I'm trying to trigger the inserts in
catalog_product_index_eav of configurable attributes values. For a configurable product with 2 associated products, each having a different color, it would add in catalog_product_index_eav 2 additional rows (configurable entity_id, color attribute_id, color value/option_id).
This happens when configurable product is saved in admin or when I reindex in admin indexer with code 'catalog_product_attribute' (Index product attributes for layered navigation building).
I want to trigger this reindex after $product->save() in a script initiated with Mage::app('admin'); I want to do this for each product and not globally with: Mage::getModel('index/indexer')->getProcessByCode($indexer_code)-> .. ->save();
I've tested on a default Magento 184.108.40.206. I additionally tried this: Reindex single product and didn't worked.
Why I want to do this ? There are configurable products in a store that will not have these values in
catalog_product_index_eav. It works only when product is saved in admin. It doesn't work for reindex 'catalog_product_attribute'. There is something wrong about the data. As a result some categories doesn't have filters (left column, frontend category page).
I always had index to save on update. I reindexed everything because of the dependencies of indexes. Before I reindexd, some of the indexes required a full reindex (in admin).
This works for most configurable products:
// $product->save(); // Isn't required. $product->setForceReindexRequired(true); // just this is needed for the lines bellow. Mage::getSingleton('index/indexer')->processEntityAction( $product, Mage_Catalog_Model_Product::ENTITY, Mage_Index_Model_Event::TYPE_SAVE );
What works: adding the configurable attributes values in
catalog_product_index_eav from associated products for parent entity_id. These values are needed for layered navigation.
What it doesn't work:
For some configurable products, the above snippet code doesn't do it. I noticed that only after I save the product in admin and delete from
catalog_product_index_eav the entries for the configurable attributes will be inserted by the above snippet.
Don't know why those products won't have the configurable attributes rows but the other filter attributes values are inserted.