Magento 1.8 – Replace Block in Layout for Specific Page

blocksce-1.8.1.0layoutmagento-1.8magento-ce

At the controller checkout_cart_index with the reference content, I want to replace this:

<block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>

With this:

<block type="multicoupon/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>

What happens is instead of replacing the block, it adds a new one. I've spent hours looking into this to no avail. Is there a way to do this with my own module using just the layout or will I have to write the change to a different file?

Best Answer

Because unsetChild isn't working in this case, I suggest the nuclear option:

<checkout_cart_index>
    <remove name="checkout.cart.coupon"></remove>
</checkout_cart_index>

This will remove the block entirely. Not such a big deal because you'll immediately re-create it:

<checkout_cart_index>
    <remove name="checkout.cart.coupon"></remove>
    <reference name="checkout.cart">
        <block type="multicoupon/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
    </reference>
</checkout_cart_index>
Related Topic