سؤال

I need to display a custom date attribute in product view and product listing. Currently, I am using the following code:

$_product->getResource()->getAttribute('my_date')->getFrontend()->getValue($_product);

For the product view this code works fine, but in product listing it does not.

The attribute option 'Used in Product Listing' is set to 'yes', but this does not help.

Any suggestions?

هل كانت مفيدة؟

المحلول 2

I found the solution. I had to change the attributes scope from 'website' to 'store view' to got it working.

نصائح أخرى

you can easily get attribute value in listing page .

but remember The attribute option 'Used in Product Listing' is set to 'yes' and try to run reindex it will solve your problem

just write

echo  $_product->getData('my_date')
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top