Toggle Nav
My Cart 0

magento 2 get attribute option label by attribute option ID

magento 2 get attribute option label by attribute option ID

Using below code you can get product attribute option label by option ID directly from the database.
$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
$resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection();
$tableName = $resource->getTableName('eav_attribute_option_value');

$option_id = 350;
$sql = "select * FROM " . $tableName . " where option_id=".$option_id;
$result = $connection->fetchAll($sql);

echo $option_label = $result[0]['value'];
August 10, 2019
Did you like this post?
0
0