I'm trying to extend a function getOption() of Bundle Class(Magento\Bundle\Block\Catalog\Product\View\Type\Bundle.php) in my own Class using following code

protected $_ProductBundle;

public function __construct(
\Magento\Backend\Block\Template\Context $context,
array $data = [],
\Magento\Bundle\Block\Catalog\Product\View\Type\Bundle $ProductBundle,
        $this->_ProductBundle = $ProductBundle;
        parent::__construct($context, $data);

and then I declared this getOptions function in the same class

public function getOptions()
        return $this->_ProductBundle->getOptions();

I'm getting following error when I call above function from my phtml file

Fatal error: Call to undefined method Magento\ConfigurableProduct\Model\Product\Type\Configurable\Interceptor::getOptionsCollection() in C:\xampp\htdocs\Magento21\app\code\Vendor_Name\Catalog\Block\Product\ProductBundleNew.php on line 82

Above function getOptionsCollection() is coming from getOptions function from Bundle.php

public function getOptions()
        if (!$this->options) {
            $product = $this->getProduct();
            $typeInstance = $product->getTypeInstance();
            $typeInstance->setStoreFilter($product->getStoreId(), $product);

            $optionCollection = $typeInstance->getOptionsCollection($product);

            $selectionCollection = $typeInstance->getSelectionsCollection(

            $this->options = $optionCollection->appendSelections(

        return $this->options;

I'm not able to get the definition of getOptionsCollection. Is this function declared somewhere else? do I have to extend some other class to call this function?

  • after searching through Magento modules, getOptionsCollection function comes from Type.php Magento\Bundle\Model\Product\Type.php – Nausif Oct 3 '16 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.