magento 2 获取产品属性

magento 收藏
0 65
<?php $helper = $this->helper('Magento\Catalog\Helper\Output');

$helper->productAttribute($_product, $_product->getDescription(), 'description') ?>

获取多选下拉属性

// block = Magento\Catalog\Block\Product\View

<?php $product = $block->getProduct(); ?> // Get current product
<div>
    <?php 
        $data = explode(',',$product->getData('attribute_code'));
        foreach($data as $value):            
    ?>
        <?php 
        $attr = $product->getResource()->getAttribute('attribute_code');
        if ($attr->usesSource()): ?>
            <?php 
                $option_value = $attr->getSource()->getOptionText($value);
            ?>
            <p><?php echo $option_value; ?></p>

        <?php endif;?>
    <?php endforeach;?>
</div>


    暂时没有人评论
精选帖子
热门帖子
1在phtml中使用图片 80
2创建flutter应用 79
3js 变量命令法 78
4应用配置 78
5js 添加邮箱验证 77
6flutter 构建模式 77
7回流和重绘 77
8作用域 76
9const注意点 75