0
votes

I want to rewrite the Mage_Catalog_Block_Product_View block.

I created this file: config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <modules>
    <JB_CustomPrice>
      <version>0.1.0</version>
    </JB_CustomPrice>
  </modules>
  <global>

<blocks>
      <customprice>
        <class>JB_CustomPrice_Block</class>
      </customprice>
      <catalog>
        <rewrite>
          <product_view>JB_CustomPrice_Block_Catalog_Product_View</product_view>
        </rewrite>
      </catalog>
</blocks>
</config>

Then I created the block in /app/code/local/JB/CustomPrice/Block/Catalog/Product/View.php

<?php
class JB_CustomPrice_Block_Catalog_Product_View extends Mage_Catalog_Block_Product_View
{
   public function getJsonConfig()
   {
      return 'test';
   }
}
?>

Though, the product view doesn't change, even not when I call the getProduct() method. What's going wrong?

1
You're rewrite looks fine. Is your module active? - check if you see it in System -> Configuration -> Advanced -> Disable module output Is there any other module that extends the same block? - you can enable template path hints & block names hints from System -> Configuration -> Developer -> Debug (or put a Mage::log(get_class($this)) in product 's view.phtml template)Bogdan Constantinescu
Also as I see you don't have a closing tag for global node.Bogdan Constantinescu
The global error was a typo, thanks for the Mage::log(get_class($this)), that fixed it. The problem was that another plugin extended Mage_Catalog_Block_Product_View already. It was an old Yoast_MetaRobots plugin, which is deprecated. I disabled it and everything was fixed. Thanks for the answer!J.2

1 Answers

0
votes

The global error was a typo, solved by using Mage::log(get_class($this)), that fixed it. The problem was that another plugin extended Mage_Catalog_Block_Product_View already. It was an old Yoast_MetaRobots plugin, which is deprecated. I disabled it and everything was fixed. Thanks for the answer!