Question

I have my custom "sidebar_brand.phtml" in "catalog_product_view.xml".

<container name="right.product.container" as="rightProductContainer" label="Right Product Container" htmlTag="div" htmlClass="col-md-3 text-sm-center" >
    <block class="Magento\Catalog\Block\Product\View\Attributes" name="product.info.sidebarbrands" template="Magento_Catalog::product/view/sidebar-brand.phtml" after="product.info.main"/>
</container>

I have tried many different ways but I can not find out how to display the manufacturer attribute in this file.

Should I do it from the XML file or the phtml file?

I have seen different solutions, but nothing works. I am using Magento 2.2.3, how do I get the '$_product->getAttributeText('manufacturer');' working?

Sources: https://www.dckap.com/blog/display-custom-attribute-value-product-viewlist-page-magento-2/

https://stackoverflow.com/questions/37305107/how-do-i-display-an-attribute-on-product-view-page-in-magento-2

I am failing all the time! Can someone please show me how it should be in my Magento version?

The phtml file sidebar_brand.phtml works fine, but I am not able to show the product attribute.

Thank you in advance.

Was it helpful?

Solution

Your layout changes seem to fine ( and expecting .phtml changes fine too ) then only possible issue could be enabling storefrontend settings to view on catalog pages.

you need to check attribute front-end setting :

Stores->Attributes->Product

and find your manufacturer attribute ( click to edit ) and go to "Storefront Properties" ( as attached ) there you should change Visible on Catalog Pages on Storefront to Yes

enter image description here

hopefully it will work.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top