Example #1
0
 public function actionList($id)
 {
     $model = CarouselCatalog::findOne($id);
     if ($model === null) {
         $this->flash('error', Yii::t('easyii', 'Not found'));
         return $this->redirect(['/admin/' . $this->module->id]);
     }
     if (Yii::$app->request->post('save')) {
         $items = [];
         foreach (Yii::$app->request->post('Items', []) as $itemData) {
             $item = Json::decode($itemData, false);
             if ($item === null || empty($item->item_id) || !($item->item_id = trim($item->item_id))) {
                 continue;
             }
             $items[] = $item->item_id;
         }
         $model->items = $items;
         if ($model->save()) {
             $this->flash('success', Yii::t('easyii/carouselcatalog', 'Item updated'));
         } else {
             $this->flash('error', Yii::t('easyii', 'Update error. {0}', $model->formatErrors()));
         }
         return $this->refresh();
     } else {
         $items = Item::find()->where(['not in', 'item_id', $model->items])->all();
         $already = Item::find()->where(['in', 'item_id', $model->items])->orderBy(['FIELD(item_id, ' . join(', ', $model->items) . ')' => ''])->all();
         foreach ($already as &$_already) {
             $_already = new ItemObject($_already);
         }
         foreach ($items as &$item) {
             $item = new ItemObject($item);
         }
     }
     return $this->render('list', ['model' => $model, 'items' => $items, 'already' => $already]);
 }
Example #2
0
 /**
  * @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;
 }
Example #3
0
 public function actionIndex2()
 {
     $items = Item::find()->all();
     foreach ($items as $index => $item) {
         /** @var Item $item */
         echo "{$index}/" . (count($items) - 1) . PHP_EOL;
         $itemObject = new ItemObject($item);
         $item->getFieldManager()->getValueField('divan-common', 'title')->setValue($item->title);
         $item->getFieldManager()->getValueField('divan-common', 'description')->setValue($itemObject->getDescription());
         $item->getFieldManager()->getValueField('divan-common', 'price')->setValue($item->price);
         $item->getFieldManager()->getValueField('divan-common', 'price-old')->setValue($item->old_price);
         $item->getFieldManager()->save();
     }
 }
Example #4
0
 public function getRelated()
 {
     $id = [];
     foreach ($this->model->related as $related) {
         $id[] = $related->item_id;
     }
     if (count($id) > 0) {
         $query = Item::find()->status(Item::STATUS_ON)->where(['in', 'item_id', $id])->limit(2);
         $result = [];
         foreach ($query->all() as $item) {
             $result[] = new ItemObject($item);
         }
         return $result;
     }
     return [];
 }
 public function insertCatalog()
 {
     if (catalog\models\Category::find()->count()) {
         return '`<b>' . catalog\models\Category::tableName() . '</b>` table is not empty, skipping...';
     }
     $this->db->createCommand('TRUNCATE TABLE `' . catalog\models\Category::tableName() . '`')->query();
     $fields = [['name' => 'brand', 'title' => 'Brand', 'type' => 'select', 'options' => ['Samsung', 'Apple', 'Nokia']], ['name' => 'storage', 'title' => 'Storage', 'type' => 'string', 'options' => ''], ['name' => 'touchscreen', 'title' => 'Touchscreen', 'type' => 'boolean', 'options' => ''], ['name' => 'cpu', 'title' => 'CPU cores', 'type' => 'select', 'options' => ['1', '2', '4', '8']], ['name' => 'features', 'title' => 'Features', 'type' => 'checkbox', 'options' => ['Wi-fi', '4G', 'GPS']], ['name' => 'color', 'title' => 'Color', 'type' => 'checkbox', 'options' => ['White', 'Black', 'Red', 'Blue']]];
     $root = new catalog\models\Category(['title' => 'Gadgets', 'fields' => $fields]);
     $root->makeRoot();
     $cat1 = new catalog\models\Category(['title' => 'Smartphones', 'fields' => $fields]);
     $cat1->appendTo($root);
     $this->attachSeo($cat1, 'Smartphones H1', 'Extended smartphones title');
     $cat2 = new catalog\models\Category(['title' => 'Tablets', 'fields' => $fields]);
     $cat2->appendTo($root);
     $this->attachSeo($cat2, 'Tablets H1', 'Extended tablets title');
     if (catalog\models\Item::find()->count()) {
         return '`<b>' . catalog\models\Item::tableName() . '</b>` table is not empty, skipping...';
     }
     $time = time();
     $item1 = new catalog\models\Item(['category_id' => $cat1->primaryKey, 'title' => 'Nokia 3310', 'description' => '<h3>The legend</h3><p>The Nokia 3310 is a GSMmobile phone announced on September 1, 2000, and released in the fourth quarter of the year, replacing the popular Nokia 3210. The phone sold extremely well, being one of the most successful phones with 126 million units sold worldwide.&nbsp;The phone has since received a cult status and is still widely acclaimed today.</p><p>The 3310 was developed at the Copenhagen Nokia site in Denmark. It is a compact and sturdy phone featuring an 84 × 48 pixel pure monochrome display. It has a lighter 115 g battery variant which has fewer features; for example the 133 g battery version has the start-up image of two hands touching while the 115 g version does not. It is a slightly rounded rectangular unit that is typically held in the palm of a hand, with the buttons operated with the thumb. The blue button is the main button for selecting options, with "C" button as a "back" or "undo" button. Up and down buttons are used for navigation purposes. The on/off/profile button is a stiff black button located on the top of the phone.</p>', 'available' => 5, 'discount' => 0, 'price' => 100, 'data' => ['brand' => 'Nokia', 'storage' => '1', 'touchscreen' => '0', 'cpu' => 1, 'color' => ['White', 'Red', 'Blue']], 'image' => '/uploads/catalog/3310.jpg', 'time' => $time]);
     $item1->save();
     $this->attachPhotos($item1, ['/uploads/photos/3310-1.jpg', '/uploads/photos/3310-2.jpg']);
     $this->attachSeo($item1, 'Nokia 3310');
     $item2 = new catalog\models\Item(['category_id' => $cat1->primaryKey, 'title' => 'Galaxy S6', 'description' => '<h3>Next is beautifully crafted</h3><p>With their slim, seamless, full metal and glass construction, the sleek, ultra thin edged Galaxy S6 and unique, dual curved Galaxy S6 edge are crafted from the finest materials.</p><p>And while they may be the thinnest smartphones we`ve ever created, when it comes to cutting-edge technology and flagship Galaxy experience, these 5.1" QHD Super AMOLED smartphones are certainly no lightweights.</p>', 'available' => 1, 'discount' => 10, 'price' => 1000, 'data' => ['brand' => 'Samsung', 'storage' => '32', 'touchscreen' => '1', 'cpu' => 8, 'features' => ['Wi-fi', 'GPS']], 'image' => '/uploads/catalog/galaxy.jpg', 'time' => $time - 86400]);
     $item2->save();
     $this->attachPhotos($item2, ['/uploads/photos/galaxy-1.jpg', '/uploads/photos/galaxy-2.jpg', '/uploads/photos/galaxy-3.jpg', '/uploads/photos/galaxy-4.jpg']);
     $this->attachSeo($item2, 'Samsung Galaxy S6');
     $item3 = new catalog\models\Item(['category_id' => $cat1->primaryKey, 'title' => 'Iphone 6', 'description' => '<h3>Next is beautifully crafted</h3><p>With their slim, seamless, full metal and glass construction, the sleek, ultra thin edged Galaxy S6 and unique, dual curved Galaxy S6 edge are crafted from the finest materials.</p><p>And while they may be the thinnest smartphones we`ve ever created, when it comes to cutting-edge technology and flagship Galaxy experience, these 5.1" QHD Super AMOLED smartphones are certainly no lightweights.</p>', 'available' => 0, 'discount' => 10, 'price' => 1100, 'data' => ['brand' => 'Apple', 'storage' => '64', 'touchscreen' => '1', 'cpu' => 4, 'features' => ['Wi-fi', '4G', 'GPS']], 'image' => '/uploads/catalog/iphone.jpg', 'time' => $time - 86400 * 2]);
     $item3->save();
     $this->attachPhotos($item3, ['/uploads/photos/iphone-1.jpg', '/uploads/photos/iphone-2.jpg', '/uploads/photos/iphone-3.jpg', '/uploads/photos/iphone-4.jpg']);
     $this->attachSeo($item3, 'Apple Iphone 6');
     return 'Catalog data inserted.';
 }
Example #6
0
 public function getServices()
 {
     $model = \yii\easyii\modules\catalog\models\Item::find()->all();
     $listData = ArrayHelper::map($model, 'item_id', 'title');
     return $listData;
 }
Example #7
0
 private function findItem($id_slug)
 {
     if (!($item = Item::find()->where(['or', 'item_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->one())) {
         return null;
     }
     $itemObject = $this->parseItem($item);
     $itemObject->photos = $this->parsePhotos($item->photos);
     $itemObject->seo_h1 = $item->seo_h1;
     $itemObject->seo_title = $item->seo_title;
     $itemObject->seo_keywords = $item->seo_keywords;
     $itemObject->seo_description = $item->seo_description;
     return $itemObject;
 }
Example #8
0
<?php

use yii\easyii\modules\article\api\Article;
use yii\easyii\modules\carousel\api\Carousel;
use yii\easyii\modules\gallery\api\Gallery;
use yii\easyii\modules\guestbook\api\Guestbook;
use yii\easyii\modules\news\api\News;
use yii\easyii\modules\page\api\Page;
use yii\easyii\modules\text\api\Text;
use yii\helpers\Html;
use yii\easyii\models\Setting;
$page = Page::get('about');
$this->title = yii::t('easyii', 'Dry Site Map');
$products = \yii\easyii\modules\catalog\models\Item::find()->where('category_id =2')->all();
?>

<div class="content">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <h2 class="title"><?php 
echo yii::t('easyii', 'site map');
?>
 </h2>
            </div>
        </div>
        <div class="row">
            <div class="site-map center-block">
                <a href="/"><i class="fa fa-circle"></i> <?php 
echo yii::t('easyii', 'home');
?>
Example #9
0
 private function findItem($id_slug)
 {
     if (is_numeric($id_slug)) {
         $item = Item::find()->where('item_id=:id_slug', [':id_slug' => $id_slug])->status(Item::STATUS_ON)->one();
     } else {
         $item = Item::find()->where('slug=:id_slug', [':id_slug' => $id_slug])->status(Item::STATUS_ON)->one();
     }
     /* asline
             if(!($item = Item::find()->where(['or', 'item_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->status(Item::STATUS_ON)->one())){
                 return null;
             }
     */
     if (!$item) {
         return null;
     } else {
         return new ItemObject($item);
     }
 }
Example #10
0
 private function findItem($id_slug)
 {
     if (!($item = Item::find()->where(['or', 'item_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->status(Item::STATUS_ON)->one())) {
         return null;
     }
     return new ItemObject($item);
 }