2015-04-23 90 views
-1

我把這段代碼放在一個view.phtml文件中,以檢索特定值的特定CSS樣式的所有產品頁面中的屬性值列表。但有沒有我找不到的PHP錯誤。

有人可以幫助解決或分享任何事情嗎?由於

<?php $attribute_code = "my_attribute_code" ?> 
<?php $attribute_details = Mage::getSingleton("eav/config")->getAttribute("catalog_product", $attribute_code) ?> 
<?php $options = $attribute_details->getSource()->getAllOptions(false) ?> 
     <ul> 
     <?php foreach($options as $option): ?> 
      <li> 
      <?php if ($_product->getResource()->getAttribute('my_attribute_code')->getFrontend()->getValue($_product);?>) === $option['label']): ?> 
       <p style="font-weight:bold;"><?php echo $option['label']; ?></p> 
      <?php else: ?> 
       <p><?php echo $option['label']; ?></p> 
      <?php endif; ?> 
      </li> 
     <?php endforeach; ?> 

回答

0

Synax錯誤:

我刪除這個字符串:從第一個條件語句;?>),一切都看起來很好。

<?php if ($_product->getResource()->getAttribute('my_attribute_code')->getFrontend()->getValue($_product) === $option['label']): ?> 
+0

完美!謝謝 – vhanahrni