Cannot Override Item Renderer in Magento Checkout Sidebar – Solution

blockscheckoutoverridesrenderersidebar

I can successfully override other blocks but I couldn't extend Mage_Checkout_Block_Cart_Item_Renderer.

<?xml version="1.0"?>
<config>
    <modules>
        <Test_Checkout>
            <version>0.0.1</version>
        </Test_Checkout>
    </modules>
    <global>
        <blocks>
            <test_checkout>
                <class>Test_Checkout_Block</class>
            </test_checkout>
            <checkout>
                <rewrite>
                    <cart_item_renderer>Test_Checkout_Block_Cart_Item_Renderer</cart_item_renderer>
                </rewrite>
            </checkout>
        </blocks>
        <helpers>
            <test_checkout>
                <class>Test_Checkout_Helper</class>
            </test_checkout>
        </helpers>
    </global>
</config>

And here's my block file Renderer.php inside Test/Checkout/Block/Cart/Item inside local folder:

class Test_Checkout_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_Item_Renderer
{}

But it's not picking up the functions inside my custom block.

Any ideas?

Best Answer

Upon thorough investigation, I found out that another custom module is already overriding the block. So what I did is to override the same block then extend the other module who extends it:

    <checkout>
      <rewrite>
        <cart_item_renderer>Test_Checkout_Block_Cart_Item_Renderer</cart_item_renderer>
      </rewrite>
    </checkout>

On my Renderer.php:

class Test_Checkout_Block_Cart_Item_Renderer extends Third_Party_Block_Rewrite_Checkout_Cart_Item_Renderer{

}

Then on my Test_Checkout.xml in modules folder:

<?xml version="1.0"?>
<config>
     <modules>
        <Test_Checkout>
               <active>true</active>
               <codePool>local</codePool>
               <depends>
                    <Third_Party/>
               </depends>
        </Test_Checkout>
     </modules>
</config>

As always, these "third parties" are pain in the </3 ...

Related Topic