商品价字段 市场价字段 库存字段 sku字段
sku字段是代表
举个例子:
手机
32g id=1
黑色(id=5 ) 白色id=6() 如果我想要的是手机 32g 黑色,哪个sku是1,5
$goodsStandardData是什么呢?
那sku是1,5 1,6是怎么实现的呢?
/** * 组合 */ public function combineAttributes(){ $m_len=count($this->models); if($m_len>=2){ $result=$this->recurse($this->models[$this->index],$this->models[++$this->index],$m_len); }else{ $result=$this->models[0]; } return $result; } /** * 递归拼接属性 * @param $array1 * @param $array2 * @param $m_len * @return array */ public function recurse($array1,$array2,$m_len){ $res=[]; foreach ($array1 as $a1){ foreach ($array2 as $a2){ array_push($res,$a1.','.$a2); } } $this->index++; if($this->index<=$m_len-1){ return $this->recurse($res,$this->models[$this->index],$m_len); }else{ return $res; } }