如何获得产品属性组在 magento 2 中来自 属性集 .
我想在 上显示属性列表页通过使用组,以便我将来可以添加更多属性
最佳答案
您只需通过 $product->getAttributes();
获取所有产品属性
$productAttributes=$product->getAttributes();
$group_id=9;
$attributeSetId=4;
foreach ($productAttributes as $attribute) {
if ($attribute->isInGroup($attributeSetId, $group_id)) {
echo $attribute->getFrontendLabel().' : '.$attribute->getFrontend()->getValue($product).'<br />';
}
}
关于magento2 - 通过magento 2中的产品属性组获取产品属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39263706/