Chinaunix首页 | 论坛 | 博客
  • 博客访问: 268763
  • 博文数量: 59
  • 博客积分: 1368
  • 博客等级: 中尉
  • 技术积分: 1071
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-02 06:06
文章分类

全部博文(59)

文章存档

2012年(59)

我的朋友

分类: 系统运维

2012-03-04 01:48:43

当Magento中的产品的某个属性为空时,前台将显示为NO,如果需要隐藏此属性,可以按照以下方法做出修改:
打开 app/code/core/Mage/Catalog/Block/Product/View/Attributes.php
将 getAdditionalData 函数中
  1. if (!$product->hasData($attribute->getAttributeCode())) {
  2.     $value = Mage::helper('catalog')->__('N/A');
  3. } elseif ((string)$value == '') {
  4.     $value = Mage::helper('catalog')->__('No');
  5. } elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
  6.     $value = Mage::app()->getStore()->convertPrice($value, true);
  7. }
修改为
  1. if (!$product->hasData($attribute->getAttributeCode())) {
  2.     $value = '';
  3. } elseif ((string)$value == '') {
  4.     $value = '';
  5. } elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
  6.     $value = Mage::app()->getStore()->convertPrice($value, true);
  7. }
刷新前台产品页面,所有值为空的属性将不再显示。

阅读(1787) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~