0

i want reindex for some products by id i tried following code but it take all indexing to reindex required i am using magento 1.9.2.

$product = Mage::getModel('catalog/product')->load('84494'); // Product Id

$event = Mage::getSingleton('index/indexer')->logEvent( $product,$product->getResource()->getType(), Mage_Index_Model_Event::TYPE_SAVE,true );

Mage::getSingleton('index/indexer')
    ->getProcessByCode('catalog_url') // Adjust the indexer process code as needed
    ->setMode(Mage_Index_Model_Process::MODE_REAL_TIME)
    ->processEvent($event);

1 Answer 1

0

Use below code :

$productid = 1;
$product = Mage::getModel('catalog/product')->load($productid);

$event = Mage::getSingleton('index/indexer')->logEvent(
        $product,
        $product->getResource()->getType(),
        Mage_Index_Model_Event::TYPE_SAVE,
        false );

    Mage::getSingleton('index/indexer')
        ->getProcessByCode('catalog_url')
        ->setMode(Mage_Index_Model_Process::MODE_REAL_TIME)
        ->processEvent($event);
1
  • i tried this but its take all index to reindex reuired
    – sdfas
    Commented Oct 25, 2018 at 7:21

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.