cancel
Showing results for 
Search instead for 
Did you mean: 

how to display admin attribute in magento 2 frontend product details page ?

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

how to display admin attribute in magento 2 frontend product details page ?

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: how to display admin attribute in magento 2 frontend product details page ?

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);  ?>

View solution in original post

2 REPLIES 2

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);  ?>

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: how to display admin attribute in magento 2 frontend product details page ?

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);  ?>