EmicoEcommerce / Magento2TweakwiseExport-archived

Magento 2 module for Tweakwise export
Other
6 stars 16 forks source link

Magento 2.2.5 changes in indexing `catalog_category_product_index` #53

Closed jasperzeinstra closed 5 years ago

jasperzeinstra commented 6 years ago

Tweakwise export isn't compatibale with Magento 2.2.5. They've changed the way the category products are indexed. More information can be found here: https://devdocs.magento.com/guides/v2.2/config-guide/cli/config-cli-subcommands-index.html#config-cli-subcommands-index-reindex-parallel

In the database the table catalog_category_product_index isn't filled any more, instead they've created a table for each store (catalog_category_product_index_store1, catalog_category_product_index_store2, …). Tweakwise export isn't expecting this and isn't finding any category product relation anymore. Resulting in empty categories.

Environment

Steps to reproduce

  1. Install Magento from master branch.
  2. Run indexer
  3. Export to tweakwise

Actual result

  1. Notice that product in XML export file doesn't contain any category ids. screen shot 2018-07-24 at 16 06 05

Expected result

martijnrmediact commented 6 years ago

@Fgruntjes could you look into this? We have multiple clients with the same issue.

hostep commented 6 years ago

Confirmed, we also see this problem after upgrading to Magento 2.2.5 (from 2.2.2).

Dirty and ugly fix (not very well tested):

--- a/src/Model/Write/Products/CollectionDecorator/CategoryReference.php
+++ b/src/Model/Write/Products/CollectionDecorator/CategoryReference.php
@@ -18,7 +18,7 @@ class CategoryReference extends AbstractDecorator
     {
         $query = $this->getConnection()
             ->select()
-            ->from($this->getTableName(AbstractAction::MAIN_INDEX_TABLE), ['category_id', 'product_id'])
+            ->from($this->getTableName(AbstractAction::MAIN_INDEX_TABLE . '_store' . $collection->getStoreId()), ['category_id', 'product_id'])
             ->where('store_id = ?', $collection->getStoreId())
             ->where('product_id IN(' . implode(',', $collection->getIds()) . ')')
             ->query();

You can't add this like this to the module, since this module needs to support Magento < 2.2.5 & Magento >= 2.2.5, so a proper solution is probably to rewrite this select and use some kind of built-in function from Magento to get this data (if that exists).

jasperzeinstra commented 6 years ago

@hostep we've already created a nice fix in the way Magento indented to get the table name based on a store, see: https://github.com/EmicoEcommerce/Magento2TweakwiseExport/pull/54

hostep commented 6 years ago

@jasperzeinstra: ah, I failed to look into the open PR's 😄 Looks much better then my hack.

Thanks for the heads up! 🙂

Update: left a comment behind in the PR, since it's not the correct solution if we want this module to be compatible with Magento 2.2.4 and lower.

edwinljacobs commented 6 years ago

This fix (a variant thereof) will soon be released, update will follow.

edwinljacobs commented 6 years ago

Fix for this issue has been released in 1.2.0