I'm trying to create a custom Indexer under Index Management in Magento community edition 1.4, the main purpose of this custom indexer is to update a custom product attribute based on a set of calculations.
I looked into magento core code and I made something similar to what I need, but I couldn't find enough documentations around the subject.
this what I got so far:
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>
Then I created a model
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');
}
}
after implementing this code I was able to see my new custom indexer item under Index Management grid, but when I ran reindex action it just fired reindexAll() method.
Any ideas would be helpful and thank in advance.