Skip to content

Commit 06906b3

Browse files
committed
Fix review comments
1 parent 111f57d commit 06906b3

8 files changed

Lines changed: 58 additions & 38 deletions

File tree

SalesOrdersDataExporter/Console/Command/Export.php renamed to SalesOrdersDataExporter/Console/Command/ExportOnDemmand.php

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@
1616
use Magento\SalesOrdersDataExporter\Console\Command\Link;
1717
use Magento\SalesOrdersDataExporter\Model\Indexer\DateTimeRangeOrderProcessor;
1818
use Symfony\Component\Console\Command\Command;
19-
use Symfony\Component\Console\Exception\ExceptionInterface;
20-
use Symfony\Component\Console\Input\ArrayInput;
2119
use Symfony\Component\Console\Input\InputArgument;
2220
use Symfony\Component\Console\Input\InputInterface;
2321
use Symfony\Component\Console\Output\OutputInterface;
24-
use Throwable;
2522

2623
/**
2724
* Command export orders since certain time in the past
2825
*/
29-
class Export extends Command
26+
class ExportOnDemmand extends Command
3027
{
3128
private const COMMAND_NAME = 'commerce-data-export:orders:export-on-demmand';
3229
private CommerceDataExportLoggerInterface $logger;
@@ -35,6 +32,13 @@ class Export extends Command
3532
private DateTimeFactory $dateTimeFactory;
3633
private Link $linkCommand;
3734

35+
/**
36+
* @param CommerceDataExportLoggerInterface $logger
37+
* @param FeedIndexMetadata $metadata
38+
* @param DateTimeRangeOrderProcessor $processor
39+
* @param DateTimeRangeOrderProcessor dateTimeFactory
40+
* @param Link $link
41+
*/
3842
public function __construct(
3943
CommerceDataExportLoggerInterface $logger,
4044
FeedIndexMetadata $metadata,
@@ -51,6 +55,9 @@ public function __construct(
5155
parent::__construct();
5256
}
5357

58+
/**
59+
* @inheritdoc
60+
*/
5461
protected function configure()
5562
{
5663
$this
@@ -65,14 +72,16 @@ protected function configure()
6572
parent::configure();
6673
}
6774

75+
/**
76+
* @inheritdoc
77+
*/
6878
protected function execute(InputInterface $input, OutputInterface $output): int
6979
{
7080
$from = $this->dateTimeFactory->create($input->getArgument('from'));
7181
$to = $this->dateTimeFactory->create();
7282

73-
7483
$returnCode = $this->ensureAssignedUuids($from, $to, $output);
75-
if ($returnCode != 0) {
84+
if ($returnCode != Cli::RETURN_SUCCESS) {
7685
return Cli::RETURN_FAILURE;
7786
}
7887

@@ -83,18 +92,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8392

8493
private function ensureAssignedUuids(DateTime $from, DateTime $to, OutputInterface $output): int
8594
{
86-
87-
88-
try {
89-
return $this->linkCommand->
90-
prepareForExport(10000, $output, $from->format(DateTimeInterface::W3C),
91-
$to->format(DateTimeInterface::W3C));
92-
} catch (ExceptionInterface $e) {
93-
$this->logger->error(
94-
sprintf('Command "commerce-data-export:orders:link" failed. Message: %s', $e->getMessage())
95+
$returnCode = $this->linkCommand->
96+
prepareForExport(
97+
10000,
98+
$output,
99+
$from->format(DateTimeInterface::W3C),
100+
$to->format(DateTimeInterface::W3C)
95101
);
96-
97-
return Cli::RETURN_FAILURE;
102+
if ($returnCode != Cli::RETURN_SUCCESS) {
103+
$this->logger->error('Command "commerce-data-export:orders:link" failed.');
98104
}
105+
return $returnCode;
99106
}
100107
}

SalesOrdersDataExporter/Console/Command/Link.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
135135
? (new \DateTime($input->getOption(self::OPTION_TO)))->format(\DateTimeInterface::W3C)
136136
: null;
137137

138-
return $this->link($batchSize, $output, $from, $to, $state);
138+
return $this->prepareForExport($batchSize, $output, $from, $to, $state);
139139
} catch (\Throwable $e) {
140140
$output->writeln('<error>Failed to update UUID. Check logs</error>');
141141
$this->logger->error(

SalesOrdersDataExporter/Model/Indexer/DateTimeRangeOrderProcessor.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ class DateTimeRangeOrderProcessor
2020
private DataSerializerInterface $serializer;
2121
private FeedIndexProcessorInterface $delegatingProcessor;
2222

23-
public function __construct(ResourceConnection $resourceConnection, BatchIteratorFactory $batchIteratorFactory, DataSerializerInterface $serializer, FeedIndexProcessorInterface $delegatingProcessor)
24-
{
23+
public function __construct(
24+
ResourceConnection $resourceConnection,
25+
BatchIteratorFactory $batchIteratorFactory,
26+
DataSerializerInterface $serializer,
27+
FeedIndexProcessorInterface $delegatingProcessor
28+
) {
2529
$this->resourceConnection = $resourceConnection;
2630
$this->batchIteratorFactory = $batchIteratorFactory;
2731
$this->serializer = $serializer;
@@ -30,7 +34,12 @@ public function __construct(ResourceConnection $resourceConnection, BatchIterato
3034

3135
public function fullReindex(FeedIndexMetadata $metadata, $from, $to): void
3236
{
33-
$idsProvider = new DateTimeRangeOrderIdsProvider($this->resourceConnection, $this->batchIteratorFactory, $from, $to);
37+
$idsProvider = new DateTimeRangeOrderIdsProvider(
38+
$this->resourceConnection,
39+
$this->batchIteratorFactory,
40+
$from,
41+
$to
42+
);
3443
$this->delegatingProcessor->fullReindex($metadata, $this->serializer, $idsProvider);
3544
}
3645
}

SalesOrdersDataExporter/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ Reindexing is currently limited to orders modified in the last 7 days.
4040
Note that `commerce-data-export:orders:link` will assign uuids to the orders older than last 7 days but only orders
4141
modified within that timeframe will be exported.
4242

43-
### Orders On Demmand
43+
### Orders on demand
4444
Posibility to load sales orders from a date on SaaS Order Service. It's an independent process from usual sales order flow.
4545
To load orders:
4646
```shell
47-
bin/magento commerce-data-export:orders:export-on-demmand yyyymmdd
47+
bin/magento commerce-data-export:orders:export-on-demand yyyymmdd
4848
```
49-
The command will assing uuids to orders and index them in sales_data_export_on_demmand_orders. As it is a on demmand op, no index is scheduled.
49+
The command will assing uuids to orders and index them in sales_data_export_on_demand_orders. As it is a on demand op, no index is scheduled.

SalesOrdersDataExporter/etc/db_schema.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<column xsi:type="int"
4444
name="id"
4545
padding="10"
46-
unsigned="true"––
46+
unsigned="true"
4747
nullable="false"
4848
comment="ID" />
4949
<column xsi:type="mediumtext"

SalesOrdersDataExporter/etc/di.xml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
</arguments>
2727
</virtualType>
2828
<virtualType
29-
name="Magento\SalesOrdersDataExporter\Model\Indexer\OrdersOnDemmandExportFeedIndexMetadata"
29+
name="Magento\SalesOrdersDataExporter\Model\Indexer\OnDemandOrdersFeedIndexMetadata"
3030
type="Magento\DataExporter\Model\Indexer\FeedIndexMetadata">
3131
<arguments>
32-
<argument name="feedName" xsi:type="string">salesOrdersOnDemmandExport</argument>
32+
<argument name="feedName" xsi:type="string">onDemandSalesOrders</argument>
3333
<argument name="feedIdentity" xsi:type="string">commerceOrderId</argument>
3434
<argument name="sourceTableName" xsi:type="string">sales_order</argument>
3535
<argument name="sourceTableField" xsi:type="string">entity_id</argument>
@@ -53,23 +53,25 @@
5353
<virtualType name="Magento\SalesOrdersDataExporter\Model\OrdersFeed"
5454
type="Magento\DataExporter\Model\Feed">
5555
<arguments>
56-
<argument name="feedIndexMetadata" xsi:type="object">Magento\SalesOrdersDataExporter\Model\Indexer\OrdersFeedIndexMetadata</argument>
56+
<argument name="feedIndexMetadata" xsi:type="object">
57+
Magento\SalesOrdersDataExporter\Model\Indexer\OrdersFeedIndexMetadata</argument>
5758
<argument name="hasRemovableEntities" xsi:type="boolean">false</argument>
5859
<argument name="dateTimeFormat" xsi:type="const">\DateTimeInterface::RFC3339</argument>
5960
</arguments>
6061
</virtualType>
6162
<virtualType name="Magento\SalesOrdersDataExporter\Model\OrdersOnDemmandExportFeed"
62-
type="Magento\DataExporter\Model\Feed">
63+
type="Magento\DataExporter\Model\Feed">
6364
<arguments>
64-
<argument name="feedIndexMetadata" xsi:type="object">Magento\SalesOrdersDataExporter\Model\Indexer\OrdersOnDemmandExportFeedIndexMetadata</argument>
65+
<argument name="feedIndexMetadata" xsi:type="object">
66+
Magento\SalesOrdersDataExporter\Model\Indexer\OnDemandOrdersFeedIndexMetadata</argument>
6567
<argument name="hasRemovableEntities" xsi:type="boolean">false</argument>
6668
<argument name="dateTimeFormat" xsi:type="const">\DateTimeInterface::RFC3339</argument>
6769
</arguments>
6870
</virtualType>
69-
<type name="Magento\SalesOrdersDataExporter\Console\Command\Export">
71+
<type name="Magento\SalesOrdersDataExporter\Console\Command\ExportOnDemmand">
7072
<arguments>
7173
<argument name="metadata" xsi:type="object">
72-
Magento\SalesOrdersDataExporter\Model\Indexer\OrdersOnDemmandExportFeedIndexMetadata</argument>
74+
Magento\SalesOrdersDataExporter\Model\Indexer\OnDemandOrdersFeedIndexMetadata</argument>
7375
<argument name="processor" xsi:type="object">
7476
Magento\SalesOrdersDataExporter\Model\Indexer\DateTimeRangeOrderProcessor</argument>
7577
</arguments>
@@ -234,7 +236,7 @@
234236
<argument name="classMap" xsi:type="array">
235237
<item name="salesOrders" xsi:type="string">
236238
Magento\SalesOrdersDataExporter\Model\OrdersFeed</item>
237-
<item name="salesOrdersOnDemmandExport" xsi:type="string">
239+
<item name="onDemandSalesOrders" xsi:type="string">
238240
Magento\SalesOrdersDataExporter\Model\OrdersOnDemmandExportFeed</item>
239241
</argument>
240242
</arguments>
@@ -260,7 +262,7 @@
260262
<item name="link" xsi:type="object">
261263
Magento\SalesOrdersDataExporter\Console\Command\Link</item>
262264
<item name="export" xsi:type="object">
263-
Magento\SalesOrdersDataExporter\Console\Command\Export</item>
265+
Magento\SalesOrdersDataExporter\Console\Command\ExportOnDemmand</item>
264266
</argument>
265267
</arguments>
266268
</type>

SalesOrdersDataExporter/etc/et_schema.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
provider="Magento\SalesOrdersDataExporter\Model\Provider\Orders">
1313
<using field="commerceOrderId" />
1414
</field>
15-
<field name="salesOrdersOnDemmandExport" type="OrderV2" repeated="true"
15+
<field name="onDemandSalesOrders" type="OrderV2" repeated="true"
1616
provider="Magento\SalesOrdersDataExporter\Model\Provider\Orders">
1717
<using field="commerceOrderId" />
1818
</field>

SalesOrdersDataExporter/etc/query.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@
7777
<link-source name="store_website" link-type="left">
7878
<attribute name="code" alias="websiteCode" />
7979
<using glue="and">
80-
<condition attribute="website_id" operator="eq" type="identifier">store.website_id</condition>
80+
<condition attribute="website_id" operator="eq" type="identifier">
81+
store.website_id</condition>
8182
</using>
8283
</link-source>
8384
</source>
8485
</query>
85-
<query name="salesOrdersOnDemmandExport">
86+
<query name="onDemandSalesOrders">
8687
<source name="sales_order">
8788
<attribute name="entity_id" alias="commerceOrderId" />
8889
<attribute name="increment_id" alias="commerceOrderNumber" />
@@ -152,7 +153,8 @@
152153
<link-source name="store_website" link-type="left">
153154
<attribute name="code" alias="websiteCode" />
154155
<using glue="and">
155-
<condition attribute="website_id" operator="eq" type="identifier">store.website_id</condition>
156+
<condition attribute="website_id" operator="eq"
157+
type="identifier">store.website_id</condition>
156158
</using>
157159
</link-source>
158160
</source>

0 commit comments

Comments
 (0)