Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Proper Way To Reindex Single Item and associated Group product

Tags:

What is the proper way to reindex a single item after modifications have been made to it.

Example context:

Our company relies on a third party inventory management platform called Stone Edge. We also sell items on multiple storefronts those include Magento, Amazon, Ebay and Buy.com

Once every 10 minutes Stone Edge will download all orders from the sites and then send the inventory adjustments back to our Magento store. This is done by sending a simple http request to a php script stored on our webserver with an array of key value pairs for each of the items in inventory that have had an inventory change since the last update.

After the save function is completed on each of these, the item is then re-indexed so as not to reflect a 0 inventory in-between the time of the update and the next sitewide re-index.

I've located on the Magento forums discussion about how to re-index the item:

$item->setForceReindexRequired(true); Mage::getSingleton('index/indexer')->processEntityAction($item,Mage_CatalogInventory_Model_Stock_Item::ENTITY,Mage_Index_Model_Event::TYPE_SAVE); 

Prior to this set of instructions you would see something like

$item = Mage::getModel('cataloginventory/stock_item')->loadByProduct($entityid); $item->addQty($change); $item->save(); 

However, after completing this, a problem became apparent. The items themselves were re-indexed, but if they were a member of a grouped product, then the group product was not updated.

There is an obvious issue that I will need to address. What is the best approach to this problem?

I will post an answer if I happen to come up with one.

like image 303
ajameswolf Avatar asked Dec 12 '12 19:12

ajameswolf


People also ask

How do I reindex in Magento?

Log in to Magento 2 Admin and navigate to System → Index Management. You will see the panel above. Select indexers, which has status Reindex Required, then select in Actions menu Update on Schedule. Press Submit button to apply selected mode to indexers.

How does Magento 2 indexing work?

What is indexing in Magento 2? Put simply, indexing is the way Magento 2 converts refreshable data (products, categories, prices, etc.) to enhance the storefront performance. When you refresh the converted data it needs an update or Magento 2 to be reindex programmatically or manually.

Why do we do Reindexing in Magento 2?

When the data changes, the transformed data must be updated or reindexed. With the support of reindexing, Magento 2 store owners can quickly and correctly change the store data, reduce the waiting time of customers, and increase the conversion rate.

What does indexer reindex do?

Reindex. Use this command to reindex all or selected indexers one time only. This command reindexes one time only. To keep indexers up-to-date, you must set up a cron job.


1 Answers

Kindly note that the production collection related to grouped product will try to join the price index. So you would need to run the price index and then you would see the result. To run only price index you can run, got to magento root folder and then:

php shell/indexer.php --reindex catalog_product_price 

Best of luck !

like image 165
Bijeesh K G Avatar answered Sep 30 '22 02:09

Bijeesh K G