是否可以在不触发重新索引的情况下更新产品属性?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