商品自定义销量(虚拟销量)实现方法
1.在sq执行语句
- ALTER TABLE `ecs_goods` ADD `sales_volume_base` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'
- INSERT INTO `ecs_shop_config` (`parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order` ) VALUES ('7','show_goods_sales', 'select', '1,0', '', '1', '1');
-
- INSERT INTO `ecs_shop_config` (`parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order` ) VALUES ('3', 'show_sales_type', 'select', '1,0', '', '1', '1');
复制代码
注意:如果你的数据表前缀不是‘ecs_’ 请自行修改
2./admin/includes/lib_goods.php中- $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
- " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
- " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
- " ORDER BY $filter[sort_by] $filter[sort_order] ".
- " LIMIT " . $filter['start'] . ",$filter[page_size]";
复制代码 修改为
- $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, sales_volume_base, " .
- " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
- " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
- " ORDER BY $filter[sort_by] $filter[sort_order] ".
- " LIMIT " . $filter['start'] . ",$filter[page_size]";
复制代码
3./admin/templates/goods_list.htm,在
- {if $use_storage} {$lang.goods_number}{$sort_goods_number} {/if}
复制代码 后,添加
- {$lang.sales_volume_base}{$sort_sales_volume_base}
复制代码 在
- {if $use_storage} {$goods.goods_number} {/if}
复制代码 后,添加
- {$goods.sales_volume_base}
复制代码 4./admin/goods.php,在
- /**
- * 列表链接
- * @param bool $is_add 是否添加(插入)
- * @param string $extension_code 虚拟商品扩展代码,实体商品为空
- * @return array('href' => $href, 'text' => $text)
- */ function list_link($is_add = true, $extension_code = '')
复制代码
前,添加
- /*------------------------------------------------------ */ //-- 修改商品虚拟销量 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'edit_sales_volume_base')
- {
- check_authz_json('goods_manage');
-
- $goods_id = intval($_POST['id']);
- $sales_volume_base = json_str_iconv(trim($_POST['val']));
-
- if ($exc->edit("sales_volume_base = '$sales_volume_base', last_update=" .gmtime(), $goods_id))
- {
- clear_cache_files();
- make_json_result(stripslashes($sales_volume_base));
- }
- }
复制代码 5.goods.php,在
- $smarty->assign('categories', get_categories_tree($goods['cat_id'])); // 分类树
复制代码 后,添加
- $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
- " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
- " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
- " ORDER BY $filter[sort_by] $filter[sort_order] ".
- " LIMIT " . $filter['start'] . ",$filter[page_size]";0
复制代码 在末尾添加
- $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
- " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
- " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
- " ORDER BY $filter[sort_by] $filter[sort_order] ".
- " LIMIT " . $filter['start'] . ",$filter[page_size]";1
复制代码
6.在/languages/zh_cn/admin/shop_config.php,中
/languages/zh_cn/admin/shop_config.php
下,添加- $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
- " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
- " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
- " ORDER BY $filter[sort_by] $filter[sort_order] ".
- " LIMIT " . $filter['start'] . ",$filter[page_size]";2
复制代码
7./languages/zh_cn/admin/goods.php,中
- $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
- " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
- " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
- " ORDER BY $filter[sort_by] $filter[sort_order] ".
- " LIMIT " . $filter['start'] . ",$filter[page_size]";3
复制代码 后,添加
- $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
- " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
- " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
- " ORDER BY $filter[sort_by] $filter[sort_order] ".
- " LIMIT " . $filter['start'] . ",$filter[page_size]";4
复制代码 8./languages/zh_cn/common.php,中
- $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
- " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
- " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
- " ORDER BY $filter[sort_by] $filter[sort_order] ".
- " LIMIT " . $filter['start'] . ",$filter[page_size]";5
复制代码
后,添加
- $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
- " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
- " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
- " ORDER BY $filter[sort_by] $filter[sort_order] ".
- " LIMIT " . $filter['start'] . ",$filter[page_size]";6
复制代码
9./themes/default/goods.dwt,在
- $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
- " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
- " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
- " ORDER BY $filter[sort_by] $filter[sort_order] ".
- " LIMIT " . $filter['start'] . ",$filter[page_size]";7
复制代码 后,添加
- $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
- " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
- " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
- " ORDER BY $filter[sort_by] $filter[sort_order] ".
- " LIMIT " . $filter['start'] . ",$filter[page_size]";8
复制代码
OK,完成! |