Table of Content

In Magento 2.3.1 the product.info.details block has changed its class from Magento\Catalog\Block\Product\View\Description to Magento\Catalog\Block\Product\View\Details.

Magento 2.3.0
magento/magento2/blob/2.3.0/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml#L139-L139


Magento 2.3.1
magento/magento2/blob/2.3.1/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml#L139-L139

The Magento\Catalog\Block\Product\View\Description class has the getProduct() method:
magento/magento2/blob/2.3.0/app/code/Magento/Catalog/Block/Product/View/Description.php#L48-L57
/**
* @return Product
*/
public function getProduct()
{
if (!$this->_product) {
$this->_product = $this->_coreRegistry->registry(‘product’);
}
return $this->_product;
}
The Magento\Catalog\Block\Product\View\Details class does not have such method.
So any third-party design theme which calls the getProduct() method in the product.info.details block’s template will fail.

How to fix
In the Smartwave Porto’s case you need to patch the file app/design/frontend/Smartwave/porto_child/Magento_Catalog/templates/product/view/details.phtml

Step 1
Replace the 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.

Last modified: 05.06.2019

Author

Comments

Write a Reply or Comment

Your email address will not be published.