应snwcwqqq要求 加一个产品时让他显示这个类别的产品为关联商品

2016-07-07 15:02 来源:www.chinab4c.com 作者:ecshop专家

good.php

找到

$linked_goods = get_linked_goods($goods_id);

替换成

$linked_goods = get_linked_goods($goods_id,$goods['cat_id']);

找到

function get_linked_goods($goods_id) 一直到...."LIMIT " . $GLOBALS['_CFG']['related_goods_number'];

替换成
  1. function get_linked_goods($goods_id,$cat_id)
  2. {
  3. $sql = 'SELECT g.goods_id, g.goods_name, g.seo_title, g.goods_thumb, g.goods_img, g.shop_price AS org_price, ' .
  4. "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
  5. 'g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' .
  6. 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
  7. "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
  8. "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
  9. "WHERE g.cat_id = $cat_idAND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ". "ORDER BY rand()".
  10. "LIMIT " . $GLOBALS['_CFG']['related_goods_number'];
复制代码

回答:
这样的话 。每个商品的关联产品也太多了吧

good.php

找到

$linked_goods = get_linked_goods($goods_id);

替换成

$linked_goods = ge ...
jerryrat 发表于 2010-6-26 17:26


测试后根本不能使用


测试后根本不能使用
温度 发表于 2010-6-29 10:13




杯具。。我自己用的非常好。不要妄自下结论。

to 2 楼

不多 每个产品页面还是 后台定义的 关联数量。

我做了一个随机选取 聽ORDER BY rand()

把网站发出来看下

这个要顶顶!

按照步骤做的出错了
MySQL server error report:Array ( [0] => Array ( [message] => MySQL Query Error ) [1] => Array ( [sql] => SELECT g.goods_id, g.goods_name, g.seo_title, g.goods_thumb, g.goods_img, g.shop_price AS org_price, IFNULL(mp.user_price, g.shop_price * '1') AS shop_price, g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date FROM `test`.`mingliugoods` AS g LEFT JOIN `test`.`mingliumember_price` AS mp ON mp.goods_id = g.goods_id AND mp.user_rank = '0' WHERE g.cat_id = 6 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ORDER BY rand()LIMIT 6 ) [2] => Array ( [error] => Unknown column 'g.seo_title' in 'field list' ) [3] => Array ( [errno] => 1054 ) )