首页推荐精品的一个很恶心的问题

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

我通过修改lib_goods.php如下

  1. //取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
  2. $sql = 'SELECT g.goods_id, g.goods_name, g.goods_brief, g.goods_desc, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .
  3. "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
  4. "promote_start_date, promote_end_date, g.goods_thumb, g.goods_img, RAND() AS rnd " .
  5. 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
  6. "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
  7. "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ";
  8. $type_merge = array_merge($type_array['new'], $type_array['best'], $type_array['hot']);
  9. $type_merge = array_unique($type_merge);
  10. $sql .= ' WHERE g.goods_id ' . db_create_in($type_merge);
  11. $sql .= ' ORDER BY g.sort_order, g.last_update DESC';

  12. $result = $GLOBALS['db']->getAll($sql);
  13. foreach ($result AS $idx => $row)
  14. {
  15. if ($row['promote_price'] > 0)
  16. {
  17. $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
  18. $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
  19. }
  20. else
  21. {
  22. $goods[$idx]['promote_price'] = '';
  23. }

  24. $goods[$idx]['id'] = $row['goods_id'];
  25. $goods[$idx]['name'] = $row['goods_name'];
  26. $goods[$idx]['brief'] = $row['goods_brief'];
  27. $goods[$idx]['goods_desc'] = $row['goods_desc'];
  28. $goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
  29. $goods[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);

  30. $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
  31. sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
  32. $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'],$row['goods_name_style']);
  33. $goods[$idx]['market_price'] = price_format($row['market_price']);
  34. $goods[$idx]['shop_price'] = price_format($row['shop_price']);
  35. $goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
  36. $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
  37. $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
  38. if (in_array($row['goods_id'], $type_array['best']))
  39. {
  40. $type_goods['best'][] = $goods[$idx];
  41. }
  42. if (in_array($row['goods_id'], $type_array['new']))
  43. {
  44. $type_goods['new'][] = $goods[$idx];
  45. }
  46. if (in_array($row['goods_id'], $type_array['hot']))
  47. {
  48. $type_goods['hot'][] = $goods[$idx];
  49. }
  50. }
  51. }
  52. return $type_goods[$type];
  53. }
复制代码


实现了在全部推荐中调用商品的详细描述
但是一旦切换到分类推荐,详细描述就调不出来了....请教一下各位大虾这是怎么回事....

回答:
切换到分类推荐,你看看url,是不是也不是一个文件了。

一个文件中定义了这个变量,另一个文件中没有,当然就调用不出来了。

切换到分类推荐,你看看url,是不是也不是一个文件了。

一个文件中定义了这个变量,另一个文件中没有,当然就调用不出来了。
l0ss 发表于 2010-4-20 13:43

当然不是....