Skip to content

Commit 6f18e4f

Browse files
committed
MC-3103: Custom Product Attributes with FullWidth Page Layout
- Change attributes block to use constants to determine attribute visibility - Rename title wrapper and attributes to better illustrate their purpose
1 parent 879221e commit 6f18e4f

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99

1010
class Attributes extends \Magento\Catalog\Block\Product\View\Attributes
1111
{
12+
const DISPLAY_ATTRIBUTES_NON_PAGEBUILDER = 'non_pagebuilder';
13+
14+
const DISPLAY_ATTRIBUTES_PAGEBUILDER_ONLY = 'pagebuilder_only';
15+
1216
/**
1317
* Determine if we should display the attribute on the front-end, add support for exclude page builder & page
1418
* builder only options on class.
1519
*
16-
* pagebuilder_attributes can be set to determine whether to include just Page Builder attributes or to exclude
20+
* display_attributes can be set to determine whether to include just Page Builder attributes or to exclude
1721
* them.
1822
*
1923
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
@@ -24,9 +28,11 @@ class Attributes extends \Magento\Catalog\Block\Product\View\Attributes
2428
protected function isVisibleOnFrontend(
2529
\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute,
2630
array $excludeAttr
27-
) {
31+
) : bool {
2832
return parent::isVisibleOnFrontend($attribute, $excludeAttr)
29-
&& (($this->getPagebuilderAttributes() && $attribute->getIsPagebuilderEnabled())
30-
|| (!$this->getPagebuilderAttributes() && !$attribute->getIsPagebuilderEnabled()));
33+
&& (($this->getDisplayAttributes() == self::DISPLAY_ATTRIBUTES_NON_PAGEBUILDER
34+
&& !$attribute->getIsPagebuilderEnabled())
35+
|| ($this->getDisplayAttributes() == self::DISPLAY_ATTRIBUTES_PAGEBUILDER_ONLY
36+
&& $attribute->getIsPagebuilderEnabled()));
3137
}
3238
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@
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/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/attribute_list.phtml">
2828
<arguments>
29-
<argument name="pagebuilder_attributes" xsi:type="boolean">true</argument>
29+
<argument name="display_attributes" xsi:type="string">pagebuilder_only</argument>
3030
</arguments>
3131
</block>
3232
</container>
3333
<!-- Create new product details wrapper under main.content for tabs section -->
3434
<container name="product.info.details.after.wrapper" after="product.attributes.pagebuilder.wrapper" before="product.info.details.wrapper" htmlTag="div" htmlClass="page-main page-main-details">
3535
<container name="product.info.details.after.wrapper.columns" htmlTag="div" htmlClass="columns">
3636
<container name="product.info.details.after.wrapper.main" label="Product Details Main Content Container" htmlTag="div" htmlClass="column main">
37-
<block class="Magento\Framework\View\Element\Template" name="product.attributes.wrapper" template="Magento_PageBuilder::catalog/product/view/title_wrapper.phtml">
37+
<block class="Magento\Framework\View\Element\Template" name="product.attributes.wrapper" template="Magento_PageBuilder::catalog/product/view/section_wrapper.html">
3838
<arguments>
3939
<argument name="title" translate="true" xsi:type="string">More Information</argument>
4040
</arguments>
4141
<!-- Create a new instance of attributes which excludes Page Builder attributes -->
42-
<block class="Magento\PageBuilder\Block\Catalog\Block\Product\View\Attributes" name="product.attributes.exclude.pagebuilder" as="additional" template="Magento_Catalog::product/view/attributes.phtml">
42+
<block class="Magento\PageBuilder\Block\Catalog\Block\Product\View\Attributes" name="product.attributes.exclude.pagebuilder" as="additional" template="Magento_Catalog::product/view/attribute_list.phtml">
4343
<arguments>
44-
<argument name="pagebuilder_attributes" xsi:type="boolean">false</argument>
44+
<argument name="display_attributes" xsi:type="string">non_pagebuilder</argument>
4545
</arguments>
4646
</block>
4747
</block>
48-
<block class="Magento\Framework\View\Element\Template" name="product.reviews.wrapper" after="product.attributes.wrapper" template="Magento_PageBuilder::catalog/product/view/title_wrapper.phtml">
48+
<block class="Magento\Framework\View\Element\Template" name="product.reviews.wrapper" after="product.attributes.wrapper" template="Magento_PageBuilder::catalog/product/view/section_wrapper.html">
4949
<arguments>
5050
<argument name="title" translate="true" xsi:type="string">Reviews</argument>
5151
</arguments>

0 commit comments

Comments
 (0)