1

各オプションの画像を表示するようにマルチオプション属性を作成しましたが、機能させることができません。

ここにある別の投稿のこのコードを使用して、表示するオプションのリストを取得しました。

私が使用したコードは次のとおりです。

<?php if($_product->getResource()->getAttribute('suitable_for')->getFrontend()->getValue($_product)): ?>
        <h4>Suitable for:</h4>
        <ul><li><?php
            $_comma = ",";
            $_list = "</li><li>";
            echo str_replace($_comma,$_list,$_product->getResource()->getAttribute('suitable_for')->getFrontend()->getValue($_product))    ?>    
        </li></ul>
        <?php endif; ?>

これで、オプションのリストが表示されます。

私が言ったように、私は各オプションの画像を表示したいと思います。

divを作成し、各divに画像を割り当てるのが最善の方法だと思いました。

私は出力が次のようになることを望んでいました:

<div class="option1"></div>
<div class="option2"></div>
<div class="option3"></div>
<div class="option3"></div>

上記のコードの出力の代わりに:

<ul>
    <li>option1</li>
    <li>option2</li>
    <li>option3</li>
    <li>option4</li>
</ul>
4

1 に答える 1

1

コードを次のように変更します

<?php if($_product->getResource()->getAttribute('suitable_for')->getFrontend()->getValue($_product)): ?>
    <h4>Suitable for:</h4>
    <div class="<?php
        $_comma = ",";
        $_list = "\"></div><div class=\"";
        echo str_replace($_comma,$_list,$_product->getResource()->getAttribute('suitable_for')->getFrontend()->getValue($_product))    ?>    
    </div>
    <?php endif; ?>
于 2012-09-17T16:25:05.470 に答える