1

I have few core files modifications in my app/code/local/Mage folder, but I wan't to make them work as magento module.

My example: I did few small modifications in method getValueHtml in file Mage/Bundle/Block/Sales/Order/Items/Renderer.php and now I wan't this rewritten method to be used.

I have followed online tutorials for blocks rewrite but it is not working for me. I'm missing something, but I can't figure it out. These are my module files:

app/code/local/MyCompany/Bundleproducts/etc/config.xml:

<?xml version="1.0"?>
<config>
 <modules>
    <MyCompany_Bundleproducts>
        <version>1.0.0</version>
    </MyCompany_Bundleproducts>
 </modules>
 <global>
  <blocks>
      <bundle>
         <rewrite>
              <sales_order>MyCompany_Bundleproducts_Block_Sales_Order_Items_Renderer</sales_order>
          </rewrite>
      </bundle>
  </blocks>
 </global>
</config>

app/code/local/MyCompany/Bundleproducts/Block/Sales/Order/Items/Renderer.php:

<?php
class MyCompany_Bundleproducts_Block_Sales_Order_Items_Renderer extends Mage_Bundle_Block_Sales_Order_Items_Renderer
{
    public function getValueHtml($item)
    {
        if ($attributes = $this->getSelectionAttributes($item)) {
            return sprintf('%d', $attributes['qty']) . ' TEST ' .
                $this->escapeHtml($item->getName());
        } else {
            return $this->escapeHtml($item->getName());
        }
    }
}

and app/etc/modules/MyCompany_Bundleproducts.xml

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

Can someone point me to the right direction? Thanks!

3

your block rewrite should be like this

<blocks>
      <bundle>
         <rewrite>
              <sales_order_items_renderer>MyCompany_Bundleproducts_Block_Sales_Order_Items_Renderer</sales_order_items_renderer>
          </rewrite>
      </bundle>
  </blocks>
3

You need to include the complete path to the core block while overriding. This is the config.xml code

<?xml version="1.0"?>
<config>
 <modules>
    <MyCompany_Bundleproducts>
        <version>1.0.0</version>
    </MyCompany_Bundleproducts>
 </modules>
 <global>
  <blocks>
      <bundle>
         <rewrite>
              <sales_order_items_renderer>MyCompany_Bundleproducts_Block_Sales_Order_Items_Renderer</sales_order_items_renderer>
          </rewrite>
      </bundle>
  </blocks>
 </global>
</config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.