I have ThirdPary_Extension
that rewrites a resource class method of Mage_Catalog_Model_Resource_Product_Indexer_Price
. However, ThirdPary_Extension
goes about doing this a little strange. It's configured to rewrite only Mage_Catalog_Model_Product_Indexer_Price
, but in this class' _construct()
, it's pointing to a resource class that extends off of Mage_Catalog_Model_Resource_Product_Indexer_Price
.
Let me illustrate.
config.xml
...
<models>
<catalog>
<rewrite>
<product_indexer_price>ThirdParty_Extension_Model_Product_Indexer_Price</product_indexer_price>
</rewrite>
</catalog>
</models>
...
ThirdParty_Extension_Model_Product_Indexer_Price
class ThirdParty_Extension_Model_Product_Indexer_Price extends Mage_Catalog_Model_Product_Indexer_Price
{
protected function _construct()
{
$this->_init('thirdparty/resource_product_indexer_price');
}
...
}
ThirdParty_Extension_Model_Resource_Product_Indexer_Price
class ThirdParty_Extension_Model_Resource_Product_Indexer_Price extends Mage_Catalog_Model_Resource_Product_Indexer_Price
{
protected function _rewrittenMethod()
{
// Good stuff
}
...
}
And in Mage_Catalog_Model_Product_Indexer_Price::reindexAll
, you have $this->_getResource()->reindexAll()
, which invokes the rewritten method as was intended.
However, this causes some issues. Depending on how you're instantiating the resource model and invoke a method, you may end up with using ThirdParty_Extension_Model_Resource_Product_Indexer_Price
(good) or Mage_Catalog_Model_Resource_Product_Indexer_Price
(bad), among one or two other things.
Obvisouly, the extension works for re-indexing prices, but I'm not a fan of how it's done. Please correct me if I misunderstand this extension.
Now the question, how do I rewrite Mage_Catalog_Model_Resource_Product_Indexer_Price
the right (lol!) way?
Rewrite both
Mage_Catalog_Model_Product_Indexer_Price
andMage_Catalog_Model_Resource_Product_Indexer_Price
to re-align everything nicely? Or..Rewrite just
ThirdParty_Extension_Model_Resource_Product_Indexer_Price
Option #1 would typically be my pick, but I'm thinking maybe there was a reason this rewrite was done in such a way, in which case #2 would be the way to go. What say ye?