magento2 - 通过magento 2中的产品属性组获取产品属性

标签 magento2

如何获得产品属性组在 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/

相关文章:

php - 我如何显示在 Magento 2 中节省的金额?

magento - 将商店 View 选择器添加到 Magento 2 中的管理工具栏

magento2 - 为 Magento\Framework\Interception\PluginList\PluginList 的 $reader 参数提供的参数配置无效

php - 找不到 setIsInProcess() 函数定义

php - Magento 2 : Database user does not have enough privileges

xml - Magento 2 : ifconfig in xml for module enable/disable

installation - 如何在 magento 2 中安装下载的免费主题?

php - try/catch block 中未捕获异常

php - Magento 2 - 如何在另一个 phtml 文件、xml 布局、静态 block 和 cms 页面中调用自定义 phtml 文件?

magento2 - Magento 2 给出错误,没有类别保存。错误是 - 没有 id = xx 的此类实体