Magento 2 – How to Output Custom Text Attribute in Catalog list.phtml

attributesmagento2

I made a attribute set and custom text field attribute. Now I need the value of the attribute shown in list.phtml (catalog).

I tried without success:

Fail 1

<?php  echo $product->getAttributeText('catalog_description'); ?>

Fail 2

<?php echo $product->getAttributeText('catalog_description'); ?>

Fail 3

<?php $product->getAttributeText('catalog_description'); ?>

Fail 4

<?php echo $catalog_description; ?>

Best Answer

I found the solution, this works:

<?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getcatalog_description(), 'catalog_description'); ?>

In the Attribute setting in Magento 2 choose in Storefront properties YES for:

  • Visible on Catalog Pages on Storefront
  • Used in Product Listing
Related Topic