I would like to show the Brand attribute under the product name on the listing page. Attached is a screenshot for reference.
3 Answers
You would need to override the template file to a subtheme.
Info on how to do that here: How to create a Child Theme in Magento 2
Then you can change the text, by replacing it with
<?php echo $_product->getAttributeText('attribute_code'); ?>
Don't forget to set "used in product listing" to yes in the backend
1) First to display your attribute as you want in listing products, check first this config admin, Catalog > Attributes > Manage Attributes
. select your attribute brand
then check if Used in Product Listing
is set to 'yes' if no, change it to 'Yes' then save.
2) You need to reindexall
3) Go to app/design/frontend/{yourpackage}/{yourtheme}/template/catalog/product/list.phtml
under this class class="product-name"
you add this one for the attribute <h4><?php echo $_product->getBrand(); ?></h4>
.
4) Clear your cache and you get what you need.
First to display your attribute as you want in listing products, check first this config admin, Catalog > Attributes > Manage Attributes. select your attribute brand then check if Used in Product Listing is set to 'yes' if no, change it to 'Yes' then save.
You need to reindexall
Go to app/design/frontend/{yourpackage}/{yourtheme}/template/catalog/product/list.phtmlunder this class class="product-name" you add this one for the attribute getAttributeText('attribute_code'); ?>.
Clear your cache and you get what you need.