欢迎各位兄弟 发布技术文章
这里的技术是共享的
在使用ecshop中当更改商品图片后,该图片就会置于商品相册的最后一个,于是前台显示放大图就会于相册第一张不同。修改方法很简单:
找到include/lib_goods.php文件中“获得指定商品的相册”的get_goods_gallery函数,
将
查找代码如下:
" WHERE goods_id = '$goods_id' LIMIT "
大概在代码730行,如图所示
更改为
" WHERE goods_id = ‘$goods_id’ ORDER BY img_id ASC LIMIT "
最近发现商品相册发生了比较严重的问题. 1.后台根据商品图顺序上传,结果后台商品相册内显示的商品图顺序并不是根据上传顺序显示。 2.显示顺序是混乱的. 3.如何调整商品相册内商品图顺序呢?(各位好心人不要跟我说重传,小弟我已经针对一件商品重复上传了几百遍了,顺序还是错误) 请各位好心人指点一下,如何调整顺序,是不是给各个商品图编号就可以了?系统会按照商品名称的编号自动按顺序排列? |
如果您对代码比价了解的话可以修改"includes\lib_goods.php"function get_goods_gallery 这个函数,可以按商品相册的发布时间或是id号来取数据。 |
$sql = 'SELECT img_id, img_url, thumb_url, img_desc' . ' FROM ' . $GLOBALS['ecs']->table('goods_gallery') . " WHERE goods_id = '$goods_id' LIMIT " . $GLOBALS['_CFG']['goods_gallery_number']." ORDER BY image_id DESC ; 根据id。 |
$sql = 'SELECT img_id, img_url, thumb_url, img_desc' . ' FROM ' . $GLOBALS['ecs']->table('goods_gallery') . " WHERE goods_id = '$goods_id' LIMIT " . $GLOBALS['_CFG']['goods_gallery_number']; $row = $GLOBALS['db']->getAll($sql); 请问是不是把上面的这一段代码修改成下面的代码 $sql = 'SELECT img_id, img_url, thumb_url, img_desc' . ' FROM ' . $GLOBALS['ecs']->table('goods_gallery') . " WHERE goods_id = '$goods_id' LIMIT " . $GLOBALS['_CFG']['goods_gallery_number']." ORDER BY image_id DESC ; 根据id。 |
$sql = 'SELECT img_id, img_url, thumb_url, img_desc' . ' FROM ' . $GLOBALS['ecs']->table('goods_gallery') . " WHERE goods_id = '$goods_id' LIMIT " . $GLOBALS['_CFG']['goods_gallery_number']." ORDER BY image_id DESC ; 注意红色部分呢,对应修改 |
$sql = 'SELECT img_id, img_url, thumb_url, img_desc' . ' FROM ' . $GLOBALS['ecs']->table('goods_gallery') . " WHERE goods_id = '$goods_id' LIMIT " . $GLOBALS['_CFG']['goods_gallery_number']." ORDER BY img_id DESC ; order by img_id DESC 是安降序排列,但它不能放在limit的后面.所以会报错,应该改成: $sql = 'SELECT img_id, img_url, thumb_url, img_desc' . ' FROM ' . $GLOBALS['ecs']->table('goods_gallery') . " WHERE goods_id = '$goods_id' ORDER BY img_id DESC LIMIT " . $GLOBALS['_CFG']['goods_gallery_number']; (includes\lib_goods.php function get_goods_gallery函数) 这样就不会报错了.如果不想安降序排列把DESC去掉就行了. |
好像官方默认的是先传的先显示,你的是不是自己改过什么程序 |
includes/lib_goods.php 修改get_goods_gallery($goods_id) 函数部分 在SQL语句中加一个“ order by img_id asc ” 就是先传的先显示, 改成 “ order by img_id desc” 就是后传的先显示 |
order by 应该要在 limit 前 否则程序肯定报错! |
哈哈哈哈哈 问题终于解决了 my god!! ! 稍后整理一下我会将解决方法贴上 |
改成這樣即可以商品相簿描述來排列 |