咨询热线:18076568990、0755-25823180

[已解决] ShoWT 使用 - ShoWT B2B2C最新版 让所有店铺能使用所有分类不一个个绑定

2765 1 希望 发表于 2016-9-7 15:58:52
本帖最后由 希望 于 2016-9-7 16:03 编辑

是不是觉得只有自营店才能使用所有分类,其他店铺得一个个申请每种分类太麻烦了,现在就让我们改一改程序:
让所有店铺能使用所有分类不在需要绑定分类
【温馨提示:修改之前先备份,如果出错了可以还原】
  1. 找到文件:
  2. data\model\goods_class.model.php
  3. /**
  4.      * 取得店铺绑定的分类
  5.      *
  6.      * @param   number  $store_id   店铺id
  7.      * @param   number  $pid        父级分类id
  8.      * @param   number  $deep       深度
  9.      * @return  array   二维数组
  10.      */
  11.     public function getGoodsClass($store_id, $pid = 0, $deep = 1) {
  12.         // 读取商品分类
  13.         $gc_list = $this->getGoodsClassListByParentId($pid);
  14.         // 如果不是自营店铺或者自营店铺未绑定全部商品类目,读取绑定分类
  15.         if (!checkPlatformStoreBindingAllGoodsClass()) {
  16.             $gc_list = array_under_reset($gc_list, 'gc_id');
  17.             $model_storebindclass = Model('store_bind_class');
  18.             $gcid_array = $model_storebindclass->getStoreBindClassList(array(
  19.                 'store_id' => $store_id,
  20.                 'state' => array('in', array(1, 2)),
  21.             ), '', "class_{$deep} asc", "distinct class_{$deep}");
  22.             if (!empty($gcid_array)) {
  23.                 $tmp_gc_list = array();
  24.                 foreach ($gcid_array as $value) {
  25.                     if (isset($gc_list[$value["class_{$deep}"]])) {
  26.                         $tmp_gc_list[] = $gc_list[$value["class_{$deep}"]];
  27.                     }
  28.                 }
  29.                 $gc_list = $tmp_gc_list;
  30.             } else {
  31.                 return array();
  32.             }
  33.         }
  34.         return $gc_list;
  35.     }
  36. 复制代码
  37. 修改为:
  38. /**
  39.      * 取得店铺绑定的分类
  40.      *
  41.      * @param   number  $store_id   店铺id
  42.      * @param   number  $pid        父级分类id
  43.      * @param   number  $deep       深度
  44.      * @return  array   二维数组
  45.      */
  46.     public function getGoodsClass($store_id, $pid = 0, $deep = 1) {
  47.         // 读取商品分类
  48.         $gc_list = $this->getGoodsClassListByParentId($pid);
  49.         // 如果不是自营店铺或者自营店铺未绑定全部商品类目,读取绑定分类
  50.         /*
  51.         if (!checkPlatformStoreBindingAllGoodsClass()) {
  52.             $gc_list = array_under_reset($gc_list, 'gc_id');
  53.             $model_storebindclass = Model('store_bind_class');
  54.             $gcid_array = $model_storebindclass->getStoreBindClassList(array(
  55.                 'store_id' => $store_id,
  56.                 'state' => array('in', array(1, 2)),
  57.             ), '', "class_{$deep} asc", "distinct class_{$deep}");
  58.             if (!empty($gcid_array)) {
  59.                 $tmp_gc_list = array();
  60.                 foreach ($gcid_array as $value) {
  61.                     if (isset($gc_list[$value["class_{$deep}"]])) {
  62.                         $tmp_gc_list[] = $gc_list[$value["class_{$deep}"]];
  63.                     }
  64.                 }
  65.                 $gc_list = $tmp_gc_list;
  66.             } else {
  67.                 return array();
  68.             }
  69.         }*/
  70.         return $gc_list;
  71.     }
  72. 复制代码
  73. shop\control\store_goods_add.php
  74. 寻找:
  75. public function add_step_twoOp
  76. 方法里面的:
  77. // 如果不是自营店铺或者自营店铺未绑定全部商品类目,读取绑定分类
  78.         if (!checkPlatformStoreBindingAllGoodsClass()) {
  79.             $where['class_1|class_2|class_3'] = $gc_id;
  80.             $where['store_id'] = $_SESSION['store_id'];
  81.             $rs = Model('store_bind_class')->getStoreBindClassInfo($where);
  82.             if (empty($rs)) {
  83.                 showMessage(L('store_goods_index_again_choose_category2'));
  84.             }
  85.         }
  86. 复制代码
  87. 改成:
  88. // 如果不是自营店铺或者自营店铺未绑定全部商品类目,读取绑定分类
  89.         /*
  90.         if (!checkPlatformStoreBindingAllGoodsClass()) {
  91.             $where['class_1|class_2|class_3'] = $gc_id;
  92.             $where['store_id'] = $_SESSION['store_id'];
  93.             $rs = Model('store_bind_class')->getStoreBindClassInfo($where);
  94.             if (empty($rs)) {
  95.                 showMessage(L('store_goods_index_again_choose_category2'));
  96.             }
  97.         }
  98.         */
  99. 复制代码
  100. \shop\control\store_goods_online.php
  101. 寻找:public function edit_save_goodsOp()
  102. // 三方店铺验证是否绑定了该分类
  103.         if (!checkPlatformStore()) {
  104.             $where = array();
  105.             $where['class_1|class_2|class_3'] = $gc_id;
  106.             $where['store_id'] = $_SESSION['store_id'];
  107.             $rs = Model('store_bind_class')->getStoreBindClassInfo($where);
  108.             if (empty($rs)) {
  109.                 showDialog(L('store_goods_index_again_choose_category2'));
  110.             }
  111.         }
  112. 复制代码
  113. 修改为:
  114. // 三方店铺验证是否绑定了该分类
  115.         /*
  116.         if (!checkPlatformStore()) {
  117.             $where = array();
  118.             $where['class_1|class_2|class_3'] = $gc_id;
  119.             $where['store_id'] = $_SESSION['store_id'];
  120.             $rs = Model('store_bind_class')->getStoreBindClassInfo($where);
  121.             if (empty($rs)) {
  122.                 showDialog(L('store_goods_index_again_choose_category2'));
  123.             }
  124.         }
  125.         */
  126. 复制代码
复制代码
shopwt 发表于 2016-9-7 19:33:15
感谢提供教程,不过V5.0.1已支持了,跟你上面的方案有些不同,看需要的人看情况来,已打补丁的用户不用此方案。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

  • 今日
    0
  • 主题
    90

推荐贴子

联系我们

产品及方案咨询:18076568990、0755-25823180

电子邮箱:web@shopwt.com、客服微信:shopwtcom

公司地址:深圳市罗湖区人民南路3002号国贸大厦B座1608楼

  • 官方公众号

  • 微信客服