发新话题
打印

[待解决] 如何在商品列表页将商品的自定义属性调出显示?

如何在商品列表页将商品的自定义属性调出显示?

如何在商品列表页将商品的自定义属性调出显示?

自己在后台,设置了商品的一些属性~~
在列表页,默认只显示商品一些基本属性~~如价格等~~
而我需要将我自定义的一些属性显示在列表页~~不知道要怎么作?>
我在商品详情页模板代码中提取了部分代码放到里面不起任何作用~~

我发出我自己修改相关文件的办法,但不成功

一:改 themes\相关模板目录\librarygoods_list.lbi
复制内容到剪贴板
代码:
{$lang.shop_price}<span class="goods-price">{$goods.shop_price}</span>
          <!--{/if}-->
下面增加:
复制内容到剪贴板
代码:
<!--{if $properties or $specification}-->
             <table border="1" class="goods-table">
                <!-- {foreach from=$properties item=property_group key=key} -->
                <!-- {foreach from=$property_group item=property} -->
                <tr>
                  <th>{$property.name|escape:html} :</th>
                  <td>{$property.value|escape:html}</td>
                </tr>
                <!-- {/foreach}-->
                <!-- {/foreach}-->
              </table>
            <!-- {/if}-->
二:在category.php中修改:
复制内容到剪贴板
代码:
$smarty->assign('top_goods',        get_top10());                  // 销售排行
下面增加:
复制内容到剪贴板
代码:


//添加获取商品自定义属性
$properties = get_goods_properties($goods_id);  // 获得商品的规格和属性
    $smarty->assign('properties',          $properties['pro']);                              // 商品属性
    $smarty->assign('specification',       $properties['spe']);                              // 商品规格
//添加获取商品自定义属性结束
三:改templates\compiled\下面的  goods_list.lbi.php 文件
复制内容到剪贴板
代码:
<p class="price">
          <?php if ($this->_var['show_marketprice']): ?>
          <?php echo $this->_var['lang']['market_price']; ?><span class="market-price"><?php echo $this->_var['goods']['market_price']; ?></span><br />
          <?php endif; ?>
          <?php if ($this->_var['goods']['promote_price'] != ""): ?>
          <?php echo $this->_var['lang']['promote_price']; ?><span class="goods-price"><?php echo $this->_var['goods']['promote_price']; ?></span>
          <?php else: ?>
          <?php echo $this->_var['lang']['shop_price']; ?><span class="goods-price"><?php echo $this->_var['goods']['shop_price']; ?></span>
          <?php endif; ?>
下面增加:
复制内容到剪贴板
代码:
<!--/*在列表页显示商品自定义属性 */-->
          <?php if ($this->_var['properties'] || $this->_var['specification']): ?>
              <table border="1" class="goods-table">
                <?php $_from = $this->_var['properties']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'property_group');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['property_group']):
?>
                <?php $_from = $this->_var['property_group']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'property');if (count($_from)):
    foreach ($_from AS $this->_var['property']):
?>
                <tr>
                  <th><?php echo htmlspecialchars($this->_var['property']['name']); ?> :</th>
                  <td><?php echo htmlspecialchars($this->_var['property']['value']); ?></td>
                </tr>
                <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
              </table>
            <?php endif; ?>
           <!--/*在列表页显示商品自定义属性 */-->
OK,完成这个之后~~~更新了缓存,但是还是不显示,我郁闷,我实在搞不懂怎么弄了~~~

[ 本帖最后由 王可梦 于 2008-8-8 14:52 编辑 ]

TOP

有没有管理员来帮帮我啊???

TOP

关注,同问。

如果能在商品信息页自由调用自己想要的自定义“商品属性”,多好啊

TOP

再顶~~没人理我~~不行吗>?

TOP

因为涉及二次开发,所以不要指望EC的人来回答,只能等热心网友帮忙了

TOP

我也支持一下,需要啊~~~

TOP

回复 #1 王可梦 的帖子

1、修改templates\compiled\下面的任何文件是白费力气。
2、$properties = get_goods_properties($goods_id);  // 获得商品的规格和属性
其中的 $goods_id 未赋值。。。

TOP

碰到这个问题了,烦啊

TOP

没有人用到这个功能吗?如果网站所有商品都有属性,难道都必须要点去商品详细页才能再订购?太麻烦了吗
哈哈,我来了!

TOP

发新话题