0

I want to override this class : 'Magento\Checkout\Block\Cart\Item\Renderer' This class has a child like : 'Magento\ConfigurableProduct\Block\Cart\Item\Renderer'

So i use <preference for="Magento\Checkout\Block\Cart\Item\Renderer" type="Custom\Checkout\Block\Cart\Item\Renderer" />

It's works only when i use the parent class ( Cart\Item\Renderer ). but when i instantiate the child i can't use my custom function. Is there something else to do ? I have to override all the child class ?

1 Answer 1

0

You need to customize the block using layout XML. In this case check how the Bundle module defines a custom renderer for bundle-type products:

https://github.com/magento/magento2/blob/2.4/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_item_renderers.xml.

You would need to do the same, i.e. define a custom block class that extends \Magento\Checkout\Block\Cart\Item\Renderer - as per this:

https://github.com/magento/magento2/blob/2.4/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.