Cannot use __construct in bundle checkbox class

I want to add the product image to bundle product page for each option. I chose to extend class \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option\Checkbox

This class has no __construct method, but I have to use it because I want to use \Magento\Catalog\Helper\Image. When I define a construct method, the page crashes and throws an error Call to a member function dispatch() on null

If I call parent::__construct, I receive a type error indicating the __construct methods do not match.

I have read that if the parent class does not have a __construct class, that I do not have to call parent, but in my case I cannot get this simple modification to work.

class Checkbox extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option\Checkbox {

public function __construct(
    \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
    \Magento\Catalog\Helper\Image $imageHelper
    $this->_stockRegistry = $stockRegistry;
    $this->_imageHelper = $imageHelper;


The problem is that when you extend a class that extends from another class and has no __construct method, you must use the __construct of the parent which in this case is \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option

This fixed my issue.

Tags: Magento 2.x

Similar questions

Magento 2 Bundle product option Type Checkbox quantity user defined Quaqntity
Is there any way to set/show quantity box on Bundle product Option type Checkbox like Radio Button?
Magento Checkbox for bundle products needs qty
With a bundled product in magento you can select various types of options - drop down for example adds a Qty box so you may choose the quantity of items from the drop down. I am using Checkboxes instead as i need many choices and need a Qty box associated - how is this possible? I've spent hours trying to code this.
Magento bundle product Quantity box for checkbox
I have created one bundle product containing many bundle items. SO I am adding that bundle items to cart using check box. But how to add quantity box for bundle items using check box to select. So that, I can add many items for that checked bundle item ?
system.log errors - Warning: SimpleXMLElement::__construct()
My system.log file is filling up with the following error message: I've been trawling through xml files trying to find anything that might be calling feed.php but have had no luck. Can anyone offer any advice? I'm running Magento
What is __construct and _construct in magento2?
In Magento 2, most of classes have these two constructs (__construct and _construct) methods. What is the difference between them?
Recoverable Error: Argument 1 passed to Magento\Framework\Data\Form::__construct() must be an instance of Magento\Framework\Data\Form\Element\Factory
I am developing a custom module for Magento 2. Right now I have an error. When I run the Place Order in checkout page, it is supposed to redirect me to a page where it says "You will be redirected to somewhere" for 5 seconds, and then redirect to the "somewhere". But, I am getting this error in var/report Recoverable Error: Argument 1 passed to Mag...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.