Magento Forum

   
Overriding methods
 
Alekc
Jr. Member
 
Total Posts:  20
Joined:  2008-05-29
 

Hi, i was fooling around trying to understand the way to overriding magento methods (so i wouldn’t need to hack core files each time).

I’ve chosen to override getToolbarBlock() of Product list.
My files:

/app/etc/modules/Testcompany_All.xml

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

app/code/local/Testcompany/Catalog/Block/Product/List.php

<?php
class Testcompany_Catalog_Block_Product_List extends Mage_Catalog_Block_Product_List
{
    
public function getToolbarBlock()
    
{
        $test 
"";
        if (
$blockName $this->getToolbarBlockName()) {
            
if ($block $this->getLayout()->getBlock($blockName)) {
                
return $block;
            
}
        }
        $block 
$this->getLayout()->createBlock($this->_defaultToolbarBlockmicrotime());
        return 
$block;
    
}
}

app/code/local/Testcompany/etc/config.xml

<?xml version="1.0" ?>
<config>
    <global>
        <
blocks>
            <
catalog>
               <
rewrite>
                   <
product_list>Testcompany_Catalog_Block_Product_List</product_list>
               </
rewrite>
             </
catalog>
        </
blocks>
    </global>
</
config>

But it seems that i’m missing something since it doesn’t work. Any ideas?
Thx in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
crius
Guru
 
Avatar
Total Posts:  623
Joined:  2007-10-16
Denmark
 

Try moving app/code/local/Testcompany/etc/config.xml to app/code/local/Testcompany/Catalog/etc/config.xml .

Otherwise, renaming <Testcompany_Catalog> in Testcompany_All.xml to <Testcompany> might also work.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top