0

I use Magento 2.3.4 EE and when I try to add a custom attribute to the product page - I can’t do it.

Mi file:

app/design/vendor/theme/Magento_Catalog/layout/catalog_product_view.xml

My code:

<referenceBlock name="product.info.details">
    <block class="Magento\Catalog\Block\Product\View\Attributes" name="product.info.custom" as="custom" template="Magento_Catalog::product/view/attribute.phtml" group="detailed_info">
        <arguments>
            <argument name="at_call" xsi:type="string">getCustom</argument>
            <argument name="at_code" xsi:type="string">custom</argument>
            <argument name="title" translate="true" xsi:type="string">Custom Attribute</argument>
            <argument name="sort_order" xsi:type="string">15</argument>
        </arguments>
    </block>
</referenceBlock>

And i try too:

<referenceBlock name="product.info.details">
    <block class="Magento\Catalog\Block\Product\View\Description" name="product.info.custom" as="custom" template="Magento_Catalog::product/view/attribute.phtml" group="detailed_info">
        <arguments>
            <argument name="at_call" xsi:type="string">getCustom</argument>
            <argument name="at_code" xsi:type="string">custom</argument>
            <argument name="title" translate="true" xsi:type="string">Custom Attribute</argument>
            <argument name="sort_order" xsi:type="string">15</argument>
        </arguments>
    </block>
3

There is not any problem with the code. you need to check the custom attribute configuration for that.

Please check below configuration for your custom attribute.

you need to enable output for frontend (Visible on Catalog Pages on Storefront).

to do it you need to go to M2 Admin > Store > attribute > Product > edit your attribute.

open tab store front properties and make (Visible on Catalog Pages on Storefront) to yes.

Then it will work for you.

enter image description here

hope this will resolve your issue.

Note: Please make it right and add plus to this solution if this solution work for you.

Thank you.

1
  • Yes, it's works) Thanks) Apr 19 '20 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.