In some circumstances, products that are not assigned to any category disappear from the search.

It turns out that this is caused by performing any of the following two actions from the Magento admin of any Magento CE 1.7, 1.8 or 1.9 installation:

  • Move any category in the category tree (in CE 1.6 the issue is also present, but only when moving a direct child category of the default category).
  • Change the product assignment for any category (changing the category assignment of a product does not trigger the issue).

This issue can be reproduced as follows:

  1. From the admin, create a product without assigning any category (or take an existing product, and remove the category assignment), and make sure the product can be found using the frontend search (status enabled, visible in search, positive stock quantity, status status enabled, assigned to the correct websites when using a multistore setup).
  2. In the frontend, search for the product and observe that the product is shown on the page
  3. From the admin, perform any of the above two actions (move any category or change the product assignment for any category).
  4. In the frontend, search for the product and observe that the product is missing.

The issue seems to be caused by the catalog_category_product index.

The following function can be used to determine whether this issue is present:

function getProductIdsMissingFromCatalogCategoryProductIndex(Mage_Core_Model_Store $store)
    /** @var Mage_Catalog_Model_Resource_Product_Collection $productCollection */
    $productCollection = Mage::getResourceModel('catalog/product_collection');
    $productCollection->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
    $select = $productCollection->getSelect();
        ['ccpi' => 'catalog_category_product_index'],
            'ccpi.product_id = e.entity_id AND ccpi.category_id = %d AND ccpi.store_id = %d',
    $select->where('ccpi.product_id IS NULL');
    return $productCollection->getConnection()->fetchCol($select);

The issue can be temporarily fixed by reindexing the catalog_category_product index.

This issue has been reported to Magento via the bug tracker on the 26th of November 2014 as issue #6542, but never got a response.

A workaround for this issue is to assign each to the root category of each store group.

I am looking for any actual fix for this bug, such that I do not need to apply this workaround.

Does anyone have an idea how to fix this bug?

  • You need a fix instead of a workaround? I can't get tell the difference. Nov 23, 2015 at 13:49
  • I am looking for a code patch to resolve the bug (fix), not a suggestion to assign all products to the default category (workaround). Nov 23, 2015 at 13:51
  • I see it now. Looks like someone didn't test their devs thoroughly, or didn't see this use case. Nov 23, 2015 at 14:17
  • Can be this related to this issue: Nov 25, 2015 at 20:47

1 Answer 1


The problem lies in the index invalidation process. If you move the category from one tree to another, it would be an incredibly cumbersome operation to retrieve all possible product identifiers and partially re-index them, as the number of such products can be counted by thousands. The best fix as from core perspective would be to simply marking category_product index as "require reindex".

For your problem, you can fix it by observing Magento event category_move and schedule a delayed full reindex of category_product index. The easiest way would be to write a file to var directory with some flag. Then by CRON, you should check for this file existence, lock it, run reindex, remove a file afterwards.

Your Answer

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

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