diff --git a/app/code/Magento/CatalogDataExporter/Model/Indexer/IndexInvalidationManager.php b/app/code/Magento/CatalogDataExporter/Model/Indexer/IndexInvalidationManager.php new file mode 100644 index 000000000..09aaae283 --- /dev/null +++ b/app/code/Magento/CatalogDataExporter/Model/Indexer/IndexInvalidationManager.php @@ -0,0 +1,55 @@ +indexer = $indexer; + $this->invalidationEvents = $invalidationEvents; + } + + /** + * Invalidates all indexes subscribed on event + * + * @param string $eventName + */ + public function invalidate(string $eventName): void + { + $indexers = isset($this->invalidationEvents[$eventName]) ? $this->invalidationEvents[$eventName] : []; + foreach ($indexers as $indexer) { + $this->indexer->load($indexer)->invalidate(); + } + } +} diff --git a/app/code/Magento/CatalogDataExporter/Plugin/Index/InvalidateOnGroupChange.php b/app/code/Magento/CatalogDataExporter/Plugin/Index/InvalidateOnGroupChange.php new file mode 100644 index 000000000..6dd9336ab --- /dev/null +++ b/app/code/Magento/CatalogDataExporter/Plugin/Index/InvalidateOnGroupChange.php @@ -0,0 +1,75 @@ +invalidationManager = $invalidationManager; + $this->invalidationEvent = $invalidationEvent; + } + + /** + * Invalidate on save + * + * @param Group $subject + * @param Group $result + * @return Group + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterSave(Group $subject, Group $result) + { + $this->invalidationManager->invalidate($this->invalidationEvent); + return $result; + } + + /** + * Invalidate on delete + * + * @param Group $subject + * @param Group $result + * @return Group + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterDelete(Group $subject, Group $result) + { + $this->invalidationManager->invalidate($this->invalidationEvent); + return $result; + } +} diff --git a/app/code/Magento/CatalogDataExporter/Plugin/Index/InvalidateOnStoreChange.php b/app/code/Magento/CatalogDataExporter/Plugin/Index/InvalidateOnStoreChange.php new file mode 100644 index 000000000..f02e8c7af --- /dev/null +++ b/app/code/Magento/CatalogDataExporter/Plugin/Index/InvalidateOnStoreChange.php @@ -0,0 +1,75 @@ +invalidationManager = $invalidationManager; + $this->invalidationEvent = $invalidationEvent; + } + + /** + * Invalidate on save + * + * @param Store $subject + * @param Store $result + * @return Store + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterSave(Store $subject, Store $result) + { + $this->invalidationManager->invalidate($this->invalidationEvent); + return $result; + } + + /** + * Invalidate on delete + * + * @param Store $subject + * @param Store $result + * @return Store + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterDelete(Store $subject, Store $result) + { + $this->invalidationManager->invalidate($this->invalidationEvent); + return $result; + } +} diff --git a/app/code/Magento/CatalogDataExporter/Plugin/Index/InvalidateOnWebsiteChange.php b/app/code/Magento/CatalogDataExporter/Plugin/Index/InvalidateOnWebsiteChange.php new file mode 100644 index 000000000..bcad6bb1d --- /dev/null +++ b/app/code/Magento/CatalogDataExporter/Plugin/Index/InvalidateOnWebsiteChange.php @@ -0,0 +1,70 @@ +invalidationManager = $invalidationManager; + $this->invalidationEvent = $invalidationEvent; + } + + /** + * Invalidate on save + * + * @param Website $subject + * @param Website $result + * @return Website + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterSave(Website $subject, Website $result) + { + $this->invalidationManager->invalidate($this->invalidationEvent); + return $result; + } + + /** + * Invalidate on delete + * + * @param Website $subject + * @param Website $result + * @return Website + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterDelete(Website $subject, Website $result) + { + $this->invalidationManager->invalidate($this->invalidationEvent); + return $result; + } +} diff --git a/app/code/Magento/CatalogDataExporter/etc/di.xml b/app/code/Magento/CatalogDataExporter/etc/di.xml index ca77f0599..c1881082d 100644 --- a/app/code/Magento/CatalogDataExporter/etc/di.xml +++ b/app/code/Magento/CatalogDataExporter/etc/di.xml @@ -444,7 +444,6 @@ - @@ -460,7 +459,6 @@ - @@ -468,4 +466,35 @@ + + + + + + catalog_data_exporter_products + catalog_data_exporter_product_attributes + catalog_data_exporter_categories + + + catalog_data_exporter_products + catalog_data_exporter_product_attributes + catalog_data_exporter_categories + + + catalog_data_exporter_products + catalog_data_exporter_product_attributes + catalog_data_exporter_categories + + + + + + + + + + + + + diff --git a/app/code/Magento/ConfigurableProductDataExporter/Test/Integration/ConfigurableProductsTest.php b/app/code/Magento/ConfigurableProductDataExporter/Test/Integration/ConfigurableProductsTest.php index 6ffd9ba69..a8da63212 100755 --- a/app/code/Magento/ConfigurableProductDataExporter/Test/Integration/ConfigurableProductsTest.php +++ b/app/code/Magento/ConfigurableProductDataExporter/Test/Integration/ConfigurableProductsTest.php @@ -196,7 +196,10 @@ private function validateVariantsData(ProductInterface $product, array $extract, 'selections' => $this->getVariantSelections($childProduct, $attributeCodes) ]; } - $this->assertEquals($variants, $extract['feedData']['variants']); + $actualVariants = $extract['feedData']['variants']; + usort($actualVariants, function ($a, $b){return $a['sku'] <=> $b['sku'];}); + usort($variants, function ($a, $b){return $a['sku'] <=> $b['sku'];}); + $this->assertEquals($variants, $actualVariants); } /**