4个数组:
$this->data["specs"] = $specs;
$this->data["thespecs"] = $thespecs;
$this->data["itemspecs"] = $itemspecs;
$this->data['productstr'] = json_encode($products);
衣服有2个规格,颜色和尺码
dump($this->data["specs"]);
显示如下:
Array ( [1] => Array ( [specid] => 1 [name] => 颜色 [memo] => 服装 [type] => pic ) [2] => Array ( [specid] => 2 [name] => 尺码 [memo] => 服装 [type] => text ) )
$thespecs[$spec['specid']][] = $spec['specvalid'];,规格ID对应的规格值ID。
dump($this->data["thespecs"]);
显示如下:
Array ( [1] => Array ( [0] => 36 [1] => 31 [2] => 5 [3] => 31 ) [2] => Array ( [0] => 8 [1] => 8 [2] => 10 [3] => 9 ) )
dump($this->data["itemspecs"]);
显示如下:
Array ( [1] => Array ( [text] => Array ( [5] => 黑色 [31] => 白色 [36] => 蓝色 ) [pic] => Array ( [1] => [2] => [3] => [4] => [5] => http://demo.yuncart.com/uploads//2012/05/08/20120508145603_308v_cfc2ca1a.jpg [6] => [7] => [31] => http://demo.yuncart.com/uploads//2012/05/08/20120508145611_QCRB_2b3877c6.jpg [32] => [33] => [34] => [35] => [36] => http://demo.yuncart.com/uploads//2012/05/08/20120508145558_Yxkp_5683169c.jpg [37] => [38] => ) [sel] => Array ( [0] => 5 [1] => 31 [2] => 36 ) ) [2] => Array ( [text] => Array ( [8] => S [9] => M [10] => L ) [sel] => Array ( [0] => 8 [1] => 9 [2] => 10 ) ) )
货品数组:$products[$spec['productid']]['spec'][$spec['specid']] = $spec['specvalid'];
$this->data['productstr']的值是json_encode($products)的JSON字符串(点击规格时,Javascript设置规格可选不可选用到),$products的结构如下:
Array ( [67] => Array ( [productid] => 67 [itemid] => 8 [bn] => C3NC405210201 [inventory] => 20 [price] => 110.00 [volume] => 0 [spec] => Array ( [1] => 36 [2] => 8 ) ) [68] => Array ( [productid] => 68 [itemid] => 8 [bn] => C3NC405210202 [inventory] => 20 [price] => 110.00 [volume] => 0 [spec] => Array ( [1] => 31 [2] => 8 ) ) [69] => Array ( [productid] => 69 [itemid] => 8 [bn] => C3NC405210203 [inventory] => 20 [price] => 110.00 [volume] => 0 [spec] => Array ( [1] => 5 [2] => 10 ) ) [70] => Array ( [productid] => 70 [itemid] => 8 [bn] => C3NC405210204 [inventory] => 20 [price] => 110.00 [volume] => 0 [spec] => Array ( [1] => 31 [2] => 9 ) ) )