Reputation: 55
How to so index of single product? I have tried below code but it's not working.
Mage::getSingleton('index/indexer')->processEntityAction( $product, Mage_Catalog_Model_Product::ENTITY, Mage_Index_Model_Event::TYPE_SAVE )
is there any other solution?
Upvotes: 2
Views: 2505
Reputation: 101
require_once 'app/Mage.php';
umask(0);
Mage::app();
$childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds('121644');
$productsIds = $childIds;
$event = Mage::getModel('index/event');
$event->setNewData(array(
'product_ids' => $productsIds,));
Mage::getResourceSingleton('catalog/category_indexer_product')->catalogProductMassAction($event);
Mage::getResourceModel('catalog/product_indexer_price')->reindexProductIds($productsIds);
Mage::getResourceModel('cataloginventory/indexer_stock')->reindexProducts($productsIds);
Mage::getResourceModel('catalog/product_indexer_eav_source')->reindexEntities($productsIds);
$catalogSearchIndexer = Mage::getResourceModel('catalogsearch/fulltext');
$catalogSearchIndexer->rebuildIndex(null, $productsIds);
echo "Done";exit;
Upvotes: 0
Reputation: 2988
You can do product indexing by their attribute like this:
$indexer = Mage::getSingleton('index/indexer')->processEntityAction($_product, 'catalog_url', Mage_Index_Model_Event::TYPE_SAVE);
Hope, it works for you.
Upvotes: 1
Reputation: 61
$process = Mage::getSingleton('index/indexer')->getProcessByCode("cataloginventory_stock");
$process->reindexAll();
Try use this codes depending do you need:
catalog_product_attribute Product Attributes
catalog_product_price Product Prices
catalog_url Catalog Url Rewrites
catalog_product_flat Product Flat Data
catalog_category_flat Category Flat Data
catalog_category_product Category Product
catalogsearch_fulltext Catalog Search Index
cataloginventory_stock Stock status
Upvotes: 1