0

I'm trying to extend the "Mage_Catalog_Product_CompareController" class with my own class which is "Invent_Catalog_Product_CompareController" from the core.

But I can't seem to get the results that i am looking for. I suspect the problem on my config xml here is my config.xml

<config>
<frontend>
    <routers>
        <catalog>
            <args>
                <modules>
                    <invent_catalog before="Mage_Catalog">Invent_Catalog</invent_catalog>
                </modules>
            </args>
        </catalog>
    </routers>
</frontend>
</config>

and here is my CompareController.php

require_once(Mage::getModuleDir('controllers','Mage_Catalog').DS.'CompareController.php');
class Invent_Catalog_Product_CompareController extends Mage_Catalog_Product_CompareController

 public function addAction()
    {
      //My Code goes here
   }
1
  • I assume that you close the <config> tag in config.xml (it is not in the code you provided) and also you have the module declaration file in app/etc/modules and you cleared the cache.
    – Marius
    Apr 24, 2014 at 13:58

1 Answer 1

1

I think the problem is your require_once statement. It does not include the correct file.

require_once(Mage::getModuleDir('controllers','Mage_Catalog').DS.'CompareController.php');

Will include the file Mage/Catalog/controllers/CompareController.php
What you want is Mage/Catalog/controllers/Product/CompareController.php
For this use:

require_once(Mage::getModuleDir('controllers','Mage_Catalog').DS.'Product'.DS.'CompareController.php');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.