My phtml file is extended with this class:
class Select extends \Magento\Catalog\Block\Product\View\Options\AbstractOptions
{
protected $_escaper;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Pricing\Helper\Data $pricingHelper,
\Magento\Framework\Registry $registry,
\Magento\Catalog\Helper\Data $catalogData
) {
$this->registry = $registry;
parent::__construct($context, $pricingHelper, $catalogData);
}
private function getCurrentProduct()
{
if (is_null($this->product)) {
$this->product = $this->registry->registry('product');
if (!$this->product->getId()) {
throw new LocalizedException(__('Failed to initialize product'));
}
}
return $this->product;
}
When i call my function $this->getCurrentProduct()
i get nothing, what i am doing wrong here. Its a product page