国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 網(wǎng)站 > 建站經(jīng)驗(yàn) > 正文

ecshop商品屬性排序的問(wèn)題

2024-04-25 20:43:27
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

情況一:添加新產(chǎn)品時(shí),讓屬性按照添加的順序(屬性id)排列

修改/inclues/lib_goods.php

/* 獲得商品的規(guī)格 */

$sql = "SELECT a.attr_id, a.attr_name, a.attr_group, a.is_linked, a.attr_type, ".

"g.goods_attr_id, g.attr_value, g.attr_price " .

'FROM ' . $GLOBALS['ecs']->table('goods_attr') . ' AS g ' .

'LEFT JOIN ' . $GLOBALS['ecs']->table('attribute') . ' AS a ON a.attr_id = g.attr_id ' .

"WHERE g.goods_id = '$goods_id' " .

'ORDER BY g.goods_attr_id, a.sort_order, g.attr_price';

$res = $GLOBALS['db']->getAll($sql);

情況二:在復(fù)制商品時(shí)屬性排序跟原商品相反到處理

修改/inclues/lib_goods.php

/**

* 取得商品屬性

* @param int $goods_id 商品id

* @return array

*/

function get_goods_attr($goods_id)

{

$attr_list = array();

$sql = "SELECT a.attr_id, a.attr_name " .

"FROM " . $GLOBALS['ecs']->table('goods') . " AS g, " . $GLOBALS['ecs']->table('attribute') . " AS a " .

"WHERE g.goods_id = '$goods_id' " .

"AND g.goods_type = a.cat_id " .

"AND a.attr_type = 1".' ORDER BY a.attr_id';

$attr_id_list = $GLOBALS['db']->getCol($sql);

$res = $GLOBALS['db']->query($sql);

while ($attr = $GLOBALS['db']->fetchRow($res))

{

if (defined('ECS_ADMIN'))

{

$attr['goods_attr_list'] = array(0 => $GLOBALS['_LANG']['select_please']);

}

else

{

$attr['goods_attr_list'] = array();

}

$attr_list[$attr['attr_id']] = $attr;

}

$sql = "SELECT attr_id, goods_attr_id, attr_value " .

"FROM " . $GLOBALS['ecs']->table('goods_attr') .

" WHERE goods_id = '$goods_id' " .

"AND attr_id " . db_create_in($attr_id_list).' ORDER BY goods_attr_id';

$res = $GLOBALS['db']->query($sql);

while ($goods_attr = $GLOBALS['db']->fetchRow($res))

{

$attr_list[$goods_attr['attr_id']]['goods_attr_list'][$goods_attr['goods_attr_id']] = $goods_attr['attr_value'];

}

return $attr_list;

}

補(bǔ)充:上面說(shuō)的是同一屬性里屬性值的排序

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 洞口县| 大洼县| 清镇市| 福州市| 永州市| 陵川县| 吉首市| 正蓝旗| 措勤县| 阜宁县| 保山市| 肃南| 云安县| 海口市| 两当县| 玉树县| 北辰区| 尼玛县| 罗山县| 新泰市| 称多县| 永吉县| 台中县| 沈丘县| 祁东县| 从化市| 泌阳县| 恩施市| 融水| 鹿泉市| 图们市| 申扎县| 和田市| 都匀市| 揭东县| 旬阳县| 安阳县| 临潭县| 都兰县| 乌什县| 镇原县|