function getProducts($products) { foreach ($products as $k => $product) { $skus = ProductsSku::getItemSkus($product['item']); $min = 100000.0; $max = 0.0; $price = ''; foreach ($skus as $sku) { if ($min > $sku['current_price']) { $min = $sku['current_price']; } if ($max < $sku['current_price']) { $max = $sku['current_price']; } } if ($min == $max) { $price = $min; } else { $price = "{$min} ~ {$max}"; } $products[$k]['price'] = $price; if (!isset($products[$k]['pics']) || !$products[$k]['pics']) { $path = ''; foreach ($skus as $sku) { $pic = ProductsPic::getOne(array('sku' => $sku['sku']), 'path', 'sort DESC'); $path = isset($pic['path']) ? $pic['path'] : ''; if ($path) { break; } } $products[$k]['pics'] = $path; } } return $products; }
header("Location: /html/404.html?004"); exit; } $item_code = $sku['item']; $item = ProductsItem::getOne(array('item' => $item_code, 'status' => 1)); if (!$item) { header("Location: /html/404.html?005"); exit; } $sku['iteminfo'] = $item; $sku_code = $sku['sku']; $pics = ProductsPic::getSkuPics($sku_code, 'path', 'sort DESC LIMIT 0,3'); $sku['pics'] = $pics; $sku['order_num'] = OrdersProducts::getSkuAllNum($sku_code); $sku['stock'] = ProductsStock::getSkuStock($sku_code); $skus = ProductsSku::getItemSkus($item_code, "id,sku,sku_name"); $skus = ProductsSku::getProductsPic($skus); $sku['skus'] = $skus; $userid = isset($_SESSION['userid']) ? (int) $_SESSION['userid'] : 0; $history = array(); if ($userid) { $history = UsersHistory::getProductViewLog($userid, $id); } if (!$history) { $history = ProductsSku::getRand($item_code); } $history = ProductsSku::getProductsPic($history); $history = ProductsSku::getProductsItemTitle($history); ProductsSku::increase("id={$id}", 'view_num'); $log = array('op' => 'view', 'id' => $id, 'url' => Func::getCurrentURL()); $log = json_encode($log);