9

Could someone explain me what is the difference between the indexes catalog_category_product and catalog_product_category?

From db i see that catalog_category_product is related to table catalog_category_product_index, but i don't find to which table is related catalog_product_category index.

10
  • There is no catalog_product_category table in Magento 2.1.5 CE & catalog_category_product stores Category wise Product Info
    – Jackson
    Mar 22, 2017 at 8:12
  • Yes i see that, so what is the role of catalog_product_category index?
    – LucScu
    Mar 22, 2017 at 8:44
  • There is no catalog_product_category Index table as well
    – Jackson
    Mar 22, 2017 at 8:51
  • 2
    @AnkitShah I think my question is clear and you continue to give useless reply. What is the role of catalog_product_category index if it isn't related to any table? What does this index when run?
    – LucScu
    Mar 22, 2017 at 9:05
  • @AnkitShah Do you give vote down? Are you serious?
    – LucScu
    Mar 23, 2017 at 7:46

3 Answers 3

5

The real difference is in the partial reindexing features:

  • the catalog_category_product index reindexes partially by Category ID (accepts list of category IDs to reindex);
  • the catalog_product_category index reindexes partially by Product ID (accepts list of product IDs to reindex);

Both act on the same database tables, it's just the input that differs.

2
1

Looking deep in magento core files, you notice that catalog_product_category index model is Magento\Catalog\Model\Indexer\Product\Category that extends Magento\Catalog\Model\Indexer\Category\Product that is the model of catalog_category_product index.

Both of them $fullActionFactory and $rowsActionFactory entities extends from Magento\Catalog\Model\Indexer\Category\Product\AbstractAction that has

const MAIN_INDEX_TABLE = 'catalog_category_product_index';

So we can say that both indexer works and save data on the same table catalog_category_product_index.

1

catalog_product_category : the "true" data saved by product. Those are the categories checked in the back-office when you edit the product.

catalog_product_category_index : where the product are "really". Meaning, if the parent category has "is_anchor" at yes, it means it has also the children category in it. So, it's "normal" to have both of those table.

1
  • My answer was about the difference between the two index catalog_product_category and catalog_category_product, nothing about db tables.
    – LucScu
    Jan 28, 2020 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.