I am using magento 2.3
I want to display product attribute on product page, I select the storefront properties tab and change the value of Visible on Catalog Pages on Storefront drop down value No to Yes. but custom product attribute is not showing.
please see attached screenshot. same I want to display.
Best Answer
In order to do add your custom attributes to the product detail page, you must:
Note the attribute code of your custom attribute.
Once that is complete, if not already setup, you must set up a custom theme:
Create theme: https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/themes/theme-create.html
Once your theme is created, applied and configured, add the following folder to your custom theme:
Create the following file:
Examine the following file:
Determine which container you would like to display your custom attribute within and note the name of the container. We will use the name of the container in order to reference the container in the catalog_product_view.xml file.
i.e.
<referenceContainer name="content">
or<referenceContainer name="product.info.main">
or<referenceContainer name="add-container-name-here">
Place this code within catalog_product_view.xml, replacing {attributeCode} with your custom attribute code:
Flush cache & deploy static resources (you may also need to run indexer).
This will display the attribute using the default Magento 2 attribute template.
If you would like to use a custom template to display your custom attribute, use this code within the catalog_product_view.xml file:
Add the following folder to your custom theme:
Create the following file:
Add the following code to custom.phtml, replace {attributeCode} with your custom attribute code:
Adjust the HTML code, as needed.
Flush cache & deploy static resources (you may also need to run indexer).