code review by hf: do modify product detail return size and color data format
Showing
1 changed file
with
6 additions
and
1 deletions
@@ -242,11 +242,14 @@ class DetailModel | @@ -242,11 +242,14 @@ class DetailModel | ||
242 | ++ $i; | 242 | ++ $i; |
243 | } | 243 | } |
244 | // 遍历所有颜色, 构建尺码显示数据 | 244 | // 遍历所有颜色, 构建尺码显示数据 |
245 | + $i = 1; | ||
245 | foreach ($colorList as $value) { | 246 | foreach ($colorList as $value) { |
246 | // 各个尺码的颜色,每行显示一个颜色的对应尺码 | 247 | // 各个尺码的颜色,每行显示一个颜色的对应尺码 |
247 | - $sizeGroup[]['size'] = $sizeList[ $value['skcId'] ]; | 248 | + $sizeGroup[$i]['size'] = $sizeList[ $value['skcId'] ]; |
248 | // 默认颜色 | 249 | // 默认颜色 |
249 | $colorGroup[0]['color'][] = $value; | 250 | $colorGroup[0]['color'][] = $value; |
251 | + | ||
252 | + ++ $i; | ||
250 | } | 253 | } |
251 | 254 | ||
252 | // 商品图: 多个 | 255 | // 商品图: 多个 |
@@ -275,6 +278,8 @@ class DetailModel | @@ -275,6 +278,8 @@ class DetailModel | ||
275 | $notForSale = $baseInfo['attribute'] == 2; | 278 | $notForSale = $baseInfo['attribute'] == 2; |
276 | // 显示加入购物车链接 | 279 | // 显示加入购物车链接 |
277 | if (!$soldOut && !$notForSale) { | 280 | if (!$soldOut && !$notForSale) { |
281 | + ksort($colorGroup, SORT_NUMERIC); | ||
282 | + | ||
278 | $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'); | 283 | $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'); |
279 | $result['cartInfo']['productId'] = $productId; | 284 | $result['cartInfo']['productId'] = $productId; |
280 | $result['cartInfo']['thumbs'] = $thumbImageList; | 285 | $result['cartInfo']['thumbs'] = $thumbImageList; |
-
Please register or login to post a comment