0
產品(電影)具有屬性「流派」(多選),例如「喜劇,動作,幻想」。在list.phtml文件中,我附加了一些php代碼來顯示每部電影的所有流派。但我只獲得第一個OptionId。Magento - 如何通過選項值獲取屬性搜索的選項ID?
<?php
$AttrName = explode(",",$_product->getResource()->getAttribute('genre')->getFrontend()->getValue($_product));
$attr = $_product->getResource()->getAttribute('genre');
foreach($AttrName as $optvl):
echo $attr->getSource()->getOptionId($optvl);
endforeach;
?>
這個循環有什麼問題?
謝謝你的精神食糧。 – Juri 2014-09-06 21:11:15