magento 2 获取产品下拉属性

magento 收藏
0 29
获取select属性

<code class=" hljs coffeescript" codemark="1">$_product->getResource()->getAttribute('your_attribute_code')->getFrontend()->getValue($_product);

$product->getResource()->getAttribute('your_attribute_code')->getFrontend()->getLabel($product);

获取multiselect属性
<?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;?>


下一主题: 阻止冒泡
    暂时没有人评论