Pārlūkot izejas kodu

change color id

stanley-king 9 gadi atpakaļ
vecāks
revīzija
737de96f07

+ 21 - 20
crontab/crawl/fetch_goods.php

@@ -54,23 +54,24 @@ function not_null($str)
 //$tmreq = new tmrequest();
 //$tmreq->proc();
 
-$brander = new brand_operator();
-
-$cat = new category();
-$cat->proc();
-
-$treater = new pretreat_tmdata();
-$treater->proc(false);
-
-
-$spec = new spec_attr_parser();
-$spec->proc();
-
-$importer = new product_importer();
-$importer->proc_shop();
-
-
-$brander->update_brand();
-
-//$ichecker = new importer_check();
-//$ichecker->proc();
+//$brander = new brand_operator();
+//
+//$cat = new category();
+//$cat->proc();
+//
+//$treater = new pretreat_tmdata();
+//$treater->proc(false);
+//
+//
+//$spec = new spec_attr_parser();
+//$spec->proc();
+//
+//$importer = new product_importer();
+//$importer->proc_shop();
+
+
+//$brander->create();
+//$brander->update_brand();
+
+$ichecker = new importer_check();
+$ichecker->proc();

+ 1 - 1
crontab/crawl/importer_check.php

@@ -51,7 +51,7 @@ class importer_check
 
     private function check_images($comm_id)
     {
-        $goods = $this->goods->field('goods_image_id,color_id')->where(array('goods_commonid' => $comm_id))->group('filesig')->limit(false)->select();
+        $goods = $this->goods_images->field('goods_image_id,color_id')->where(array('goods_commonid' => $comm_id))->group('filesig')->limit(false)->select();
         if(empty($goods)) {
             return false;
         }

+ 19 - 0
gcidfiller.php

@@ -0,0 +1,19 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 16/1/11
+ * Time: 下午12:43
+ */
+
+
+define('BASE_ROOT_PATH',str_replace('\\','/',dirname(__FILE__)));
+require_once (BASE_ROOT_PATH . '/fooder.php');
+require_once (BASE_UTIL_PATH . '/gcid_fill.php');
+
+define('StartTime', microtime(true));
+define('TIMESTAMP', time());
+Base::run_test();
+
+$filler = new gcid_fill();
+$filler->proc();

+ 4 - 4
shop/templates/default/seller/store_goods_add.step2.php

@@ -128,17 +128,17 @@
       <?php if(is_array($output['spec_list']) && !empty($output['spec_list'])){?>
       <?php $i = '0';?>
       <?php foreach ($output['spec_list'] as $k=>$val){?>
-      <dl nc_type="spec_group_dl_<?php echo $i;?>" nctype="spec_group_dl" class="spec-bg" <?php if($k == '1'){?>spec_img="t"<?php }?>>
+      <dl nc_type="spec_group_dl_<?php echo $i;?>" nctype="spec_group_dl" class="spec-bg" <?php if($k == '1627207'){?>spec_img="t"<?php }?>>
         <dt>
           <input name="sp_name[<?php echo $k;?>]" type="text" class="text w60 tip2 tr" title="自定义规格类型名称,规格值名称最多不超过6个字" value="<?php if (isset($output['goods']['spec_name'][$k])) { echo $output['goods']['spec_name'][$k];} else {echo $val['sp_name'];}?>" maxlength="6" nctype="spec_name" data-param="{id:<?php echo $k;?>,name:'<?php echo $val['sp_name'];?>'}"/>
           <?php echo $lang['nc_colon']?></dt>
 
-        <dd <?php if($k == '1'){?>nctype="sp_group_val"<?php }?>>
+        <dd <?php if($k == '1627207'){?>nctype="sp_group_val"<?php }?>>
           <ul class="spec">
             <?php if(is_array($val['value'])){?>
             <?php foreach ($val['value'] as $v) {?>
             <li><span nctype="input_checkbox">
-              <input type="checkbox" value="<?php echo $v['sp_value_name'];?>" nc_type="<?php echo $v['sp_value_id'];?>" <?php if($k == '1'){?>class="sp_val"<?php }?> name="sp_val[<?php echo $k;?>][<?php echo $v['sp_value_id']?>]">
+              <input type="checkbox" value="<?php echo $v['sp_value_name'];?>" nc_type="<?php echo $v['sp_value_id'];?>" <?php if($k == '1627207'){?>class="sp_val"<?php }?> name="sp_val[<?php echo $k;?>][<?php echo $v['sp_value_id']?>]">
               </span><span nctype="pv_name"><?php echo $v['sp_value_name'];?></span></li>
             <?php }?>
             <?php }?>
@@ -149,7 +149,7 @@
                 <a href="javascript:void(0);" nctype="specAddSubmit" class="ncsc-btn ncsc-btn-acidblue ml5 mr5">确认</a><a href="javascript:void(0);" nctype="specAddCancel" class="ncsc-btn ncsc-btn-orange">取消</a></div>
             </li>
           </ul>
-          <?php if($output['edit_goods_sign'] && $k == '1'){?>
+          <?php if($output['edit_goods_sign'] && $k == '1627207'){?>
           <p class="hint">添加或取消颜色规格时,提交后请编辑图片以确保商品图片能够准确显示。</p>
           <?php }?>
         </dd>

+ 0 - 2
util.php

@@ -11,8 +11,6 @@ define('BASE_ROOT_PATH',str_replace('\\','/',dirname(__FILE__)));
 require_once (BASE_ROOT_PATH . '/fooder.php');
 require_once (BASE_UTIL_PATH . '/sku_mapper.php');
 
-
-
 define('StartTime', microtime(true));
 define('TIMESTAMP', time());
 Base::run_test();

+ 82 - 0
util/gcid_fill.php

@@ -0,0 +1,82 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 16/1/20
+ * Time: 下午4:53
+ */
+
+require_once(BASE_CRONTAB_PATH . '/crawl/class_tree.php');
+
+class gcid_fill
+{
+    private $cls_tree;
+    private $mod_goods;
+    private $mod_goods_common;
+
+    public function __construct()
+    {
+        $this->mod_goods = Model('goods');
+        $this->mod_goods_common = Model('goods_common');
+        $this->cls_tree = new class_tree();
+    }
+
+    private function fill_class($cid,&$val,&$name)
+    {
+        $ret = $this->cls_tree->get_info($cid,$cid_1,$cid_2,$cid_3,$name);
+
+        if($ret) {
+            $val['gc_id'] = $cid;
+            $val['gc_id_1'] = $cid_1;
+            $val['gc_id_2'] = $cid_2;
+            $val['gc_id_3'] = $cid_3;
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public function proc()
+    {
+        $this->proc_goods_common();
+        $this->proc_goods();
+    }
+
+    private function proc_goods()
+    {
+        $items = $this->mod_goods->field('gc_id')->group('gc_id')->select();
+        foreach ($items as $item)
+        {
+            $cid = $item['gc_id'];
+            $val = array();
+            if ($this->fill_class($cid, $val,$name)) {
+                $ret = $this->mod_goods->where(array('gc_id' => $cid))->update($val);
+                if ($ret == false) {
+                    Log::record("cannot update goods class id info where gc_id = {$cid}.", Log::DEBUG);
+                }
+            } else {
+                Log::record("cannot find goods class info where gc_id = {$cid}.", Log::DEBUG);
+            }
+        }
+    }
+
+    private function proc_goods_common()
+    {
+        $items = $this->mod_goods_common->field('gc_id')->group('gc_id')->select();
+        foreach ($items as $item) {
+            $cid = $item['gc_id'];
+            $val = array();
+            if ($this->fill_class($cid, $val,$name)) {
+                $val['gc_name'] = $name;
+                //$val['type_id'] = $cid;
+                $ret = $this->mod_goods_common->where(array('gc_id' => $cid))->update($val);
+                if ($ret == false) {
+                    Log::record("cannot update goods class id info where gc_id = {$cid}.", Log::DEBUG);
+                }
+            } else {
+                Log::record("cannot find goods class info where gc_id = {$cid}.", Log::DEBUG);
+            }
+        }
+    }
+}