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

  • in what page are you using this?
    – Marius
    Commented Jun 23, 2020 at 11:14
  • @Marius its a single product page. if you need more information about XML files i can update the question
    – Ilijanovic
    Commented Jun 23, 2020 at 11:22

1 Answer 1


This registry key will be filled only on the product detail page:

also, you may use


instead of


  • i have laready tried that without success sadly
    – Ilijanovic
    Commented Jun 23, 2020 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.