コード例 #1
0
 /**
  * Creates a new ItemImg model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $itemModel = new Item();
     $imagesArray = $itemModel->getUploadImages();
     foreach ($imagesArray as $image) {
         $itemImg = new ItemImg();
         $itemImg->item_id = Yii::$app->request->post('item_id');
         $itemImg->pic = $image['pic'];
         $itemImg->title = $image['title'];
         $itemImg->position = Yii::$app->request->post('position');
         $itemImg->create_time = time();
         if (!$itemImg->save()) {
             return json_encode(['error' => Yii::t('catalog', 'save images to database fail.')]);
         }
     }
     return json_encode([]);
 }
コード例 #2
0
 public function actionGetWishlist()
 {
     $user_id = Yii::$app->user->id;
     if ($user_id) {
         $items = Item::find()->innerJoin('wishlist', 'item.item_id = wishlist.item_id', ['wishlist.user_id' => $user_id]);
         $pages = new Pagination(['totalCount' => $items->count(), 'pageSize' => '3']);
         $items = $items->offset($pages->offset)->limit($pages->limit)->all();
         return $this->render('index', ['items' => $items, 'pages' => $pages]);
     } else {
         return $this->redirect(['/user/login']);
     }
 }
コード例 #3
0
ファイル: ItemSearch.php プロジェクト: shuangjie/galaxy
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Item::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['item_id' => $this->item_id, 'category_id' => $this->category_id, 'stock' => $this->stock, 'min_number' => $this->min_number, 'price' => $this->price, 'shipping_fee' => $this->shipping_fee, 'is_show' => $this->is_show, 'is_promote' => $this->is_promote, 'is_new' => $this->is_new, 'is_hot' => $this->is_hot, 'is_best' => $this->is_best, 'click_count' => $this->click_count, 'wish_count' => $this->wish_count, 'review_count' => $this->review_count, 'deal_count' => $this->deal_count, 'create_time' => $this->create_time, 'update_time' => $this->update_time, 'country' => $this->country, 'state' => $this->state, 'city' => $this->city]);
     $query->andFilterWhere(['like', 'star_id', $this->star_id])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'currency', $this->currency])->andFilterWhere(['like', 'props', $this->props])->andFilterWhere(['like', 'props_name', $this->props_name])->andFilterWhere(['like', 'desc', $this->desc])->andFilterWhere(['like', 'language', $this->language]);
     return $dataProvider;
 }
コード例 #4
0
ファイル: ItemController.php プロジェクト: ASDAFF/OurYincart2
 public function actionList()
 {
     $catalog = Yii::$app->request->get('catalog');
     $items = Item::getItemsByCategory($catalog);
     $categories = Tree::getCategoriesById($catalog);
     if ($items && $categories) {
         $pages = new Pagination(['totalCount' => $items->count(), 'pageSize' => '3']);
         $items = $items->offset($pages->offset)->limit($pages->limit)->all();
         if ($items) {
             return $this->render('list', ['currentCategory' => Tree::findOne(['id' => $catalog]), 'categories' => $categories, 'items' => $items, 'pages' => $pages]);
         }
     }
     return $this->render('//site/error', ['name' => 'catalog', 'message' => 'There is no product']);
 }
コード例 #5
0
ファイル: PropImg.php プロジェクト: shuangjie/galaxy
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getItem()
 {
     return $this->hasOne(Item::className(), ['item_id' => 'item_id']);
 }
コード例 #6
0
ファイル: ShoppingCart.php プロジェクト: shuangjie/galaxy
 /**
  * @param $event CartEvent
  */
 public function validate($event)
 {
     //@TODO need to move to cart model the have error message
     $sku = Sku::find()->where($event->item_id)->one();
     if (!$sku) {
         $event->isValid = false;
         return;
     }
     $item = Item::find()->where($sku->item_id)->one();
     if (!$item || intval($event->qty) != $event->qty) {
         $event->isValid = false;
         return;
     }
     if ($event->qty <= 0) {
         $event->isValid = false;
         return;
     }
 }
コード例 #7
0
ファイル: index.php プロジェクト: ASDAFF/OurYincart2
<!--                <img src="--><?//= $link ?><!--/images/slider_layer_img.png" alt="" class="m_bottom_5">-->
<!---->
<!--                <div class="color_light slider_title tt_uppercase t_align_c m_bottom_60 m_sm_bottom_20"><b-->
<!--                        class="color_dark">up to 70% off</b></div>-->
<!--                <a href="#" role="button"-->
<!--                   class="d_sm_inline_b button_type_4 bg_scheme_color color_light r_corners tt_uppercase tr_all_hover">Shop-->
<!--                    Now</a>-->
<!--            </div>-->
        </div>
    </div>

    <!--products-->
    <section class="products_container clearfix m_bottom_25 m_sm_bottom_15">
        <!--product item-->
        <?php 
$items = \star\catalog\models\Item::find()->limit(12)->all();
if ($items) {
    /** @var \star\catalog\models\Item $item */
    foreach ($items as $key => $item) {
        ?>
                <div class="product_item featured">
                    <figure class="r_corners photoframe shadow relative animate_ftb long">
                        <!--product preview-->
                        <a href="<?php 
        echo Url::to(['/catalog/home/item/view', 'id' => $item->item_id]);
        ?>
" class="d_block relative pp_wrap">
                            <img src="<?php 
        echo $link;
        ?>
/images/product_img_2.jpg" class="tr_all_hover" alt="">
コード例 #8
0
ファイル: index.php プロジェクト: shuangjie/galaxy
    <div class="container">
    <h2 class="tt_uppercase m_bottom_20 color_dark heading1 animate_ftr">商品展示</h2>
    <!--filter navigation of products-->
    <ul class="horizontal_list clearfix tt_uppercase isotope_menu f_size_ex_large">
        <li class="active m_right_5 m_bottom_10 m_xs_bottom_5 animate_ftr"><button class="button_type_2 bg_light_color_1 r_corners tr_delay_hover tt_uppercase box_s_none" data-filter="*">所有</button></li>
        <li class="m_right_5 m_bottom_10 m_xs_bottom_5 animate_ftr"><button class="button_type_2 bg_light_color_1 r_corners tr_delay_hover tt_uppercase box_s_none" data-filter=".hot">热卖</button></li>
        <li class="m_right_5 m_bottom_10 m_xs_bottom_5 animate_ftr"><button class="button_type_2 bg_light_color_1 r_corners tr_delay_hover tt_uppercase box_s_none" data-filter=".new">新品</button></li>
        <li class="m_right_5 m_bottom_10 m_xs_bottom_5 animate_ftr"><button class="button_type_2 bg_light_color_1 r_corners tr_delay_hover tt_uppercase box_s_none" data-filter=".best">精品</button></li>
        <li class="m_right_5 m_bottom_10 m_xs_bottom_5 animate_ftr"><button class="button_type_2 bg_light_color_1 r_corners tr_delay_hover tt_uppercase box_s_none" data-filter=".promote">促销</button></li>
    </ul>
    <!--products-->
    <section class="products_container clearfix m_bottom_25 m_sm_bottom_15">

    <!--product item-->
    <?php 
$items = \star\catalog\models\Item::find()->where(['is_show' => 1])->limit(12)->all();
if ($items) {
    /** @var \star\catalog\models\Item $item */
    foreach ($items as $key => $item) {
        ?>
            <div class="product_item <?php 
        echo $item->is_hot ? 'hot' : '';
        ?>
 <?php 
        echo $item->is_new ? 'new' : '';
        ?>
 <?php 
        echo $item->is_best ? 'best' : '';
        ?>
 <?php 
        echo $item->is_promote ? 'promote' : '';
コード例 #9
0
ファイル: ItemController.php プロジェクト: shuangjie/galaxy
 public function actionItemProps($category_id, $item_id = 0, $tree_id)
 {
     $itemProp = Yii::createObject(ItemProp::className());
     $itemProps = $itemProp::findAll(['category_id' => $category_id]);
     $item = Yii::createObject(Item::className());
     $model = $item::findOne(['item_id' => $item_id]);
     return $this->renderPartial('_form_prop', array('itemProps' => $itemProps, 'model' => $model, 'tree_id' => $tree_id));
 }
コード例 #10
0
 public function actionIndex()
 {
     $itemModels = Item::find()->where(['in', 'item_id', $_POST['itemId']])->all();
     return $this->render('compare', ['itemModels' => $itemModels]);
 }