/** * 商城商品详情action * @param $slug * @return string */ public function actionView($slug) { $model = ShopProduct::find()->statusInUseAndOnSale()->andWhere(['slug' => $slug])->one(); if (!$model) { throw new NotFoundHttpException(); } return $this->render('view', ['model' => $model]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ShopProduct::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'price' => $this->price, 'jifen' => $this->jifen, 'product_number' => $this->product_number, 'return_jifen' => $this->return_jifen, 'is_on_sale' => $this->is_on_sale, 'is_delete' => $this->is_delete, 'is_hot' => $this->is_hot, 'is_promote' => $this->is_promote, 'is_check' => $this->is_check, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'thumbnail_base_url', $this->thumbnail_base_url])->andFilterWhere(['like', 'thumbnail_path', $this->thumbnail_path])->andFilterWhere(['like', 'img_base_url', $this->img_base_url])->andFilterWhere(['like', 'img_path', $this->img_path]); return $dataProvider; }
/** * @param null $cat * @return int|string */ public static function getOnSaleProductCount($cat = null) { $query = ShopProduct::find()->statusInUseAndOnSale(); if ($cat != null) { $query->andWhere(['category_id' => $cat]); } return $query->count(); }
/** * Created by PhpStorm. * User: buuug7 * Date: 2016/1/11 * Time: 9:26 * Desc: */ use yii\helpers\Url; use yii\bootstrap\Html; use common\models\ShopProduct; use common\util\Buuug7Util; use common\models\ShopCategory; $this->title = '积分商城'; $hotProduct = ShopProduct::find()->statusInUseAndOnSale()->andWhere(['is_hot' => ShopProduct::IS_HOT_YES])->all(); $xuniProduct = ShopProduct::find()->statusInUseAndOnSale()->andWhere(['category_id' => ShopCategory::findOne(['slug' => 'xu-ni-wu-pin'])->id])->all(); $shitiProduct = ShopProduct::find()->statusInUseAndOnSale()->andWhere(['category_id' => ShopCategory::findOne(['slug' => 'shi-ti-wu-pin'])->id])->all(); $this->beginBlock('slider'); ?> <div class="collection-banner"> <div class="container"> <div class="col-md-7 md-margin-bottom-50"> <h2>积分商城</h2> <p>积分兑换好礼,丰富好礼等你来拿!</p><br> </div> <div class="col-md-5"> <div class="overflow-h"> <span class="percent-numb">50</span> <div class="percent-off"> <span class="discount-percent">%</span>