【发布时间】:2012-01-30 19:28:28
【问题描述】:
我正在尝试在 Magento 社区版 1.4 的索引管理下创建自定义索引器,此自定义索引器的主要目的是根据一组计算更新自定义产品属性。
我查看了 magento 核心代码,并做了一些与我需要的类似的东西,但我找不到足够的关于该主题的文档。
这是我目前得到的:
config.xml
<?xml version="1.0"?>
<config>
<!-- configuration -->
<global>
<index>
<indexer>
<custom_product_price>
<model>custom/indexer_price</model>
</custom_product_price>
</indexer>
</index>
</global>
<!-- configuration -->
</config>
然后我创建了一个模型
class MyModule_Custom_Model_Indexer_Price extends Mage_Index_Model_Indexer_Abstract
{
protected $_matchedEntities = array(
Mage_Catalog_Model_Product::ENTITY => array(
Mage_Index_Model_Event::TYPE_SAVE,
Mage_Index_Model_Event::TYPE_DELETE,
Mage_Index_Model_Event::TYPE_MASS_ACTION
)
);
/**
* Initialize resource model
*
*/
protected function _construct()
{
$this->_init('custome/indexer_price');
}
public function getName()
{
return Mage::helper('customizer')->__('Customizable Products');
}
public function getDescription()
{
return Mage::helper('customizer')->__('Index Customizable Product Prices');
}
public function matchEvent(Mage_Index_Model_Event $event) {
Mage::log("Should I match an event: ".$event->getEntity() . '|'. $event->getType());
return true;
}
protected function _registerEvent(Mage_Index_Model_Event $event) {
Mage::log("Should I register an event: ".$event->getEntity() . '|'. $event->getType());
}
protected function _processEvent(Mage_Index_Model_Event $event) {
Mage::log("Should I process an event: ".$event->getEntity() . '|'. $event->getType());
}
public function reindexAll() {
Mage::log('Do my processing to reindex');
}
}
在实现此代码后,我能够在索引管理网格下看到我的新自定义索引器项,但是当我运行 reindex 操作时,它只是触发了 reindexAll() 方法。
任何想法都会有所帮助,并提前致谢。
【问题讨论】:
-
不确定您在这里实际问的是什么?
标签: magento indexing magento-1.4