如何从属性集中获取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 />';
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2043 次 |
| 最近记录: |