4

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
Shorabh
  • 1,508
  • 12
  • 18
Divya
  • 41
  • 1
  • 1
  • 2

3 Answers3

9

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

app/design/frontend/Smartwave/porto_child/Magento_Catalog/templates/product/view/details.phtml

Step 1 : Replace this line:

$_product = $block->getProduct();

with the following code block:

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

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

Getting Reference

Magento_Bhurio
  • 940
  • 5
  • 14
Shorabh
  • 1,508
  • 12
  • 18
3

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

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');
Vincent Teyssier
  • 266
  • 1
  • 14