0

Sorry if this is a rehash, but I can't find the exact answer to my problem.

I'm looking to display the contents of a custom text field just under the product name on the category page grid.

I have done the following for another custom attribute in list.phtml, and this works:

<p><?php echo $_product->getAttributeText('plug_or_plant') ?></p>

But it only seems to work on attributes that are dropdown lists. Does anybody know what changes I have to make to get it to display a text field?

TIA.

1 Answer 1

2

change the below changes on the admin attribute

Go to the Stores -> ATTRIBUTES-> Product-> search attribute you want to show like descrption

open the attribute like Description go to the Storefront Properties and set "Used in Product Listing" No To Yes

then after saving the attribute Please check the attached Image enter image description here clear cache and reindex

3
  • Thanks for your answer. I have done all that already though. I read somewhere that using '$_product->getAttributeText' could be used for dropdowns, but it was something slightly different for text-fields, but I can't find what.
    – Andy
    Jan 5 at 8:46
  • please use below code for text-field <p><?php echo $_product->getData('plug_or_plant') ?></p> or <p><?php echo $_product->getPlugOrPlant() ?></p> Jan 5 at 10:25
  • Brilliant. That works. Thank you so much.
    – Andy
    Jan 5 at 10:54

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.