i have created one product custom attribute name -> 'is-buynowbutton-show' and i want to get that attribute value in product list page to show buy now based on product setting.

Does anyone suggest me how i can get product custom attributes value in product list page?


2 Answers 2


First open attribute on admin

Store -> Attributes -> Products

Then open your desired attribute is-buynowbutton-show, open tab Storefront Properties

In this tab you will find option "Used in Product Listing" make sure it is set to Yes

Now in your list phtml file you can use attribute like this


Note: A piece of advice, do not use dash (-) always use underscore (_) in attribute code. so that you can be able to use it like this $_product->getIsBuynowbuttonShow();


In product list page you will get the foreach loop with product colection. Each product of this loop is product object as $_product.

The you will get this value of this product custom attribute as $_product->getData('is-buynowbutton-show')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.