0

Magento の属性の値に従って画像を取得したい。

例:

Attribute > MyAttribute
Values > Nasa, Google, Linux

Images > Nasa.jpg, Google.jpg, Linux.jpg

Products >

Product Nasa < Get Nasa.jpg if is selected an attribute
Product Google < Get Google.jpg if is selected an attribute
Product Linux < Get Linux.jpg if is selected an attribute

このスクリプトは、[はい] が選択されているかどうかを示します。

<?php if($_product->getMyAttribute()): ?>
<img src="/path/to/the/image.jpg">
<?php endif; ?>

私は自分で解決策を見つけました。スクリプトの下。

<?php if ($_product->getAttributeText('myattribute') == "Text Inside"): ?> 
<div id="some"><img src="image.jpg"></div>
<?php endif; ?>
4

1 に答える 1

1

JohannReinkeのAttributeOptionImages拡張機能は、まさにあなたが望むことを実行するはずです。管理者がイメージを維持できるようにするための管理UIも提供します。Johannの拡張機能は無料で、オープンソースでGuthubにあります。

于 2012-11-18T04:18:37.020 に答える