Magento 2 – Get Dropdown Value in Product Page

magento2product-page

I want one dropdown value in Product view page in Magento 2. For e.g, if I have select custom dropdown value in the product from the admin section. Now I want this value in view page as an option to display.

$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
$productRepository = $objectManager->get('\Magento\Catalog\Model\Product\Attribute\Repository');

$sizes = $productRepository->get('supply')->getOptions();
foreach ($sizes as $sizesOption) {
    if ($sizesOption->getValue() == '8') {
        echo    $sizesOption->getValue();
  echo  $sizesOption->getLabel();
}

}

But currently, they displayed all value in all product, not particular product value as per assing into products. I want this value filter by current product.

Best Answer

Try following way to getting a selected dropdown text for product:

<?= $_product->getAttributeText("country_of_manufacture") ?>