2012-11-18 89 views
0

我想根據來自magento上的屬性的值獲取圖像。如何顯示來自屬性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; ?> 
+0

如果你有答案寫在答案部分......它也令其他人感到困惑 –

回答

1

Johann Reinke的Attribute Option Images擴展應該做你想要的。它甚至爲管理員提供了管理員用戶界面,以便能夠維護圖像。約翰的擴展是免費的,開放源碼和Guthub。

+0

謝謝吉姆,是一個很好的擴展。 – Dar

+0

如果我(或其他人)的答案幫助你,請不要忘記接受答案。另外,不要忘記選擇任何您認爲有幫助的問題或答案。 SO用戶的愛聲望點(或「代表」)! –

相關問題