Beispiel #1
0
 /**
  * 分析下所有的新增的分类是否和属性对应,因为新增分类id是自增的,所以可能id对应的不正确
  *
  * @Author   tianyunzi
  * @DateTime 2016-02-18T10:28:38+0800
  * @return   [type]                   [description]
  */
 public function cateaddAction()
 {
     $id = 0;
     while (1) {
         $cateMysql = Fbcateinfo::find(array("conditions" => "cateid > ?1 and is_copyadd = 1", "bind" => array(1 => $id), "limit" => 100));
         $cateRs = $cateMysql->toArray();
         if (empty($cateRs)) {
             break;
         }
         foreach ($cateRs as $value) {
             $id = $value["cateid"];
             $propertyRs = Fbcateproperty::find(array("conditions" => "cateid = ?1", "bind" => array(1 => $id), "limit" => 100));
             $propertyRs = $propertyRs->toArray();
             if (empty($propertyRs)) {
                 continue;
             }
             echo $value["catename"] . "\n";
             foreach ($propertyRs as $value1) {
                 echo "====  " . $value1["ppname"] . "  ======\n";
             }
         }
     }
 }
Beispiel #2
0
 /**
  * 处理下分类下的所有的属性数据入库
  *
  * @Author   tianyunzi
  * @DateTime 2016-02-17T11:38:22+0800
  * @param    [type]                   $cateid      [description]
  * @param    [type]                   $propertyArr [description]
  * @return   [type]                                [description]
  */
 public function solveCateProperty($cateid, $propertyArr)
 {
     $this->sort = 1;
     foreach ($propertyArr as $property) {
         $showType = $this->getShowType($property["data"]["showType"], $property, $cateid);
         if ($showType < -1) {
             continue;
         }
         $insertArr = array("ppname" => $property["data"]["value"], "cateid" => $cateid, "showtype" => $showType, "sort" => $this->sort, "defaultvalue" => $this->getDefaultValue($cateid, $property), "parentppid" => 0, "parentvname" => "");
         if (isset($property["data"]["showStyles"]) && in_array("required", $property["data"]["showStyles"])) {
             $insertArr["isrequired"] = 1;
         } else {
             $insertArr["isrequired"] = 0;
         }
         $obj = new Fbcateproperty();
         $res = $obj->save($insertArr);
         if (!$res) {
             var_dump($obj->getMessages());
             exit;
         }
         $this->sort++;
     }
 }