【发布时间】:2013-06-26 11:53:09
【问题描述】:
我有一个用于warranty_labour 的下拉magento 属性。我正在使用我的主题 product/view.phtml 提取属性,然后附加一个图标以显示您获得的保修。
我已经使用了成功运行的代码:
<?php $warranty=$_product->getAttributeText('warranty_labour'); echo '<img style="padding-top: 10px;" src="/images/warrantylabour/'.str_replace(' ', '_',$warranty).'.png" alt="'.$warranty.'">'; ?>
当产品没有设置保修属性时我发现的问题(后端留空)我仍然将代码插入到前端的产品源代码中,如下所示:
<img style="pad`ding-top: 10px;" src="/images/warrantylabour/.png" alt="">`
当属性中没有设置值时,有没有办法阻止这种情况发生?
【问题讨论】:
标签: image magento attributes icons