2
votes

I'm trying to override class Mage_Catalog_Block_Navigation located at app/code/core/Mage/Catalog/Block/Navigation.php

I've created this three files:

1.- app/code/local/Global/Catalog/Block/Navigation.php

2.- app/code/local/Global/Catalog/etc/config.xml

3.- app/etc/modules/Global_All.xml

Code:

Global_All.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Global_Catalog>
      <active>true</active>
      <codePool>local</codePool>
    </Global_Catalog>
  </modules>
</config>

Config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Global_Catalog>
      <version>1.0</version>
    </Global_Catalog>
  </modules>
  <global>
    <blocks>
      <catalog>
        <rewrite>
          <navigation>Global_Catalog_Block_Navigation</navigation>
        </rewrite>
      </catalog>
    </blocks>
  </global>
</config>

Navigation.php

class Global_Catalog_Block_Navigation extends Mage_Catalog_Block_Navigation 
{

   protected function _renderCategoryMenuItemHtml(...){
     .......rewriting code for this method.......

   }

}

I've been trying to overwrite this method but I can't, can anybody guide me? maybe check for some typo I haven't noticed yet or Am I missing something?

Thanks,

2

2 Answers

0
votes

Try <navigation>Mage_Catalog_Block_Navigation</navigation> and rename your Naviation.php to

class Global_Catalog_Block_Navigation extends Mage_Catalog_Block_Navigation 
{

   protected function _renderCategoryMenuItemHtml(...){
     .......rewriting code for this method.......

   }

}

Finally, change your module.xml to

<modules>
    <Mage_Catalog>
      <active>true</active>
      <codePool>local</codePool>
    </Mage_Catalog>
</modules>
0
votes

Ok. So the problem was I was trying to overwrite a core file from Magento. When I first asked the question I was CREATING a module, instead of overwriting an existing one. So for you fellows out there if you want to overwride a Magento file the right way, this is how you do it. Very simple.

I was trying to overwrite Mage_Catalog_Block_Navigation located at

app/code/core/Mage/Catalog/Block/Navigation.php

All I need it to do, was to create the same root and folders although within the LOCAL folders. Being that said, this would be the route for my overwriting class.

app/code/local/Mage/Catalog/Block/Navigation.php

Note the LOCAL instead of CORE. The Navigation.php is basically the same core file (Copy & Paste), although the function I was trying to overwrite

   function protected function _renderCategoryMenuItemHtml(...)

within my newley created file, was going to return another statement, different from the core file.

Good Luck.