Skip to content

Commit 879221e

Browse files
committed
MC-3103: Custom Product Attributes with FullWidth Page Layout
- Update shouldDisplay to use new function name - Rename template to be more descriptive - Remove use of underscore variables to portray scope
1 parent 31da63b commit 879221e

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ class Attributes extends \Magento\Catalog\Block\Product\View\Attributes
1313
* Determine if we should display the attribute on the front-end, add support for exclude page builder & page
1414
* builder only options on class.
1515
*
16+
* pagebuilder_attributes can be set to determine whether to include just Page Builder attributes or to exclude
17+
* them.
18+
*
1619
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
1720
* @param array $excludeAttr
1821
* @return bool
1922
* @throws \Magento\Framework\Exception\LocalizedException
2023
*/
21-
protected function shouldDisplay(
24+
protected function isVisibleOnFrontend(
2225
\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute,
2326
array $excludeAttr
2427
) {
25-
return parent::shouldDisplay($attribute, $excludeAttr)
26-
&& (($this->getExcludePagebuilder() && !$attribute->getIsPagebuilderEnabled())
27-
|| ($this->getPagebuilderOnly() && $attribute->getIsPagebuilderEnabled()));
28+
return parent::isVisibleOnFrontend($attribute, $excludeAttr)
29+
&& (($this->getPagebuilderAttributes() && $attribute->getIsPagebuilderEnabled())
30+
|| (!$this->getPagebuilderAttributes() && !$attribute->getIsPagebuilderEnabled()));
2831
}
2932
}

app/code/Magento/PageBuilder/view/frontend/page_layout/product-full-width.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<container name="product.info.description.wrapper" after="main.content" before="product.info.details.after.wrapper" htmlTag="div" htmlClass="page-main-description product-full-width-section" htmlId="description"/>
2525
<!-- Create a new wrapper to house the custom Page Builder attributes -->
2626
<container name="product.attributes.pagebuilder.wrapper" after="product.info.description.wrapper" before="product.info.details.after.wrapper" htmlTag="div" htmlClass="page-main-pagebuilder-attributes">
27-
<block class="Magento\PageBuilder\Block\Catalog\Block\Product\View\Attributes" name="product.attributes.only.pagebuilder" as="additional.pagebuilder" template="Magento_PageBuilder::catalog/product/view/title_attributes.phtml">
27+
<block class="Magento\PageBuilder\Block\Catalog\Block\Product\View\Attributes" name="product.attributes.only.pagebuilder" as="additional.pagebuilder" template="Magento_PageBuilder::catalog/product/view/attributes.phtml">
2828
<arguments>
29-
<argument name="pagebuilder_only" xsi:type="boolean">true</argument>
29+
<argument name="pagebuilder_attributes" xsi:type="boolean">true</argument>
3030
</arguments>
3131
</block>
3232
</container>
@@ -41,7 +41,7 @@
4141
<!-- Create a new instance of attributes which excludes Page Builder attributes -->
4242
<block class="Magento\PageBuilder\Block\Catalog\Block\Product\View\Attributes" name="product.attributes.exclude.pagebuilder" as="additional" template="Magento_Catalog::product/view/attributes.phtml">
4343
<arguments>
44-
<argument name="exclude_pagebuilder" xsi:type="boolean">true</argument>
44+
<argument name="pagebuilder_attributes" xsi:type="boolean">false</argument>
4545
</arguments>
4646
</block>
4747
</block>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
$helper = $this->helper(Magento\Catalog\Helper\Output::class);
1515
$product = $block->getProduct();
1616
?>
17-
<?php if ($_additional = $block->getAdditionalData()) : ?>
17+
<?php if ($additional = $block->getAdditionalData()) : ?>
1818
<div class="pagebuilder-attributes-wrapper">
19-
<?php foreach ($_additional as $_data) : ?>
19+
<?php foreach ($additional as $data) : ?>
2020
<div class="product-full-width-section">
2121
<div class="page-main">
22-
<h2 class="product-section-title"><?= $block->escapeHtml(__($_data['label'])) ?></h2>
22+
<h2 class="product-section-title"><?= $block->escapeHtml(__($data['label'])) ?></h2>
2323
</div>
2424
<div class="pagebuilder-attribute-wrapper">
25-
<?= /* @escapeNotVerified */ $helper->productAttribute($product, $_data['value'], $_data['code']) ?>
25+
<?= /* @noEscape */ $helper->productAttribute($product, $data['value'], $data['code']) ?>
2626
</div>
2727
</div>
2828
<?php endforeach; ?>

0 commit comments

Comments
 (0)