Magento index update for one or more specific products

I want to know if there is a way to update the magento index for one or more products. So, for example, I have 100 products that I just programmatically updated the price ... and now I need to kick the indexer so that it recalculates the price for these 100 products. So just to be clear ...

I know you can just update one index for ALL products. For example, this will update the price index for all products:

$process = Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price');
$process->reindexEverything();

      

And I also know that it is possible to update ALL indexes of just one product (or multiple products if you do it in a loop):

Mage::getSingleton('index/indexer')->processEntityAction(
  $product, Mage_Catalog_Model_Product::ENTITY, 
  Mage_Index_Model_Event::TYPE_SAVE
);

      

BUT, none of these options work for me. I need to be able to make a cross section of these two. How can I take one or more products and update only one index, like a price index?

I am working with Magento CE 1.6.2.0.

EDIT: By the way, on Magento 1.3 I was able to accomplish this by following these steps, but it doesn't work anymore.

Mage::getModel('catalogindex/indexer')->plainReindex(
  $listOfProductIds,
  Mage_CatalogIndex_Model_Indexer::REINDEX_TYPE_PRICE
);

      

+3


source to share


2 answers


Try

Mage::getSingleton('catalogindex/indexer')->plainReindex($productIds);
Mage::getSingleton('catalogindex/aggregation')->clearProductData($productIds);

      

Another idea:



Mage::getResourceModel('catalog/product_indexer_price')->reindexProductIds($productIds);

      

This works for me:

$catalogSearchIndexer = Mage::getResourceSingleton('catalogsearch/fulltext');
$catalogSearchIndexer->rebuildIndex($storeId, $productIds);

      

+1


source


If your index mode is set to manual, it still tracks all changes to index_event. You can index all pending changes with$process->indexEvents();



+1


source







All Articles