we are using Magento 2.3.1 and Porto theme

when I click on product its showing below mentioned error - https://offineeds.co.in/4-in-1-touch-led-lamp.html

Fatal error: Uncaught Error: Call to a member function getData() on null in / home/offinee8/public_html/app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/view/details.phtml:18
 Stack trace: 
 #0 /home/offinee8/public_html/vendor/magento/framework/View/TemplateEngine/Php.php(59): include() 
 #1 /home/offinee8/public_html/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Catalog\Block\Product\View\Details), '/home/offinee8/...', Array) 
 #2 /home/offinee8/public_html/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template->fetchView('/home/offinee8/...') 
 #3 /home/offinee8/public_html/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template->_toHtml() 
 #4 /home/offinee8/public_html/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Element\AbstractBlock->toHtml() 
 #5 /home/offinee8/public_html/vendor/magento/framework/View/Layout.php(533): M in /home/offinee8/public_html/app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/view/details.phtml on line 18

3 Answers 3


fix this issue using below steps :- In the Smartwave Porto’s Theme case you need to patch the file


Step 1 : Replace this line:

$_product = $block->getProduct();

with the following code block:

$_product = \Magento\Framework\App\ObjectManager::getInstance()

Step 2 : Then replace each $block->getProduct() expression with $_product.

Getting Reference

  • Thank you so much
    – Divya
    Jun 27, 2019 at 7:28
  • Works like a charm ! Thank you
    – sebb
    Jul 17, 2019 at 23:17

This issue has been addressed here: https://github.com/magento/magento2/issues/22036

Until it's fixed in the release, you should apply the patch found here to your core Magento installation: https://github.com/magento/magento2/pull/22034/files

Don't use ObjectManager. For a discussion about why, see: Magento 2: to use or not to use the ObjectManager directly?

  • 2
    This is the way. Don't use ObjectManager folks.
    – User007
    Jan 9, 2020 at 0:46

Porto has a patch for that. Download latest version of porto theme and apply the 2.3.1 patch.

It basically replaces getProduct() line with:

$_product = \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Framework\Registry::class)->registry('product');

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.