是否可以在不觸發重新索引的情況下更新產品屬性?Magento更新產品屬性,無需觸發重新索引
衆所周知,load()/ setData()/ save()方案會觸發reindex。
我查看了'Mage_Catalog_Model_Product_Action'中的'updateAttributes'方法,但我認爲它也觸發了產品reindex。
/**
* Update attribute values for entity list per store
*
* @param array $productIds
* @param array $attrData
* @param int $storeId
* @return Mage_Catalog_Model_Product_Action
*/
public function updateAttributes($productIds, $attrData, $storeId)
{
$this->_getResource()->updateAttributes($productIds, $attrData, $storeId);
$this->setData(array(
'product_ids' => array_unique($productIds),
'attributes_data' => $attrData,
'store_id' => $storeId
));
// register mass action indexer event
Mage::getSingleton('index/indexer')->processEntityAction(
$this, Mage_Catalog_Model_Product::ENTITY, Mage_Index_Model_Event::TYPE_MASS_ACTION
);
return $this;
}
'// register mass action indexer event'下面的代碼似乎會觸發索引器操作。
我不太瞭解您的解決方案, '如果屬性是全局的,則可以使用Mage_Core_Model_App :: ADMIN_STORE_ID'。我們如何使用它? – nXqd 2012-10-10 09:22:09
@Vtt你可以在$ storeId參數中使用該常量 – 2012-12-12 05:56:41