Skip to content

Commit a87421e

Browse files
committed
2 parents bc4eae7 + 416d701 commit a87421e

File tree

12 files changed

+51
-35
lines changed

12 files changed

+51
-35
lines changed

CatalogDataExporter/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@
220220
<virtualType name="Magento\CatalogDataExporter\Model\Indexer\ProductFeedIndexMetadata" type="Magento\DataExporter\Model\Indexer\FeedIndexMetadata">
221221
<arguments>
222222
<argument name="feedName" xsi:type="string">products</argument>
223+
<argument name="indexerId" xsi:type="string">catalog_data_exporter_products</argument>
223224
<argument name="feedSummary" xsi:type="string">Products Feed</argument>
224225
<argument name="feedIdentity" xsi:type="string">productId</argument>
225226
<argument name="sourceTableName" xsi:type="string">catalog_product_entity</argument>
@@ -270,6 +271,7 @@
270271
<virtualType name="Magento\CatalogDataExporter\Model\Indexer\ProductAttributeFeedIndexMetadata" type="Magento\DataExporter\Model\Indexer\FeedIndexMetadata">
271272
<arguments>
272273
<argument name="feedName" xsi:type="string">productAttributes</argument>
274+
<argument name="indexerId" xsi:type="string">catalog_data_exporter_product_attributes</argument>
273275
<argument name="feedSummary" xsi:type="string">Product Attributes Feed</argument>
274276
<argument name="feedIdentity" xsi:type="string">id</argument>
275277
<argument name="sourceTableName" xsi:type="string">eav_attribute</argument>
@@ -373,6 +375,7 @@
373375
<virtualType name="Magento\CatalogDataExporter\Model\Indexer\CategoryFeedIndexMetadata" type="Magento\DataExporter\Model\Indexer\FeedIndexMetadata">
374376
<arguments>
375377
<argument name="feedName" xsi:type="string">categories</argument>
378+
<argument name="indexerId" xsi:type="string">catalog_data_exporter_categories</argument>
376379
<argument name="feedSummary" xsi:type="string">Categories Feed</argument>
377380
<argument name="feedIdentity" xsi:type="string">categoryId</argument>
378381
<argument name="sourceTableName" xsi:type="string">catalog_category_entity</argument>

DataExporter/Model/Indexer/FeedIndexMetadata.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ class FeedIndexMetadata
169169
*/
170170
private array $entityIdentifierMapping;
171171

172+
/**
173+
* @var ?string
174+
*/
175+
private ?string $indexerId;
176+
172177
/**
173178
* @param string $feedName
174179
* @param string $sourceTableName
@@ -193,6 +198,7 @@ class FeedIndexMetadata
193198
* @param string|null $feedSummary
194199
* @param string|null $viewSourceLinkField
195200
* @param array $entityIdentifierMapping
201+
* @param string|null $indexerId
196202
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
197203
*/
198204
public function __construct(
@@ -218,7 +224,8 @@ public function __construct(
218224
?Config $config = null,
219225
?string $feedSummary = null,
220226
?string $viewSourceLinkField = null,
221-
array $entityIdentifierMapping = []
227+
array $entityIdentifierMapping = [],
228+
?string $indexerId = null,
222229
) {
223230
$this->feedName = $feedName;
224231
$this->feedSummary = $feedSummary ?? '';
@@ -250,6 +257,7 @@ public function __construct(
250257
$this->viewSourceLinkField = $viewSourceLinkField;
251258
$this->config = $config ?? ObjectManager::getInstance()->get(Config::class);
252259
$this->entityIdentifierMapping = $entityIdentifierMapping;
260+
$this->indexerId = $indexerId;
253261
}
254262

255263
/**
@@ -525,4 +533,14 @@ public function getIdentifierMap(string $identifierField): ?string
525533
{
526534
return $this->entityIdentifierMapping[$identifierField] ?? null;
527535
}
536+
537+
/**
538+
* Get indexer id
539+
*
540+
* @return string|null
541+
*/
542+
public function getIndexerId(): ?string
543+
{
544+
return $this->indexerId;
545+
}
528546
}

DataExporter/Service/FeedIndexerProvider.php

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,24 @@
1616

1717
namespace Magento\DataExporter\Service;
1818

19-
use Magento\DataExporter\Model\Indexer\FeedIndexer;
2019
use Magento\DataExporter\Model\Indexer\FeedIndexMetadata;
2120
use Magento\DataExporter\Model\Logging\CommerceDataExportLoggerInterface;
2221
use Magento\Framework\Indexer\IndexerInterface;
23-
use Magento\Framework\Mview\ActionFactory;
24-
use Magento\Indexer\Model\Indexer\Collection;
22+
use Magento\Framework\Indexer\IndexerRegistry;
2523

2624
/**
2725
* Return Feed Indexer instance for given metadata
2826
*/
2927
class FeedIndexerProvider
3028
{
31-
/**
32-
* @var array|null
33-
*/
34-
private ?array $feedNameToIndexerMap = null;
35-
3629
/**
3730
* Constructor
3831
*
39-
* @param Collection $indexerCollection
40-
* @param ActionFactory $actionFactory
32+
* @param IndexerRegistry $indexerRegistry
4133
* @param CommerceDataExportLoggerInterface $logger
4234
*/
4335
public function __construct(
44-
private readonly Collection $indexerCollection,
45-
private readonly ActionFactory $actionFactory,
36+
private readonly IndexerRegistry $indexerRegistry,
4637
private readonly CommerceDataExportLoggerInterface $logger
4738
) {
4839
}
@@ -55,23 +46,22 @@ public function __construct(
5546
*/
5647
public function getIndexer(FeedIndexMetadata $metadata): ?IndexerInterface
5748
{
58-
if ($this->feedNameToIndexerMap === null) {
59-
foreach ($this->indexerCollection->getItems() as $indexer) {
60-
try {
61-
$actionIndexer = $this->actionFactory->get(
62-
$indexer->getActionClass()
63-
);
64-
if ($actionIndexer instanceof FeedIndexer) {
65-
$this->feedNameToIndexerMap[$actionIndexer->getFeedIndexMetadata()->getFeedName()] = $indexer;
66-
}
67-
} catch (\Exception $e) {
68-
$this->logger->error(
69-
'Cannot load feed indexer',
70-
['indexer' => $indexer->getId(), 'error' => $e->getMessage()]
71-
);
72-
}
73-
}
49+
if ($metadata->getIndexerId() == null) {
50+
$this->logger->warning(
51+
'Feed metadata does not contain indexer name',
52+
['feedName' => $metadata->getFeedName()]
53+
);
54+
return null;
55+
}
56+
57+
try {
58+
return $this->indexerRegistry->get($metadata->getIndexerId());
59+
} catch (\Exception $e) {
60+
$this->logger->error(
61+
'Cannot load feed indexer for feed',
62+
['feedName' => $metadata->getFeedName(), 'error' => $e->getMessage()]
63+
);
7464
}
75-
return $this->feedNameToIndexerMap[$metadata->getFeedName()] ?? null;
65+
return null;
7666
}
7767
}

ExtraProductAttributes/etc/di.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<!--
33
/**
44
* ADOBE CONFIDENTIAL
5-
* ___________________
65
*
76
* Copyright 2025 Adobe
87
* All Rights Reserved.

ExtraProductAttributes/etc/module.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<!--
33
/**
44
* ADOBE CONFIDENTIAL
5-
* ___________________
65
*
76
* Copyright 2025 Adobe
87
* All Rights Reserved.

ExtraProductAttributes/registration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
/**
33
* ADOBE CONFIDENTIAL
4-
* ___________________
54
*
65
* Copyright 2025 Adobe
76
* All Rights Reserved.

InventoryDataExporter/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<virtualType name="Magento\InventoryDataExporter\Model\Indexer\StockStatusFeedIndexMetadata" type="Magento\DataExporter\Model\Indexer\FeedIndexMetadata">
2222
<arguments>
2323
<argument name="feedName" xsi:type="string">inventoryStockStatus</argument>
24+
<argument name="indexerId" xsi:type="string">inventory_data_exporter_stock_status</argument>
2425
<argument name="feedSummary" xsi:type="string">Inventory Stock Status Feed</argument>
2526
<argument name="feedIdentity" xsi:type="string">productId</argument>
2627
<!-- source table used only during full reindex -->

ProductPriceDataExporter/Test/Integration/ExportSingleProductPriceTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,10 @@ private function getRuleByName(string $name): RuleInterface
10681068

10691069
private static function getPriceForVersion(float $price): float
10701070
{
1071-
self::$version = Bootstrap::getObjectManager()->get(ProductMetadataInterface::class)->getVersion();
1071+
if (empty(self::$version)) {
1072+
$rawVersion = Bootstrap::getObjectManager()->get(ProductMetadataInterface::class)->getVersion();
1073+
self::$version = preg_replace('/.*?(\d\.\d\.\d(?:-\w+)?).*/', '$1', $rawVersion);
1074+
}
10721075
return version_compare(self::$version, '2.4.9-dev', '>=') ? $price : round($price, 2);
10731076
}
10741077
}

ProductPriceDataExporter/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<virtualType name="Magento\ProductPriceDataExporter\Model\Indexer\ProductPriceFeedIndexMetadata" type="Magento\DataExporter\Model\Indexer\FeedIndexMetadata">
1010
<arguments>
1111
<argument name="feedName" xsi:type="string">prices</argument>
12+
<argument name="indexerId" xsi:type="string">catalog_data_exporter_product_prices</argument>
1213
<argument name="feedSummary" xsi:type="string">Product Prices Feed</argument>
13-
<!-- TODO: rename?? it's not actually identity but source of IDs for feed-->
1414
<argument name="feedIdentity" xsi:type="string">productId</argument>
1515
<argument name="sourceTableName" xsi:type="string">catalog_product_entity</argument>
1616
<argument name="sourceTableField" xsi:type="string">entity_id</argument>

ProductVariantDataExporter/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<virtualType name="Magento\ProductVariantDataExporter\Model\Indexer\ProductVariantFeedIndexMetadata" type="Magento\DataExporter\Model\Indexer\FeedIndexMetadata">
1010
<arguments>
1111
<argument name="feedName" xsi:type="string">variants</argument>
12+
<argument name="indexerId" xsi:type="string">catalog_data_exporter_product_variants</argument>
1213
<argument name="feedSummary" xsi:type="string">Product Variants Feed</argument>
1314
<argument name="feedIdentity" xsi:type="string">productId</argument>
1415
<argument name="sourceTableName" xsi:type="string">catalog_product_entity</argument>

0 commit comments

Comments
 (0)