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(
$typeInstance->getOptionsIds($product),
$product
);
$this->options = $optionCollection->appendSelections(
$selectionCollection,
false,
$this->catalogProduct->getSkipSaleableCheck()
);
}
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?
Magento\Bundle\Model\Product\Type.php