本文整理匯總了PHP中app\models\Product::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Product::getInstance方法的具體用法?PHP Product::getInstance怎麽用?PHP Product::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Product
的用法示例。
在下文中一共展示了Product::getInstance方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getIndexProductListByCat
public function getIndexProductListByCat($cat_id)
{
$category_service = \Yii::createObject('categoryservice');
$cat_list = $category_service->getChildrenCat($cat_id);
$product_list = Product::getInstance()->getIndexProductList($cat_list);
$product_id_list = [];
$image_id_list = [];
foreach ($product_list as $product) {
$product_id_list[] = $product['product_id'];
$image_id_list[] = $product['image_default_id'];
}
//獲取商品圖片
$image_list = Images::getInstance()->getDefaultImages($image_id_list);
$middle_img_list = [];
if ($image_list) {
foreach ($image_list as $value) {
$middle_img_list[$value->image_id] = $value->middle_url;
}
}
foreach ($product_list as $k => $product) {
if (array_key_exists($product['image_default_id'], $middle_img_list)) {
$product_list[$k]['img'] = Yii::$app->params['img_url'] . $middle_img_list[$product['image_default_id']];
} else {
$product_list[$k]['img'] = '';
}
}
//獲取商品庫存
$client = new \GuzzleHttp\Client();
//$res = $client->get('http://www.pzfresh.com');
return $product_list;
}
示例2: allListProduct
public function allListProduct()
{
$list_products = Product::getInstance()->getAlls();
if (count($list_products) > 0) {
foreach ($list_products as &$product) {
$id = $product->id;
$sql_product = 'SELECT * FROM order_custome WHERE key_r_order = ' . $id . ' ORDER BY price_order DESC LIMIT 6';
$order_products = app('db')->select($sql_product);
$product->order_price = $order_products;
}
}
return view('product', array('list_products' => $list_products));
}