I am trying to rewrite app/code/core/Mage/Catalog/controllers/Product/CompareController.php
. In my config.xml I have the following:
<frontend>
<routers>
<catalog>
<args>
<modules>
<Slice_CustomCompare before="Mage_Catalog">Slice_CustomCompare_Catalog_Product_Compare</Slice_CustomCompare>
</modules>
</args>
</catalog>
</routers>
</frontend>
and in app/code/local/Slice/CustomCompare/controllers/Product/CompareController.php
I have:
<?php
require_once(Mage::getModuleDir('controllers','Mage_Catalog').DS.'CompareController.php');
class Slice_CustomCompare_Product_CompareController extends Mage_Catalog_Product_CompareController {
public function removeAction() {
Mage::log('Slice_CustomCompare_Product_CompareController:removeAction');
}
}
?>
When I try to remove a product from the compare list I don't get Slice_CustomCompare_Product_CompareController:removeAction
in my logs. Instead I get output that I added to the method in the core code. What am I missing? Why is my rewrite not working?
Best Answer
Your config section should look like this:
This means that Magento looks for a controller in
Caupo/CustomCompare/controllers
before looking inMage/Catalog/controllers
.The controller path must follow the same file path as the original controller (but looks like you already have that:)
And your require statement should be like this:
I think it works with this also but I'm not sure: