Skip to content

Commit 584cd4a

Browse files
committed
MC-15322: Fatal error when selecting Product CMS page design
Cast null $product to DataObject
1 parent 888fa8f commit 584cd4a

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

app/code/Magento/PageBuilder/Block/Catalog/Block/Product/View/Attributes.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,29 @@
77

88
namespace Magento\PageBuilder\Block\Catalog\Block\Product\View;
99

10+
use Magento\Framework\DataObject;
11+
1012
class Attributes extends \Magento\Catalog\Block\Product\View\Attributes
1113
{
1214
const DISPLAY_ATTRIBUTES_NON_PAGEBUILDER = 'non_pagebuilder';
1315

1416
const DISPLAY_ATTRIBUTES_PAGEBUILDER_ONLY = 'pagebuilder_only';
1517

18+
/**
19+
* @inheritdoc
20+
*/
21+
public function getProduct()
22+
{
23+
$product = parent::getProduct();
24+
25+
if (!$product) {
26+
$product = new DataObject();
27+
$product->setAttributes([]);
28+
}
29+
30+
return $product;
31+
}
32+
1633
/**
1734
* Determine if we should display the attribute on the front-end, add support for exclude page builder & page
1835
* builder only options on class.

app/code/Magento/PageBuilder/view/frontend/templates/catalog/product/view/attribute_list.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$helper = $this->helper(Magento\Catalog\Helper\Output::class);
1515
$product = $block->getProduct();
1616
?>
17-
<?php if ($product && ($additional = $block->getAdditionalData())) : ?>
17+
<?php if ($additional = $block->getAdditionalData()) : ?>
1818
<div class="pagebuilder-attributes-wrapper">
1919
<?php foreach ($additional as $data) : ?>
2020
<div class="product-full-width-section">

app/code/Magento/PageBuilder/view/frontend/templates/catalog/product/view/section_wrapper.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @var \Magento\Framework\View\Element\Template $block
1111
*/
12-
$childHtml = $block->getProduct() ? $block->getChildHtml() : '';
12+
$childHtml = $block->getChildHtml();
1313
?>
1414
<?php if (trim($childHtml) !== "") : ?>
1515
<div class="product-full-width-section">

0 commit comments

Comments
 (0)