Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
Overriding methods
 
Alekc
Jr. Member
 
Total Posts:  15
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
 
Anders Rasmussen
Sr. Member
 
Avatar
Total Posts:  165
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.

 Signature 

Anders Rasmussen
Crius (in Danish)

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
50108 users|416 users currently online|102246 forum posts