bonez
bonez

Reputation: 695

Overriding Magento Block

I'm stuck. Been messing with this all day. To me this looks like it should work but It's not, and its not outputting any errors to magento error log.

What I tried to do was simply override the getPriceHtml() function in Catalog/Block/Product.php. The module is active from the 'Advanced' tab via the system configuration.

My config.xml in app/code/local/Brian/Pricefix/etc/config.xml:

<config>
    <modules>
        <Brian_Pricefix>
            <version>1.0</version>
        </Brian_Pricefix>
    </modules>
    <global>
        <blocks>
            <catalog>
                <rewrite>
                    <product>Brian_Pricefix_Catalog_Block_Product</product>
                </rewrite>
            </catalog>
        </blocks>
  </global>
</config>

My Brian_Pricefix.xml in app/etc/modules:

<config>
    <modules>
        <Brian_Pricefix>
            <active>true</active>
            <codePool>local</codePool>
        </Brian_Pricefix>
    </modules>
</config> 

My Product.php in app/code/local/Brian/Pricefix/Catalog/Block/Product.php

class Brian_Pricefix_Catalog_Block_Product extends Mage_Catalog_Block_Product
{
    public function getPriceHtml($product)
    {
        Mage::log("IM IN YOUR MODULEZ");
        $this->setTemplate('catalog/product/price_fix.phtml');
        $this->setProduct($product);
        return $this->toHtml();
    }

}

The new module isn't taking, its not logging anything or outputting price_fix.phtml

Any suggestions? I've done a few hours or research and this appears to be the right way to extend a block, so i'm not sure whats going on. The lack of error output is frustrating.

Thanks.

Upvotes: 1

Views: 4742

Answers (1)

Sergey
Sergey

Reputation: 1494

Looks like Mage_Catalog_Block_Product is not used anywhere.
catalog.xml contains mainly Mage_Catalog_Block_Product_View or Mage_Catalog_Block_Product_List calls. You config looks fine.
Try overriding another block. Can you precise the page you are testing on?

Upvotes: 4

Related Questions