コード例 #1
0
ファイル: CategoryObject.php プロジェクト: nanodesu88/easyii
 /**
  * @param array $options
  * @return Item[]
  */
 public function items($options = [])
 {
     if (!$this->_items) {
         $this->_items = [];
         $query = Item::find()->with('seo')->where(['category_id' => $this->id]);
         //->status(Item::STATUS_ON);
         if (!empty($options['where'])) {
             $query->andFilterWhere($options['where']);
         }
         if (!empty($options['orderBy'])) {
             // $query->orderBy($options['orderBy']);
         } else {
             $query->getSortBehavior()->sort();
             //$query->sortDate();
         }
         if (!empty($options['filters'])) {
             $query = Catalog::applyFilters($options['filters'], $query);
         }
         $this->_adp = new ActiveDataProvider(['query' => $query, 'pagination' => !empty($options['pagination']) ? $options['pagination'] : []]);
         // var_dump($query->createCommand()); die;
         foreach ($this->_adp->models as $model) {
             $this->_items[] = $model;
         }
     }
     return $this->_items;
 }
コード例 #2
0
 public function actionView($slug)
 {
     $item = Catalog::get($slug);
     if (!$item) {
         throw new NotFoundHttpException('Item not found.');
     }
     return $this->render('view', ['item' => $item, 'addToCartForm' => new \app\models\AddToCartForm()]);
 }
コード例 #3
0
 public function actionCatalog()
 {
     if (Yii::$app->request->get('slug')) {
         $item = Catalog::get(Yii::$app->request->get('slug'));
         return $this->render('catalog-item', ['item' => $item]);
     }
     $items = Catalog::items();
     return $this->render('catalog-list', ['items' => $items]);
 }
コード例 #4
0
 public function actionProducts($slug = 'products')
 {
     $filterForm = new GadgetsFilterForm();
     $cat = Catalog::cat($slug);
     if (!$cat) {
         throw new NotFoundHttpException('Shop category not found.');
     }
     $filters = null;
     if ($filterForm->load(Yii::$app->request->get()) && $filterForm->validate()) {
         $filters = $filterForm->parse();
     }
     return $this->render('cat', ['cat' => $cat, 'items' => $cat->items(['pagination' => ['pageSize' => 2], 'filters' => $filters]), 'filterForm' => $filterForm]);
 }
コード例 #5
0
 public function actionAdd($id)
 {
     $item = Catalog::get($id);
     if (!$item) {
         throw new NotFoundHttpException('Item not found');
     }
     $form = new AddToCartForm();
     $success = 0;
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
         $response = Shopcart::add($item->id, $form->count, $form->color);
         $success = $response['result'] == 'success' ? 1 : 0;
     }
     return $this->redirect(Yii::$app->request->referrer . '?' . AddToCartForm::SUCCESS_VAR . '=' . $success);
 }
コード例 #6
0
 public function actionSearch()
 {
     $text = filter_var($_REQUEST['text'], FILTER_SANITIZE_STRING);
     if (Yii::$app->language == 'en') {
         $items = \yii\easyii\modules\catalog\api\Catalog::items(['where' => ['or', ['like', 'title', $text], ['like', 'description', $text]]]);
     } else {
         $slug = 'products';
         $cat = \yii\easyii\modules\catalog\api\Catalog::cat($slug);
         $itemsData = $cat->items();
         foreach ($itemsData as $item) {
             if (strpos($item->title, $text) !== false or strpos($item->description, $text) !== false) {
                 $items[] = $item;
             }
         }
     }
     return $this->render('search', ['text' => $text, 'items' => $items]);
 }
コード例 #7
0
 public function actionAdd($id = null)
 {
     $id = $_POST['AddToCartForm']['id'];
     $item = Catalog::get($id);
     if (!$item) {
         throw new NotFoundHttpException('Item not found');
     }
     $form = new AddToCartForm();
     $success = 0;
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
         $response = Shopcart::add($item->id, $form->count, $form->color);
         $success = $response['result'] == 'success' ? 1 : 0;
     }
     return '<h4 class="text-success"><i class="glyphicon glyphicon-ok"></i>' . Yii::t('easyii', 'Added to cart') . '</h4>';
     //        $url = Yii::$app->request->referrer ;
     //            if (strpos($url,'?') !== false) {
     //             $url=$url.'&';
     //            }else{
     //                $url=$url.'?';
     //            }
     //            $fullurl=$url.AddToCartForm::SUCCESS_VAR.'='.$success .'&id='.$id;
     //  echo("<script>location.href = '".$fullurl."';</script>");
     // return $this->redirect($url.AddToCartForm::SUCCESS_VAR.'='.$success .'&id='.$id);
 }
コード例 #8
0
ファイル: index.php プロジェクト: engmohamedamer/gotest
        <ul>
            <?php 
foreach (Catalog::tree() as $node) {
    echo renderNode($node);
}
?>
        </ul>
    </div>
    <div class="col-md-4">
        <?php 
echo $this->render('_search_form', ['text' => '']);
?>

        <h4>Last items</h4>
        <?php 
foreach (Catalog::last(3) as $item) {
    ?>
            <p>
                <?php 
    //= Html::img($item->thumb(30))
    ?>
                <?php 
    echo Html::a(Html::img($item->thumb(30)), ['/shop/view', 'slug' => $item->slug]);
    ?>
<br/>


                <?php 
    echo Html::a($item->title, ['/shop/view', 'slug' => $item->slug]);
    ?>
<br/>
コード例 #9
0
 public function actionViewOnline($slug = null)
 {
     $item = Catalog::get($slug);
     if (!$item) {
         throw new NotFoundHttpException('Item not found.');
     }
     if (\Yii::$app->language == 'en') {
         $product_image = $item->image;
     } else {
         $product_image = $item->image_ar;
     }
     //og tags
     $this->view->params['metatitle'] = $item->og_title;
     $this->view->params['metaimage'] = "http://" . $_SERVER['SERVER_NAME'] . $product_image;
     $this->view->params['metadesc'] = strip_tags($item->og_desc);
     //meta tags
     $this->view->params['meta_title'] = $item->meta_title;
     $this->view->params['meta_keyword'] = strip_tags($item->meta_keyword);
     $this->view->params['meta_description'] = strip_tags($item->meta_desc);
     $cat = Catalog::cat('products');
     return $this->render('viewonline', ['item' => $item, 'addToCartForm' => new \app\models\AddToCartForm(), 'products' => $cat->items()]);
 }
コード例 #10
0
 public function actionViewOnline($slug = null)
 {
     $item = Catalog::get($slug);
     if (!$item) {
         throw new NotFoundHttpException('Item not found.');
     }
     $cat = Catalog::cat('products');
     return $this->render('viewonline', ['item' => $item, 'addToCartForm' => new \app\models\AddToCartForm(), 'products' => $cat->items()]);
 }
コード例 #11
0
ファイル: view.php プロジェクト: Brother-Simon/easyii-shop
        <?php 
if (count($item->photos)) {
    ?>
            <br/><br/>
            <div>
                <?php 
    foreach ($item->photos as $photo) {
        ?>
                    <?php 
        echo $photo->box(null, 100);
        ?>
                <?php 
    }
    ?>
                <?php 
    Catalog::plugin();
    ?>
            </div>
        <?php 
}
?>
    </div>
    <div class="col-md-8">
        <div class="row">
            <div class="col-md-8">
                <h2>
                    <span class="label label-warning"><?php 
echo $item->price;
?>
$</span>
                    <?php 
コード例 #12
0
ファイル: tours.php プロジェクト: egor-pisarev/altodis
use yii\easyii\modules\catalog\api\Catalog;
?>

<section id="popular-tracks">
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <h2>Популярные <a href="#">туры</a></h2>
            </div>
        </div>
    </div>
    <ul id="works-grid" class="works-grid works-grid-gut works-grid-3 works-hover-w">

        <?php 
foreach (Catalog::items(['pagination' => ['pageSize' => 6]]) as $item) {
    ?>

        <!-- Portfolio item start -->
        <li class="work-item illustration webdesign">
            <a href="/site/catalog?slug=<?php 
    echo $item->slug;
    ?>
">
                <div class="title">
                    <?php 
    echo $item->title;
    ?>
                </div>
                <div class="work-image">
                    <img src="<?php 
コード例 #13
0
ファイル: ItemObject.php プロジェクト: nanodesu88/easyii
 public function getCat()
 {
     return Catalog::cats()[$this->category_id];
 }
コード例 #14
0
ファイル: search.php プロジェクト: engmohamedamer/gotest
<div class="row">
    <div class="col-md-8">
        <?php 
if (count($items)) {
    ?>
            <?php 
    foreach ($items as $item) {
        ?>
                <?php 
        echo $this->render('_item', ['item' => $item]);
        ?>
            <?php 
    }
    ?>
            <?php 
    echo Catalog::pages();
    ?>
        <?php 
} else {
    ?>
            <p>No items found</p>
        <?php 
}
?>
    </div>
    <div class="col-md-4"></div>
</div>