In Magento 2.1 CE, luma theme, I'm trying to add a product attribute called "RRP" (Recommended Retail Price) and like to display it on the frontend product page and in catalog near the other prices. (Existing MSRP function isn't appropriate because i don't use MAP.)
I've added an price-attribute called "RRP" in backend, and there it's visible. In frontend, it's shown in "more information"-tab, but i like to show it near the other prices.
I've tried to call it in "vendor\magento\module-catalog\view\frontend\templates\product\list.phtml" with following code:
<?php echo $_product->getRrp(); ?>
but it's not visible.
Is this the right file and the right code to call the attribute? Or do i have to add something other to call the attribute in frontend?
But price is shown with 4 decimals, for example 10.0000 instead 10.00, and without currency symbol.
code i've used to show the attribute value:
<?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getRrp(), 'rrp') ?>
to show attribute label also, i've tried following code, but this doesn't work:
<?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getRrp(), 'rrp'); $_product->getResource()->getAttribute('rrp')->getStoreLabel() ?>
How i could add global currency format to the attribute? And how i could add the attribute label?
2 Answers 2
To Show Custom Attribute in product list page you can used following code,
<?php echo $_helper->productAttribute($_product, $_product->getRrp(), 'rrp') ?>
Note : Make sure attribute option is visible for product listing page from admin.
- 
 Thanks a lot for your help! Do you know how to add global price format to the attribute also?Steff– Steff2017年02月10日 16:01:16 +00:00Commented Feb 10, 2017 at 16:01
- 
 If above answer help you, please accept. So it will help other in community. And if you required further help you can ask new question.Dhiren Vasoya– Dhiren Vasoya2017年02月10日 16:26:41 +00:00Commented Feb 10, 2017 at 16:26
You have to allow this attribute in attribute setting "Show in product list page" to "yes" in attribute setting.
Explore related questions
See similar questions with these tags.