In Magento 1.x I could show the Admin value of an Attribute like this:
_product->getAdminAttributeText('bleach')
But it doesn't work in Magento 2. How can I show the Admin value of a dropdown list in Magento 2?
Easy way to do this (maybe not the cleanest):
$product->getResource()->getAttribute('attribute_code')->setStoreId(0)->getFrontend()->getValue($product);
Create object and load the product using id.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_product = $objectManager->get('Magento\Catalog\Mode\Product')->load($product_id);
Get the value using option id.
$optionId = 10;
$attr = $_product->getResource()->getAttribute('color');
if ($attr->usesSource()) {
$optionText = $attr->getSource()->getOptionText($optionId);
}
To get the admin value of an attribute, try this :
$attribute = $product->getResource()->getAttribute('YOUR_ATTRIBUTE_NAME');
$adminValue = $attribute
->setStoreId(0) // Admin store ID
->getSource()->getOptionText($product->getData('YOUR_ATTRIBUTE_NAME'));