6

I've read about ten different places (mostly answers on Magento stack exchange) about how to rewrite a model that has already been rewritten, but can't get my module to work. I've used the "Modules conflict detector" extension to try to debug the problem, with no success.

So my module rewrites a model from another module, which rewrites a core model.

The relevant part of the other module's config.xml:
(file path /app/code/local/GoMage/Navigation/etc/config.xml)

<?xml version="1.0" encoding="utf-8"?>
<config>
  <modules>
    <GoMage_Navigation>
      <version>3.2</version>
    </GoMage_Navigation>
  </modules>
  <global>
    <models>
      <catalog>
        <rewrite>
          <layer_filter_item>GoMage_Navigation_Model_Layer_Filter_Item</layer_filter_item>
        </rewrite>
      </catalog>
    </models>
  </global>
</config>

My config.xml:
(file path /app/code/local/OOTD/Navigation/etc/config.xml)

<?xml version="1.0" encoding="utf-8"?>
<config>
  <modules>
    <OOTD_Navigation>
      <version>0.1</version>
    </OOTD_Navigation>
  </modules>
  <global>
     <models>
        <catalog>
          <rewrite>
            <layer_filter_item>OOTD_Navigation_Model_Layer_Filter_Item</layer_filter_item>
          </rewrite>
        </catalog>
     </models>
  </global>
</config>

/app/etc/modules/OOTD_Navigation.xml:

<?xml version="1.0" encoding="utf-8"?>
<config>
  <modules>
    <OOTD_Navigation>
      <active>true</active>
      <codepool>local</codepool>
      <depends>
        <GoMage_Navigation />
      </depends>
    </OOTD_Navigation>
  </modules>
</config>

/app/code/local/OOTD/Navigation/Model/Layer/Filter/Item.php:

class OOTD_Navigation_Model_Layer_Filter_Item extends GoMage_Navigation_Model_Layer_Filter_Item {
  // ...
}

I've tried so many things I don't know what to do anymore. If you need more information just ask. Thanks in advance.

2
  • What do you mean your module isn't working ? What is the error you are getting ? You may comment out the rewrite block from GoMage module since it is not longer needed.
    – Hashid
    Commented Nov 6, 2014 at 10:16
  • The override doesn't work. My code doesn't run. My module does show up in system/configuration/advanced, however. Commented Nov 6, 2014 at 10:22

2 Answers 2

7

codepool is case sensitive and should be codePool

1
  • 1
    This was correct! To future googlers, take a look at Andreas von Studnitz' answer below, it will help you debug your problem. Commented Nov 6, 2014 at 11:10
4

It should work the way you are doing it, it looks absolutely correct. Could you add a file "text.php" with the following content in you "shell" folder below the Magento root folder?

<?php
require_once('../app/Mage.php');
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

$item = Mage::getModel('catalog/layer_filter_item');
echo get_class($item);

The output should be "OOTD_Navigation_Model_Layer_Filter_Item". If it is, then your rewrite is working and you have a different issue. If it is "GoMage_Navigation_Model_Layer_Filter_Item", we have to check your rewrite code further.

2
  • Nice way to find if rewrite is working. Thanks Andreas :-)
    – Hashid
    Commented Nov 6, 2014 at 10:38
  • 1
    Thanks for your answer, I used it to verify Fooman's answer. :) Commented Nov 6, 2014 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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