2

Below is my attempt to overwrite two pieces of magento core / enterprise code. However, I'm unsure as to how to overwrite these because they're already extensions of other pieces of code. Any elucidation is appreiciated.

Controller class definition:

require_once 'Mage/Wishlist/controllers/IndexController.php';
class Enterprise_Wishlist_IndexController extends Mage_Wishlist_IndexController

Model class definition:

class Mage_Wishlist_Model_Wishlist extends Mage_Core_Model_Abstract

Attempted controller overwrite definition:

require_once(Mage::getModuleDir('controllers', 'Enterprise_Wishlist') . DS . 'IndexController.php');
class  Namespace_Wishlist_IndexController extends Enterprise_Wishlist_IndexController

Attempted Model overwrite definition:

class Namespace_Wishlist_Model_Wishlist extends Mage_Wishlist_Model_Wishlist

config.xml for module:

<?xml version = "1.0"?>
<config>
    <modules>
        <Namespace_Wishlist>
            <version>0.0.1</version>
        </Namespace_Wishlist>
    </modules>
    <frontend>
        <routers>
            <wishlist>
                <args>
                    <modules>
                        <Namespace_Wishlist before="Enterprise_Wishlist">Namespace_Wishlist</Namespace_Wishlist>
                    </modules>
                </args>
            </wishlist>
        </routers>
    </frontend>
    <global>
        <models>
            <wishlist>
                <rewrite>
                    <wishlist>Namespace_Wishlist_Model_Wishlist</wishlist>
                </rewrite>
            </wishlist>
        </models>
    </global>
</config>

This is the .xml declaration:

<?xml version = "1.0"?>
<config>
    <modules>
        <namespace_wishlist>
            <active>true</active>
            <codepool>local</codepool>
        </namespace_wishlist>
    </modules>
</config>

1 Answer 1

4

You are doing it right. There is only one think missing. You need to tell magento that your module depends on Enterprise_Wishlist so it will be loaded after that. Also codepool should be codePool.
So your declaration xml should look like this:

<?xml version = "1.0"?>
<config>
    <modules>
        <Namespace_Wishlist>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Enterprise_Wishlist />
            </depends>
        </Namespace_Wishlist>
    </modules>
</config>
2
  • I could kiss you. Feb 18, 2015 at 21:30
  • 3
    please don't. You don't know where I've been. :)
    – Marius
    Feb 18, 2015 at 21:36

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.