Magento2 : How to get the attributes values for products list page?
-
14-02-2021 - |
Soluzione
<?php
$attribute = $product->getResource()->getAttribute('package_quantity');
if (empty($attribute->getFrontend()->getValue($product))) {
}else{
echo "<strong>Package Quantity : </strong>",$attribute->getFrontend()->getValue($product);
}
?>
Altri suggerimenti
You can get the attribute value and attribute code as :
Attribute Value :
<?php echo $_product->getResource()->getAttribute('attribute_code')->getFrontend()->getValue($_product); ?>
Attribute Label :
<?php echo $_product->getResource()->getAttribute('attribute_code')->getStoreLabel();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange