The “Product Prices” and “Product Attributes” index depended on stock index?
-
16-10-2019 - |
سؤال
I found that on a client server, the stock index run cause a heavy load and slow down the site, so I changed the stock index to manually.
After I changed "stock status" index to manually mode, every time I saved a product, the "Product Prices" and "Product Attributes" always required a re-index. I found the config:
<catalog_product_attribute>
<depends>
<cataloginventory_stock/>
</depends>
</catalog_product_attribute>
<catalog_product_price>
<depends>
<cataloginventory_stock/>
</depends>
</catalog_product_price>
on app/code/core/Mage/CatalogInventory/etc/config.xml
So I removed (commented out) that xml part and those two indexers seem ok, but could anyone explain for me what the tag for? just the order for indexers to run or something deeper than that? is it safe to remove those sections?
المحلول
If you look into the Mage_CatalogInventory_Model_Indexer_Stock
then you will notice that as part of the function _registerEvent
the event entity is checked. If this entity matches type core_config_data
and the cataloginventory/options/show_out_of_stock
value has changed then the following code is run:
Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price')
->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX);
Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_attribute')
->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX);
Also if the 'status' attribute has changed then the indexer will reindex the product, check _registerCatalogProductEvent
and _registerStockItemSaveEvent
is where if the status changes then the price appears to be reindex. See comment in code.
// Saving stock item without product object
// Register re-index price process if products out of stock hidden on Front-end
It appears that if you do not have the hidden stock on front end option then the indexers are not locked together but just in case you do magento have added this dependency.
Final note on the depends: This was added to insure that the indexes are completed in the correct order as you would not want one index to complete and then have it's state changes to needs a reindex as another index has updated it's state.