magento2: Products added to a category are not shown at the frontend.
Preconditions (*)
- Magento CE <= 2.2.6
- Magento Commerce Edition <= 2.2.6
Steps to reproduce (*)
- Run magento indexer:reindex to make all indexes up to date.
- Switch all indexes to the “Update Scheduled” mode.
- Set up Cron.
- Create a simple product (visible at the frontend, qty > 0)
- Create a category.
- Go to the frontend and make sure that the category is empty.
- Open the created category (step 4) and assign the created product to it.
- Save category changes.
- Wait until Cron reindexes category changes or run magento indexer:reindex catalog_category_product.
- Open the category at the frontend.
Expected result (*)
- Category must contain the product.
Actual result (*)
- The category is still empty
The problem
It looks like the category uses the information from the ‘catalogsearch_fulltext’ index because running magento indexer:reindex catalogsearch_fulltext solves the issue.
The solution
The solution is simple: track changes in the “catalog_category_product” table and update the “catalogsearch_fulltext_cl” changelog table.
This can be done by adding an additional subscriber:
<table name="catalog_category_product" entity_column="product_id" />
to the vendor/magento/module-catalog-search/etc/mview.xml file.
So the updated file should look this way:
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Mview/etc/mview.xsd">
<view id="catalogsearch_fulltext" class="\Magento\CatalogSearch\Model\Indexer\Mview\Action" group="indexer">
<subscriptions>
<table name="catalog_product_entity" entity_column="entity_id" />
<table name="catalog_product_entity_int" entity_column="entity_id" />
<table name="catalog_product_entity_decimal" entity_column="entity_id" />
<table name="catalog_product_entity_text" entity_column="entity_id" />
<table name="catalog_product_entity_varchar" entity_column="entity_id" />
<table name="catalog_product_entity_datetime" entity_column="entity_id" />
<table name="catalog_product_website" entity_column="product_id" />
<table name="cataloginventory_stock_item" entity_column="product_id" />
<table name="catalog_product_bundle_selection" entity_column="parent_product_id" />
<table name="catalog_product_super_link" entity_column="product_id" />
<table name="catalog_product_link" entity_column="product_id" />
<table name="catalog_category_product" entity_column="product_id" />
</subscriptions>
</view>
</config>
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (12 by maintainers)
Commits related to this issue
- issue #19417 fixed — committed to mahesh-rajawat/magento2 by mahesh-rajawat 6 years ago
@larsroettig Yes, the issue still exists.