문제

I am trying to load multiple values of Color attribute in product list phtml file with this code:

<?php echo __('Color: ') . $_product->getAttributeText('color'); ?>

But I get array error:

Notice: Array to string conversion

Any help please? This is magento 2.4 version

도움이 되었습니까?

해결책

Try the following way:


$color = $_product->getAttributeText('color');
        if ($color) {
            if (is_array($color)) {
                echo implode(',', $color);
            } else {
                echo $color;
            }
        }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top