public function actionIndex($lang = null, $path = null)
 {
     $categoryIds = [];
     /** @var $category CategoryRecord*/
     $category = null;
     if (empty($path)) {
         $categoryList = CategoryRecord::find()->select('id')->lang($lang)->all();
         foreach ($categoryList as $categoryItem) {
             $categoryIds[] = $categoryItem->id;
         }
     } else {
         $categoryModel = new CategoryRecord();
         $category = $categoryModel->findByFullPath($path);
         if (!$category) {
             throw new HttpException(404, 'Категория не найдена');
         }
         $categoryList = $category->childrens();
         $categoryIds[] = $category->id;
         foreach ($categoryList as $categoryItem) {
             $categoryIds[] = $categoryItem->id;
         }
     }
     $productList = ProductRecord::find()->lang($lang)->andWhere(['categoryId' => $categoryIds])->all();
     $template = $category->templateList ? $category->templateList : 'default';
     return $this->render('index/' . $template, ['category' => $category, 'productList' => $productList]);
 }
Esempio n. 2
0
 public static function getFirstLink($alias)
 {
     if (!empty(self::$firstLink[$alias])) {
         return self::$firstLink[$alias];
     }
     $modelRecord = new CategoryRecord();
     $model = $modelRecord->findByFullPath($alias);
     if (!$model) {
         return null;
     }
     self::$firstLink[$alias] = $model->url;
     return self::getFirstLink($alias);
 }
Esempio n. 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CategoryRecord::find()->lang();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parentId' => $this->parentId]);
     $query->andFilterWhere(['like', 'lang', $this->lang])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'metaKeywords', $this->metaKeywords])->andFilterWhere(['like', 'metaDescription', $this->metaDescription]);
     return $dataProvider;
 }
Esempio n. 4
0
 public function getParent()
 {
     return $this->hasOne(CategoryRecord::className(), ['id' => 'categoryId'])->lang();
 }
Esempio n. 5
0
<?php

use yii\jui\Accordion;
/* @var $this yii\web\View */
/* @var $model app\modules\catalog\models\ProductRecord */
/* @var $form yii\widgets\ActiveForm */
$category = \app\modules\catalog\models\CategoryRecord::find()->one();
?>

<div class="product-record-form">

    <div class="well">
        <div class="row">

            <div class="col-md-6">
                <?php 
echo $form->field($model, '[' . $k . ']title')->textInput(['maxlength' => true]);
?>
                <?php 
echo $form->field($model, '[' . $k . ']kolvoKomnat')->textInput();
?>
            </div>
            <?php 
if ($model->isCurrentLang()) {
    ?>
            <div class="col-md-6">
                <?php 
    echo $form->field($model, '[' . $k . ']alias')->textInput(['maxlength' => true]);
    ?>
            </div>
            <?php 
Esempio n. 6
0
 public function run()
 {
     $categoryList = CategoryRecord::find()->lang(\Yii::$app->language)->andWhere(['parentId' => '0'])->all();
     return $this->render($this->template, ['categoryList' => $categoryList]);
 }
Esempio n. 7
0
 public function getCategory()
 {
     return $this->hasOne(CategoryRecord::className(), ['id' => 'categoryId'])->andWhere(['lang' => Yii::$app->language]);
 }
Esempio n. 8
0
<div class="main-wraper">
    <div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-8 col-sm-offset-2">
                <div class="second-title">
                    <h4 class="subtitle color-dr-blue-2 underline">Апартаменты</h4>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="swiper-container pad-15" data-autoplay="0" data-loop="0" data-speed="1000"
                 data-slides-per-view="responsive" data-mob-slides="1" data-xs-slides="2" data-sm-slides="2"
                 data-md-slides="3" data-lg-slides="4" data-add-slides="4">
                <div class="swiper-wrapper">
                    <?php 
foreach (\app\modules\catalog\models\CategoryRecord::getProductsFullPath('appartments') as $item) {
    ?>
                        <div class="swiper-slide">
                            <div class="hotel-item style-6">
                                <div class="radius-top">
                                    <img src="<?php 
    echo $item->imageSrc('450x250', \yii\image\drivers\Image::CROP);
    ?>
" alt="">
                                </div>
                                <div class="title">

                                    <h4><b><?php 
    echo $item->title;
    ?>
</b></h4>
Esempio n. 9
0
 /**
  * @param $alias
  * @return ProductRecord[]
  */
 public static function getProductsFullPath($alias, $limit = 12)
 {
     $model = new CategoryRecord();
     return $model->getProducts($alias, $limit, \Yii::$app->language);
 }
Esempio n. 10
0
                                    </a>
                                </li>
                                <li>
                                    <a href="<?php 
echo CategoryRecord::getFirstLink('parfyumirovannaya-kosmetika/castle-forbes');
?>
" title=""><img
                                            src="<?php 
echo $this->theme->getUrl('assets/images/offer-banner4.jpg');
?>
" alt="">
                                    </a>
                                </li>
                                <li>
                                    <a href="<?php 
echo CategoryRecord::getFirstLink('parfyumirovannaya-kosmetika/castle-forbes');
?>
" title=""><img
                                            src="<?php 
echo $this->theme->getUrl('assets/images/offer-banner4.jpg');
?>
" alt="">
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>