- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys,
i created an attribute at magento backend and i want display the value of that attribute in product details page . how can i acheive it ?
can anyone help me ?
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yah i got, we can use below code to get label and value
for label :<?php echo $_product->getResource()->getAttribute('dem')->getStoreLabel(); ?>
for value : <?php echo $_product->getResource()->getAttribute('dem')->getFrontend()->getValue($_product); ?>
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: how to display admin attribute in magento 2 frontend product details page ?
You can get attribute value in product page using below way,
Let's assume you have created attribute name like product_custom_attribute and if you want to get that attribute in detail page,
You need to use get method of the attribute using product object,
echo $_product->getProductCustomAttribute()
You got a $_product object in the product page and get that attribute using above way.
Edit:
for Label of attribute :<?php echo $_product->getResource()->getAttribute('dem')->getStoreLabel(); ?>
for Value of attribute : <?php echo $_product->getResource()->getAttribute('dem')->getFrontend()->getValue($_product); ?>
Magento 2 Blogs/Tutorial
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yah i got, we can use below code to get label and value
for label :<?php echo $_product->getResource()->getAttribute('dem')->getStoreLabel(); ?>
for value : <?php echo $_product->getResource()->getAttribute('dem')->getFrontend()->getValue($_product); ?>