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!

asked Jun 24, 2015 at 8:13

2 Answers 2

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>
answered Jun 24, 2015 at 8:17
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>
answered Jun 24, 2015 at 8:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.