按magento 2中的产品属性组获取产品属性

Waq*_*qar 5 magento2

如何从属性集中获取magento 2中的产品属性组。我想通过使用组在列表页面上显示属性,以便将来可以添加更多属性

Qai*_*tti 3

您只需通过以下方式即可获得所有产品属性$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)