• [织梦吧]唯一域名:www.dedecms8.com,织梦DedeCMS学习平台.

当前位置: > CMS教程 > ecshop教程 >

ECSHOP后台批量添加商品分类

来源: www.dedecms8.com 编辑:织梦吧 时间:2013-08-30点击:

ECSHOP批量添加商品分类,转载68ecshop,未做测试,请大家自行测试。

开发步骤

一、编辑/admin/templates/category_info.htm,查找


?{$lang.cat_name}:
?
?? *
?

替换为


?{$lang.cat_name}:
?
?? *
??
?

二、编辑/admin/category.php,查找

/*------------------------------------------------------ */
//-- 商品分类添加时的处理
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'insert')
{
??? /* 权限检查 */
??? admin_priv('cat_manage');

??? /* 初始化变量 */
??? $cat['cat_id']?????? = !empty($_POST['cat_id'])?????? ? intval($_POST['cat_id'])???? : 0;
??? $cat['parent_id']??? = !empty($_POST['parent_id'])??? ? intval($_POST['parent_id'])? : 0;
??? $cat['sort_order']?? = !empty($_POST['sort_order'])?? ? intval($_POST['sort_order']) : 0;
??? $cat['keywords']???? = !empty($_POST['keywords'])???? ? trim($_POST['keywords'])???? : '';
??? $cat['cat_desc']???? = !empty($_POST['cat_desc'])???? ? $_POST['cat_desc']?????????? : '';
??? $cat['measure_unit'] = !empty($_POST['measure_unit']) ? trim($_POST['measure_unit']) : '';
??? $cat['cat_name']???? = !empty($_POST['cat_name'])???? ? trim($_POST['cat_name'])???? : '';
??? $cat['show_in_nav']? = !empty($_POST['show_in_nav'])? ? intval($_POST['show_in_nav']): 0;
??? $cat['style']??????? = !empty($_POST['style'])??????? ? trim($_POST['style'])??????? : '';
??? $cat['is_show']????? = !empty($_POST['is_show'])????? ? intval($_POST['is_show'])??? : 0;
??? $cat['grade']??????? = !empty($_POST['grade'])??????? ? intval($_POST['grade'])????? : 0;
??? $cat['filter_attr']? = !empty($_POST['filter_attr'])? ? implode(',', array_unique(array_diff($_POST['filter_attr'],array(0)))) : 0;

??? $cat['cat_recommend']? = !empty($_POST['cat_recommend'])? ? $_POST['cat_recommend'] : array();

??? if (cat_exists($cat['cat_name'], $cat['parent_id']))
??? {
??????? /* 同级别下不能有重复的分类名称 */
?????? $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
?????? sys_msg($_LANG['catname_exist'], 0, $link);
??? }

??? if($cat['grade'] > 10 || $cat['grade'] < 0)
??? {
??????? /* 价格区间数超过范围 */
?????? $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
?????? sys_msg($_LANG['grade_error'], 0, $link);
??? }

??? /* 入库的操作 */
??? if ($db->autoExecute($ecs->table('category'), $cat) !== false)
??? {
??????? $cat_id = $db->insert_id();
??????? if($cat['show_in_nav'] == 1)
??????? {
??????????? $vieworder = $db->getOne("SELECT max(vieworder) FROM ". $ecs->table('nav') . " WHERE type = 'middle'");