Commit 8950fac099ac662bc9b6cc2259e84586c11f9ba3
Merge remote-tracking branch 'origin/master'
Showing
16 changed files
with
770 additions
and
526 deletions
Show diff stats
backend/views/brand/_form.php
| @@ -84,6 +84,8 @@ | @@ -84,6 +84,8 @@ | ||
| 84 | 84 | ||
| 85 | <?= $form->field($model, 'in_menu') | 85 | <?= $form->field($model, 'in_menu') |
| 86 | ->checkbox() ?> | 86 | ->checkbox() ?> |
| 87 | + | ||
| 88 | + <?= $form->field($model, 'sort') ?> | ||
| 87 | 89 | ||
| 88 | <div class="form-group"> | 90 | <div class="form-group"> |
| 89 | <?= Html::submitButton( | 91 | <?= Html::submitButton( |
backend/views/category/_form.php
| @@ -69,6 +69,8 @@ use kartik\select2\Select2; | @@ -69,6 +69,8 @@ use kartik\select2\Select2; | ||
| 69 | 69 | ||
| 70 | <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?> | 70 | <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?> |
| 71 | 71 | ||
| 72 | + <?= $form->field($model, 'sort') ?> | ||
| 73 | + | ||
| 72 | <?= $form->field($model, 'seo_text')->widget(CKEditor::className(), | 74 | <?= $form->field($model, 'seo_text')->widget(CKEditor::className(), |
| 73 | [ | 75 | [ |
| 74 | 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[ | 76 | 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[ |
common/modules/product/models/Brand.php
| @@ -19,6 +19,7 @@ | @@ -19,6 +19,7 @@ | ||
| 19 | * @property string $seo_text | 19 | * @property string $seo_text |
| 20 | * @property string $name | 20 | * @property string $name |
| 21 | * @property string $description | 21 | * @property string $description |
| 22 | + * @property integer $sort | ||
| 22 | * @property Product[] $products | 23 | * @property Product[] $products |
| 23 | */ | 24 | */ |
| 24 | class Brand extends ActiveRecord | 25 | class Brand extends ActiveRecord |
| @@ -74,7 +75,10 @@ | @@ -74,7 +75,10 @@ | ||
| 74 | 'string', | 75 | 'string', |
| 75 | ], | 76 | ], |
| 76 | [ | 77 | [ |
| 77 | - [ 'brand_name_id' ], | 78 | + [ |
| 79 | + 'brand_name_id', | ||
| 80 | + 'sort', | ||
| 81 | + ], | ||
| 78 | 'integer', | 82 | 'integer', |
| 79 | ], | 83 | ], |
| 80 | [ | 84 | [ |
| @@ -139,6 +143,7 @@ | @@ -139,6 +143,7 @@ | ||
| 139 | 'seo_text' => Yii::t('product', 'Seo Text'), | 143 | 'seo_text' => Yii::t('product', 'Seo Text'), |
| 140 | 'in_menu' => Yii::t('product', 'Выводить в меню'), | 144 | 'in_menu' => Yii::t('product', 'Выводить в меню'), |
| 141 | 'description' => Yii::t('product', 'Описание'), | 145 | 'description' => Yii::t('product', 'Описание'), |
| 146 | + 'sort' => Yii::t('product', 'Порядок'), | ||
| 142 | ]; | 147 | ]; |
| 143 | } | 148 | } |
| 144 | 149 | ||
| @@ -152,12 +157,12 @@ | @@ -152,12 +157,12 @@ | ||
| 152 | 157 | ||
| 153 | public function getImageFile() | 158 | public function getImageFile() |
| 154 | { | 159 | { |
| 155 | - return empty($this->image) ? NULL : '/storage/brands/' . $this->image; | 160 | + return empty($this->image) ? null : '/storage/brands/' . $this->image; |
| 156 | } | 161 | } |
| 157 | 162 | ||
| 158 | public function getImageUrl() | 163 | public function getImageUrl() |
| 159 | { | 164 | { |
| 160 | - return empty($this->image) ? NULL : '/storage/brands/' . $this->image; | 165 | + return empty($this->image) ? null : '/storage/brands/' . $this->image; |
| 161 | } | 166 | } |
| 162 | 167 | ||
| 163 | } | 168 | } |
common/modules/product/models/Category.php
| @@ -18,6 +18,7 @@ use common\behaviors\Slug; | @@ -18,6 +18,7 @@ use common\behaviors\Slug; | ||
| 18 | * @property integer $category_id | 18 | * @property integer $category_id |
| 19 | * @property string $remote_id | 19 | * @property string $remote_id |
| 20 | * @property integer $parent_id | 20 | * @property integer $parent_id |
| 21 | + * @property integer $sort | ||
| 21 | * @property string $path | 22 | * @property string $path |
| 22 | * @property integer $depth | 23 | * @property integer $depth |
| 23 | * @property string $image | 24 | * @property string $image |
| @@ -76,7 +77,7 @@ class Category extends \yii\db\ActiveRecord | @@ -76,7 +77,7 @@ class Category extends \yii\db\ActiveRecord | ||
| 76 | { | 77 | { |
| 77 | return [ | 78 | return [ |
| 78 | [['name'], 'string'], | 79 | [['name'], 'string'], |
| 79 | - [['parent_id', 'depth', 'category_name_id', 'product_unit_id'], 'integer'], | 80 | + [['parent_id', 'depth', 'category_name_id', 'product_unit_id', 'sort'], 'integer'], |
| 80 | [['path', 'meta_desc', 'h1', 'seo_text'], 'string'], | 81 | [['path', 'meta_desc', 'h1', 'seo_text'], 'string'], |
| 81 | [['meta_title', 'image', 'synonym'], 'string', 'max' => 255], | 82 | [['meta_title', 'image', 'synonym'], 'string', 'max' => 255], |
| 82 | [['meta_robots'], 'string', 'max' => 50], | 83 | [['meta_robots'], 'string', 'max' => 50], |
| @@ -110,6 +111,7 @@ class Category extends \yii\db\ActiveRecord | @@ -110,6 +111,7 @@ class Category extends \yii\db\ActiveRecord | ||
| 110 | 'name' => Yii::t('product', 'Name'), | 111 | 'name' => Yii::t('product', 'Name'), |
| 111 | 'remote_id' => Yii::t('product', 'Remote ID'), | 112 | 'remote_id' => Yii::t('product', 'Remote ID'), |
| 112 | 'synonym' => Yii::t('product', 'Синоним'), | 113 | 'synonym' => Yii::t('product', 'Синоним'), |
| 114 | + 'sort' => Yii::t('product', 'Порядок') | ||
| 113 | ]; | 115 | ]; |
| 114 | } | 116 | } |
| 115 | 117 |
common/modules/product/views/variant/_form.php
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | -use common\modules\product\models\Stock; | ||
| 4 | -use yii\helpers\Html; | ||
| 5 | -use yii\web\View; | ||
| 6 | -use yii\widgets\ActiveForm; | ||
| 7 | -use yii\helpers\ArrayHelper; | ||
| 8 | -use wbraganca\dynamicform\DynamicFormWidget; | ||
| 9 | -/* @var $this yii\web\View */ | ||
| 10 | -/* @var $model common\modules\product\models\Product */ | ||
| 11 | -/* @var $form yii\widgets\ActiveForm */ | ||
| 12 | -/* @var $stocks common\modules\product\models\Stock */ | ||
| 13 | - | ||
| 14 | - | ||
| 15 | -$js = ' | 2 | + |
| 3 | + use common\modules\product\models\ProductVariant; | ||
| 4 | + use common\modules\product\models\Stock; | ||
| 5 | + use yii\helpers\Html; | ||
| 6 | + use yii\web\View; | ||
| 7 | + use yii\widgets\ActiveForm; | ||
| 8 | + use yii\helpers\ArrayHelper; | ||
| 9 | + use wbraganca\dynamicform\DynamicFormWidget; | ||
| 10 | + | ||
| 11 | + /** | ||
| 12 | + * @var View $this | ||
| 13 | + * @var ProductVariant $model | ||
| 14 | + * @var ActiveForm $form | ||
| 15 | + * @var Stock $stocks | ||
| 16 | + */ | ||
| 17 | + | ||
| 18 | + $js = ' | ||
| 16 | $(".dynamicform_wrapper").on("beforeInsert", function(e, item) { | 19 | $(".dynamicform_wrapper").on("beforeInsert", function(e, item) { |
| 17 | console.log("beforeInsert"); | 20 | console.log("beforeInsert"); |
| 18 | }); | 21 | }); |
| @@ -36,114 +39,170 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) { | @@ -36,114 +39,170 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) { | ||
| 36 | alert("Limit reached"); | 39 | alert("Limit reached"); |
| 37 | }); | 40 | }); |
| 38 | '; | 41 | '; |
| 39 | - | ||
| 40 | -$this->registerJs($js, View::POS_LOAD); | 42 | + |
| 43 | + $this->registerJs($js, View::POS_LOAD); | ||
| 41 | ?> | 44 | ?> |
| 42 | <div class="product-form"> | 45 | <div class="product-form"> |
| 43 | - | ||
| 44 | - <?php $form = ActiveForm::begin([ | ||
| 45 | - 'id' => 'dynamic-form', | ||
| 46 | - 'options' => ['enctype' => 'multipart/form-data'] | ||
| 47 | - ]); ?> | ||
| 48 | - | ||
| 49 | - <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> | ||
| 50 | - | ||
| 51 | - <?= $form->field($model, 'product_id')->hiddenInput()->label(false); ?> | ||
| 52 | - | ||
| 53 | - <?= $form->field($model, 'sku')->textarea(); ?> | ||
| 54 | - <?= $form->field($model, 'price')->textarea(); ?> | ||
| 55 | - <?= $form->field($model, 'price_old')->textarea(); ?> | ||
| 56 | - <?= $form->field($model, 'image')->widget(\kartik\file\FileInput::classname(), [ | ||
| 57 | - 'model' => $model, | ||
| 58 | - 'attribute' => 'image', | ||
| 59 | - 'options' => [ | ||
| 60 | - 'accept' => 'image/*', | ||
| 61 | - 'multiple' => true | ||
| 62 | - ], | ||
| 63 | - 'pluginOptions' => [ | ||
| 64 | - 'allowedFileExtensions' => ['jpg','gif','png'], | ||
| 65 | - 'initialPreview' => $model->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'products') : '', | ||
| 66 | - 'overwriteInitial' => true, | ||
| 67 | - 'showRemove' => true, | ||
| 68 | - 'showUpload' => false, | ||
| 69 | - ], | ||
| 70 | - ]); ?> | ||
| 71 | - | ||
| 72 | - <?php DynamicFormWidget::begin([ | ||
| 73 | - 'widgetContainer' => 'dynamicform_wrapper', // required: only alphanumeric characters plus "_" [A-Za-z0-9_] | ||
| 74 | - 'widgetBody' => '.container-items', // required: css class selector | ||
| 75 | - 'widgetItem' => '.item', // required: css class | ||
| 76 | - 'limit' => 10, // the maximum times, an element can be added (default 999) | ||
| 77 | - 'min' => 0, // 0 or 1 (default 1) | ||
| 78 | - 'insertButton' => '.add-item', // css class | ||
| 79 | - 'deleteButton' => '.remove-item', // css class | ||
| 80 | - 'model' => $stocks[0], | ||
| 81 | - 'formId' => 'dynamic-form', | ||
| 82 | - 'formFields' => [ | ||
| 83 | - 'quantity', | ||
| 84 | - 'name', | ||
| 85 | - ], | ||
| 86 | - ]); ?> | ||
| 87 | - | ||
| 88 | - <div class="panel panel-default"> | ||
| 89 | - <div class="panel-heading"> | ||
| 90 | - <h4> | ||
| 91 | - <i class="glyphicon glyphicon-envelope"></i> Склады | ||
| 92 | - <button type="button" class="add-item btn btn-success btn-sm pull-right"><i class="glyphicon glyphicon-plus"></i> Add</button> | ||
| 93 | - </h4> | ||
| 94 | - </div> | ||
| 95 | - <div class="panel-body"> | ||
| 96 | - <div class="container-items"><!-- widgetBody --> | ||
| 97 | - <?php foreach ($stocks as $i => $stock): ?> | ||
| 98 | - <div class="item panel panel-default"><!-- widgetItem --> | ||
| 99 | - <div class="panel-body"> | ||
| 100 | - <?php | ||
| 101 | - // necessary for update action. | ||
| 102 | - if (! $stock->isNewRecord) { | ||
| 103 | - echo Html::activeHiddenInput($stock, "[{$i}]stock_id"); | ||
| 104 | - } | ||
| 105 | - ?> | ||
| 106 | - <div class="row"> | ||
| 107 | - <div class="col-sm-5"> | ||
| 108 | - <?= $form->field($stock, "[{$i}]quantity")->textInput(['maxlength' => true]) ?> | ||
| 109 | - </div> | ||
| 110 | - <div class="col-sm-5"> | ||
| 111 | - <?= $form->field($stock, "[{$i}]name")->textInput(['maxlength' => true]) ?> | ||
| 112 | - </div> | ||
| 113 | - <div class="col-sm-2" style="margin-top: 30px"> | ||
| 114 | - <button type="button" class="remove-item btn btn-danger btn-xs"><i class="glyphicon glyphicon-minus"></i></button> | ||
| 115 | - </div> | ||
| 116 | - </div><!-- .row --> | ||
| 117 | - </div> | ||
| 118 | - </div> | ||
| 119 | - <?php endforeach; ?> | ||
| 120 | - </div> | ||
| 121 | - </div> | ||
| 122 | - </div><!-- .panel --> | ||
| 123 | - <?php DynamicFormWidget::end(); ?> | ||
| 124 | - | ||
| 125 | - <?= $form->field($model, 'product_unit_id')->dropDownList( | ||
| 126 | - ArrayHelper::map(\common\modules\product\models\ProductUnit::find()->all(), 'product_unit_id', 'name'), | 46 | + |
| 47 | + <?php $form = ActiveForm::begin( | ||
| 127 | [ | 48 | [ |
| 128 | - 'prompt' => Yii::t('product', 'Unit'), | ||
| 129 | - ])->label(Yii::t('product', 'Unit')) ?> | 49 | + 'id' => 'dynamic-form', |
| 50 | + 'options' => [ 'enctype' => 'multipart/form-data' ], | ||
| 51 | + ] | ||
| 52 | + ); ?> | ||
| 53 | + | ||
| 54 | + <?= $form->field($model, 'name') | ||
| 55 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 56 | + | ||
| 57 | + <?= $form->field($model, 'product_id') | ||
| 58 | + ->hiddenInput() | ||
| 59 | + ->label(false); ?> | ||
| 60 | + | ||
| 61 | + <?= $form->field($model, 'sku') | ||
| 62 | + ->textarea(); ?> | ||
| 63 | + | ||
| 64 | + <?= $form->field($model, 'status') | ||
| 65 | + ->dropDownList( | ||
| 66 | + [ | ||
| 67 | + 0 => 'В наличии / под заказ', | ||
| 68 | + 1 => 'снят с производства', | ||
| 69 | + 2 => 'в ожидании', | ||
| 70 | + ] | ||
| 71 | + )->label('Статус') ?> | ||
| 72 | + | ||
| 73 | + <?= $form->field($model, 'price') | ||
| 74 | + ->textarea(); ?> | ||
| 75 | + <?= $form->field($model, 'price_old') | ||
| 76 | + ->textarea(); ?> | ||
| 77 | + <?= $form->field($model, 'image') | ||
| 78 | + ->widget( | ||
| 79 | + \kartik\file\FileInput::classname(), | ||
| 80 | + [ | ||
| 81 | + 'model' => $model, | ||
| 82 | + 'attribute' => 'image', | ||
| 83 | + 'options' => [ | ||
| 84 | + 'accept' => 'image/*', | ||
| 85 | + 'multiple' => true, | ||
| 86 | + ], | ||
| 87 | + 'pluginOptions' => [ | ||
| 88 | + 'allowedFileExtensions' => [ | ||
| 89 | + 'jpg', | ||
| 90 | + 'gif', | ||
| 91 | + 'png', | ||
| 92 | + ], | ||
| 93 | + 'initialPreview' => $model->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage( | ||
| 94 | + $model->imageUrl, | ||
| 95 | + 'products' | ||
| 96 | + ) : '', | ||
| 97 | + 'overwriteInitial' => true, | ||
| 98 | + 'showRemove' => true, | ||
| 99 | + 'showUpload' => false, | ||
| 100 | + ], | ||
| 101 | + ] | ||
| 102 | + ); ?> | ||
| 130 | 103 | ||
| 131 | - <?php if(isset($groups)) :?> | ||
| 132 | - <?php foreach($groups->all() as $group) :?> | ||
| 133 | - <?= $form->field($model, 'options')->checkboxList( | ||
| 134 | - ArrayHelper::map($group->options, 'tax_option_id', 'ValueRenderFlash'), | 104 | + <?php DynamicFormWidget::begin( |
| 135 | [ | 105 | [ |
| 136 | - 'multiple' => true, | ||
| 137 | - 'unselect' => null, | 106 | + 'widgetContainer' => 'dynamicform_wrapper', |
| 107 | + // required: only alphanumeric characters plus "_" [A-Za-z0-9_] | ||
| 108 | + 'widgetBody' => '.container-items', | ||
| 109 | + // required: css class selector | ||
| 110 | + 'widgetItem' => '.item', | ||
| 111 | + // required: css class | ||
| 112 | + 'limit' => 10, | ||
| 113 | + // the maximum times, an element can be added (default 999) | ||
| 114 | + 'min' => 0, | ||
| 115 | + // 0 or 1 (default 1) | ||
| 116 | + 'insertButton' => '.add-item', | ||
| 117 | + // css class | ||
| 118 | + 'deleteButton' => '.remove-item', | ||
| 119 | + // css class | ||
| 120 | + 'model' => $stocks[ 0 ], | ||
| 121 | + 'formId' => 'dynamic-form', | ||
| 122 | + 'formFields' => [ | ||
| 123 | + 'quantity', | ||
| 124 | + 'name', | ||
| 125 | + ], | ||
| 138 | ] | 126 | ] |
| 139 | - )->label($group->name);?> | ||
| 140 | - <?php endforeach?> | ||
| 141 | - <?php endif?> | ||
| 142 | - | ||
| 143 | - <div class="form-group"> | ||
| 144 | - <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | 127 | + ); ?> |
| 128 | + | ||
| 129 | + <div class="panel panel-default"> | ||
| 130 | + <div class="panel-heading"> | ||
| 131 | + <h4> | ||
| 132 | + <i class="glyphicon glyphicon-envelope"></i> Склады | ||
| 133 | + <button type="button" class="add-item btn btn-success btn-sm pull-right"> | ||
| 134 | + <i class="glyphicon glyphicon-plus"></i> Add | ||
| 135 | + </button> | ||
| 136 | + </h4> | ||
| 145 | </div> | 137 | </div> |
| 146 | - | 138 | + <div class="panel-body"> |
| 139 | + <div class="container-items"><!-- widgetBody --> | ||
| 140 | + <?php foreach ($stocks as $i => $stock): ?> | ||
| 141 | + <div class="item panel panel-default"><!-- widgetItem --> | ||
| 142 | + <div class="panel-body"> | ||
| 143 | + <?php | ||
| 144 | + // necessary for update action. | ||
| 145 | + if (!$stock->isNewRecord) { | ||
| 146 | + echo Html::activeHiddenInput($stock, "[{$i}]stock_id"); | ||
| 147 | + } | ||
| 148 | + ?> | ||
| 149 | + <div class="row"> | ||
| 150 | + <div class="col-sm-5"> | ||
| 151 | + <?= $form->field($stock, "[{$i}]quantity") | ||
| 152 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 153 | + </div> | ||
| 154 | + <div class="col-sm-5"> | ||
| 155 | + <?= $form->field($stock, "[{$i}]name") | ||
| 156 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 157 | + </div> | ||
| 158 | + <div class="col-sm-2" style="margin-top: 30px"> | ||
| 159 | + <button type="button" class="remove-item btn btn-danger btn-xs"> | ||
| 160 | + <i class="glyphicon glyphicon-minus"></i></button> | ||
| 161 | + </div> | ||
| 162 | + </div><!-- .row --> | ||
| 163 | + </div> | ||
| 164 | + </div> | ||
| 165 | + <?php endforeach; ?> | ||
| 166 | + </div> | ||
| 167 | + </div> | ||
| 168 | + </div><!-- .panel --> | ||
| 169 | + <?php DynamicFormWidget::end(); ?> | ||
| 170 | + | ||
| 171 | + <?= $form->field($model, 'product_unit_id') | ||
| 172 | + ->dropDownList( | ||
| 173 | + ArrayHelper::map( | ||
| 174 | + \common\modules\product\models\ProductUnit::find() | ||
| 175 | + ->all(), | ||
| 176 | + 'product_unit_id', | ||
| 177 | + 'name' | ||
| 178 | + ), | ||
| 179 | + [ | ||
| 180 | + 'prompt' => Yii::t('product', 'Unit'), | ||
| 181 | + ] | ||
| 182 | + ) | ||
| 183 | + ->label(Yii::t('product', 'Unit')) ?> | ||
| 184 | + | ||
| 185 | + <?php if (isset($groups)) : ?> | ||
| 186 | + <?php foreach ($groups->all() as $group) : ?> | ||
| 187 | + <?= $form->field($model, 'options') | ||
| 188 | + ->checkboxList( | ||
| 189 | + ArrayHelper::map($group->options, 'tax_option_id', 'ValueRenderFlash'), | ||
| 190 | + [ | ||
| 191 | + 'multiple' => true, | ||
| 192 | + 'unselect' => null, | ||
| 193 | + ] | ||
| 194 | + ) | ||
| 195 | + ->label($group->name); ?> | ||
| 196 | + <?php endforeach ?> | ||
| 197 | + <?php endif ?> | ||
| 198 | + | ||
| 199 | + <div class="form-group"> | ||
| 200 | + <?= Html::submitButton( | ||
| 201 | + $model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), | ||
| 202 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | ||
| 203 | + ) ?> | ||
| 204 | + </div> | ||
| 205 | + | ||
| 147 | <?php ActiveForm::end(); ?> | 206 | <?php ActiveForm::end(); ?> |
| 148 | 207 | ||
| 149 | </div> | 208 | </div> |
common/modules/rubrication/models/TaxOption.php
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | -namespace common\modules\rubrication\models; | ||
| 4 | - | ||
| 5 | -use Yii; | ||
| 6 | -use common\components\artboxtree\ArtboxTreeBehavior; | ||
| 7 | -use yii\db\ActiveRecord; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * This is the model class for table "{{%tax_option}}". | ||
| 11 | - * | ||
| 12 | - * @property string $tax_option_id | ||
| 13 | - * @property integer $tax_group_id | ||
| 14 | - * @property integer $parent_id | ||
| 15 | - * @property integer $tree | ||
| 16 | - * @property string $path_int | ||
| 17 | - * @property integer $depth | ||
| 18 | - * @property string $alias | ||
| 19 | - * @property integer $sort | ||
| 20 | - * @property integer $default_value | ||
| 21 | - * @property integer $name | ||
| 22 | - * @property array $image | ||
| 23 | - * @property string $synonym | ||
| 24 | - * | ||
| 25 | - * @property TaxEntityRelation[] $taxEntityRelations | ||
| 26 | - * @property TaxGroup $taxGroup | ||
| 27 | - * @property TaxOption $parent | ||
| 28 | - * @property TaxOption[] $taxOptions | ||
| 29 | - * @property TaxOptionToGroup[] $taxOptionToGroups | ||
| 30 | - * @property TaxOptionToOption[] $taxOptionToOptions | ||
| 31 | - * @property TaxOptionToOption[] $taxOptionToOptions0 | ||
| 32 | - * @property TaxValueFloat[] $taxValueFloats | ||
| 33 | - * @property TaxValueInt[] $taxValueInts | ||
| 34 | - * @property TaxValueString[] $taxValueStrings | ||
| 35 | - * @property TaxValueText[] $taxValueTexts | ||
| 36 | - */ | ||
| 37 | -class TaxOption extends \yii\db\ActiveRecord | ||
| 38 | -{ | ||
| 39 | - public $_items_count; | ||
| 40 | - | ||
| 41 | - | 2 | + |
| 3 | + namespace common\modules\rubrication\models; | ||
| 4 | + | ||
| 5 | + use common\modules\product\models\Product; | ||
| 6 | + use Yii; | ||
| 7 | + use common\components\artboxtree\ArtboxTreeBehavior; | ||
| 8 | + use yii\db\ActiveQuery; | ||
| 9 | + use yii\db\ActiveRecord; | ||
| 10 | + | ||
| 42 | /** | 11 | /** |
| 43 | - * @inheritdoc | 12 | + * This is the model class for table "{{%tax_option}}". |
| 13 | + * | ||
| 14 | + * @property string $tax_option_id | ||
| 15 | + * @property integer $tax_group_id | ||
| 16 | + * @property integer $parent_id | ||
| 17 | + * @property integer $tree | ||
| 18 | + * @property string $path_int | ||
| 19 | + * @property integer $depth | ||
| 20 | + * @property string $alias | ||
| 21 | + * @property integer $sort | ||
| 22 | + * @property integer $default_value | ||
| 23 | + * @property integer $name | ||
| 24 | + * @property array $image | ||
| 25 | + * @property string $synonym | ||
| 26 | + * @property TaxEntityRelation[] $taxEntityRelations | ||
| 27 | + * @property TaxGroup $taxGroup | ||
| 28 | + * @property TaxOption $parent | ||
| 29 | + * @property TaxOption[] $taxOptions | ||
| 30 | + * @property TaxOptionToGroup[] $taxOptionToGroups | ||
| 31 | + * @property TaxOptionToOption[] $taxOptionToOptions | ||
| 32 | + * @property TaxOptionToOption[] $taxOptionToOptions0 | ||
| 33 | + * @property TaxValueFloat[] $taxValueFloats | ||
| 34 | + * @property TaxValueInt[] $taxValueInts | ||
| 35 | + * @property TaxValueString[] $taxValueStrings | ||
| 36 | + * @property TaxValueText[] $taxValueTexts | ||
| 44 | */ | 37 | */ |
| 45 | - public function behaviors() | 38 | + class TaxOption extends \yii\db\ActiveRecord |
| 46 | { | 39 | { |
| 47 | - return [ | ||
| 48 | - 'artboxtree' => [ | ||
| 49 | - 'class' => ArtboxTreeBehavior::className(), | ||
| 50 | - 'keyNameGroup' => 'tax_group_id', | ||
| 51 | - ], | ||
| 52 | - 'slug' => [ | ||
| 53 | - 'class' => 'common\behaviors\Slug', | ||
| 54 | - 'in_attribute' => 'name', | ||
| 55 | - 'out_attribute' => 'alias', | ||
| 56 | - 'translit' => true | ||
| 57 | - ], | ||
| 58 | - | ||
| 59 | - ]; | ||
| 60 | - } | ||
| 61 | - | 40 | + public $_items_count; |
| 41 | + | ||
| 62 | /** | 42 | /** |
| 63 | - * @inheritdoc | ||
| 64 | - */ | ||
| 65 | - public static function tableName() | ||
| 66 | - { | ||
| 67 | - return '{{%tax_option}}'; | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - /** | ||
| 71 | - * @inheritdoc | ||
| 72 | - */ | ||
| 73 | - public function rules() | ||
| 74 | - { | ||
| 75 | - return [ | ||
| 76 | - [['tax_group_id','name'], 'required'], | ||
| 77 | - [['tax_group_id', 'parent_id', 'sort', 'default_value'], 'integer'], | ||
| 78 | - [['image','alias', 'value', 'synonym'], 'string', 'max' => 255], | ||
| 79 | - [['tax_group_id'], 'exist', 'skipOnError' => true, 'targetClass' => TaxGroup::className(), 'targetAttribute' => ['tax_group_id' => 'tax_group_id']], | ||
| 80 | - ]; | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - /** | ||
| 84 | - * @inheritdoc | ||
| 85 | - */ | ||
| 86 | - public function attributeLabels() | ||
| 87 | - { | ||
| 88 | - return [ | ||
| 89 | - 'tax_option_id' => Yii::t('app', 'Tax Option ID'), | ||
| 90 | - 'tax_group_id' => Yii::t('app', 'Tax Group ID'), | ||
| 91 | - 'parent_id' => Yii::t('app', 'Parent ID'), | ||
| 92 | - 'alias' => Yii::t('app', 'Alias'), | ||
| 93 | - 'sort' => Yii::t('app', 'Sort'), | ||
| 94 | - 'default_value' => Yii::t('app', 'Default Value'), | ||
| 95 | - 'image' => Yii::t('product', 'Image'), | ||
| 96 | - 'synonym' => Yii::t('product', 'Синоним'), | ||
| 97 | - ]; | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - public static function find() { | ||
| 101 | - return new TaxOptionQuery(get_called_class()); | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - /** | ||
| 105 | - * @return \yii\db\ActiveQuery | ||
| 106 | - */ | ||
| 107 | - public function getTaxEntityRelations() | ||
| 108 | - { | ||
| 109 | - return $this->hasMany(TaxEntityRelation::className(), ['tax_option_id' => 'tax_option_id'])->inverseOf('taxOption'); | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - | ||
| 113 | - /** | ||
| 114 | - * @return \yii\db\ActiveQuery | ||
| 115 | - */ | ||
| 116 | - public function getGroup() | ||
| 117 | - { | ||
| 118 | - return $this->getTaxGroup(); | ||
| 119 | - } | ||
| 120 | - | ||
| 121 | - /** | ||
| 122 | - * @return \yii\db\ActiveQuery | ||
| 123 | - */ | ||
| 124 | - public function getTaxGroup() | ||
| 125 | - { | ||
| 126 | - return $this->hasOne(TaxGroup::className(), ['tax_group_id' => 'tax_group_id'])->inverseOf('taxOptions'); | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - /** | ||
| 130 | - * @return \yii\db\ActiveQuery | ||
| 131 | - */ | ||
| 132 | - public function getTaxOptions() | ||
| 133 | - { | ||
| 134 | - return $this->hasMany(TaxOption::className(), ['parent_id' => 'tax_option_id'])->inverseOf('parent'); | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | - /** | ||
| 138 | - * @return \yii\db\ActiveQuery | ||
| 139 | - */ | ||
| 140 | - public function getTaxOptionToGroups() | ||
| 141 | - { | ||
| 142 | - return $this->hasMany(TaxOptionToGroup::className(), ['tax_option_id' => 'tax_option_id'])->inverseOf('taxOption'); | ||
| 143 | - } | ||
| 144 | - | ||
| 145 | - /** | ||
| 146 | - * @return \yii\db\ActiveQuery | ||
| 147 | - */ | ||
| 148 | - public function getTaxOptionToOptions() | ||
| 149 | - { | ||
| 150 | - return $this->hasMany(TaxOptionToOption::className(), ['tax_option1_id' => 'tax_option_id'])->inverseOf('taxOption1'); | ||
| 151 | - } | ||
| 152 | - | ||
| 153 | - /** | ||
| 154 | - * @return \yii\db\ActiveQuery | ||
| 155 | - */ | ||
| 156 | - public function getTaxOptionToOptions0() | ||
| 157 | - { | ||
| 158 | - return $this->hasMany(TaxOptionToOption::className(), ['tax_option2_id' => 'tax_option_id'])->inverseOf('taxOption2'); | ||
| 159 | - } | ||
| 160 | - | ||
| 161 | - | ||
| 162 | - public function getTaxValueString(){ | ||
| 163 | - return $this->name; | ||
| 164 | - } | ||
| 165 | - | ||
| 166 | - | ||
| 167 | - /** | ||
| 168 | - */ | ||
| 169 | - public function getValue() | ||
| 170 | - { | ||
| 171 | - return $this->name; | ||
| 172 | - } | ||
| 173 | - public function setValue($value){ | ||
| 174 | - return $this->name = $value; | ||
| 175 | - } | ||
| 176 | - /** | ||
| 177 | - */ | ||
| 178 | - public function getValueRenderFlash() | ||
| 179 | - { | ||
| 180 | - return $this->name; | ||
| 181 | - } | ||
| 182 | - | ||
| 183 | - /** | ||
| 184 | - */ | ||
| 185 | - public function getValueRenderHTML() | ||
| 186 | - { | ||
| 187 | - return $this->name; | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | - | ||
| 191 | - | ||
| 192 | - /** | ||
| 193 | - * @return \yii\db\ActiveQuery | ||
| 194 | - */ | ||
| 195 | - public function getValues() | ||
| 196 | - { | ||
| 197 | - if ($valueClass = $this->getValueModelName()) | ||
| 198 | - return $this->hasMany($valueClass, ['tax_option_id' => 'tax_option_id'])->inverseOf('taxOption')->cascadeOnDelete(); | ||
| 199 | - } | ||
| 200 | - | ||
| 201 | - public function beforeSave($insert) | ||
| 202 | - { | ||
| 203 | - if (parent::beforeSave($insert)) { | ||
| 204 | - | ||
| 205 | - if (empty($this->parent_id)) | ||
| 206 | - $this->parent_id = 0; | ||
| 207 | - | ||
| 208 | - | ||
| 209 | - | ||
| 210 | - return true; | ||
| 211 | - } | ||
| 212 | - return false; | ||
| 213 | - } | ||
| 214 | - | ||
| 215 | - public function getImageFile() { | ||
| 216 | - return empty($this->image) ? null : Yii::getAlias('@imagesDir/tax_option/'. $this->image); | ||
| 217 | - } | ||
| 218 | - | ||
| 219 | - public function getImageUrl() | ||
| 220 | - { | ||
| 221 | - return empty($this->image) ? null : Yii::getAlias('@imagesUrl/tax_option/' . $this->image); | 43 | + * @inheritdoc |
| 44 | + */ | ||
| 45 | + public function behaviors() | ||
| 46 | + { | ||
| 47 | + return [ | ||
| 48 | + 'artboxtree' => [ | ||
| 49 | + 'class' => ArtboxTreeBehavior::className(), | ||
| 50 | + 'keyNameGroup' => 'tax_group_id', | ||
| 51 | + ], | ||
| 52 | + 'slug' => [ | ||
| 53 | + 'class' => 'common\behaviors\Slug', | ||
| 54 | + 'in_attribute' => 'name', | ||
| 55 | + 'out_attribute' => 'alias', | ||
| 56 | + 'translit' => true, | ||
| 57 | + ], | ||
| 58 | + | ||
| 59 | + ]; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * @inheritdoc | ||
| 64 | + */ | ||
| 65 | + public static function tableName() | ||
| 66 | + { | ||
| 67 | + return '{{%tax_option}}'; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * @inheritdoc | ||
| 72 | + */ | ||
| 73 | + public function rules() | ||
| 74 | + { | ||
| 75 | + return [ | ||
| 76 | + [ | ||
| 77 | + [ | ||
| 78 | + 'tax_group_id', | ||
| 79 | + 'name', | ||
| 80 | + ], | ||
| 81 | + 'required', | ||
| 82 | + ], | ||
| 83 | + [ | ||
| 84 | + [ | ||
| 85 | + 'tax_group_id', | ||
| 86 | + 'parent_id', | ||
| 87 | + 'sort', | ||
| 88 | + 'default_value', | ||
| 89 | + ], | ||
| 90 | + 'integer', | ||
| 91 | + ], | ||
| 92 | + [ | ||
| 93 | + [ | ||
| 94 | + 'image', | ||
| 95 | + 'alias', | ||
| 96 | + 'value', | ||
| 97 | + 'synonym', | ||
| 98 | + ], | ||
| 99 | + 'string', | ||
| 100 | + 'max' => 255, | ||
| 101 | + ], | ||
| 102 | + [ | ||
| 103 | + [ 'tax_group_id' ], | ||
| 104 | + 'exist', | ||
| 105 | + 'skipOnError' => true, | ||
| 106 | + 'targetClass' => TaxGroup::className(), | ||
| 107 | + 'targetAttribute' => [ 'tax_group_id' => 'tax_group_id' ], | ||
| 108 | + ], | ||
| 109 | + ]; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + /** | ||
| 113 | + * @inheritdoc | ||
| 114 | + */ | ||
| 115 | + public function attributeLabels() | ||
| 116 | + { | ||
| 117 | + return [ | ||
| 118 | + 'tax_option_id' => Yii::t('app', 'Tax Option ID'), | ||
| 119 | + 'tax_group_id' => Yii::t('app', 'Tax Group ID'), | ||
| 120 | + 'parent_id' => Yii::t('app', 'Parent ID'), | ||
| 121 | + 'alias' => Yii::t('app', 'Alias'), | ||
| 122 | + 'sort' => Yii::t('app', 'Sort'), | ||
| 123 | + 'default_value' => Yii::t('app', 'Default Value'), | ||
| 124 | + 'image' => Yii::t('product', 'Image'), | ||
| 125 | + 'synonym' => Yii::t('product', 'Синоним'), | ||
| 126 | + ]; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public static function find() | ||
| 130 | + { | ||
| 131 | + return new TaxOptionQuery(get_called_class()); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + /** | ||
| 135 | + * @return \yii\db\ActiveQuery | ||
| 136 | + */ | ||
| 137 | + public function getTaxEntityRelations() | ||
| 138 | + { | ||
| 139 | + return $this->hasMany(TaxEntityRelation::className(), [ 'tax_option_id' => 'tax_option_id' ]) | ||
| 140 | + ->inverseOf('taxOption'); | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + /** | ||
| 144 | + * @return \yii\db\ActiveQuery | ||
| 145 | + */ | ||
| 146 | + public function getGroup() | ||
| 147 | + { | ||
| 148 | + return $this->getTaxGroup(); | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + /** | ||
| 152 | + * @return \yii\db\ActiveQuery | ||
| 153 | + */ | ||
| 154 | + public function getTaxGroup() | ||
| 155 | + { | ||
| 156 | + return $this->hasOne(TaxGroup::className(), [ 'tax_group_id' => 'tax_group_id' ]) | ||
| 157 | + ->inverseOf('taxOptions'); | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + /** | ||
| 161 | + * @return \yii\db\ActiveQuery | ||
| 162 | + */ | ||
| 163 | + public function getTaxOptions() | ||
| 164 | + { | ||
| 165 | + return $this->hasMany(TaxOption::className(), [ 'parent_id' => 'tax_option_id' ]) | ||
| 166 | + ->inverseOf('parent'); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + /** | ||
| 170 | + * @return \yii\db\ActiveQuery | ||
| 171 | + */ | ||
| 172 | + public function getTaxOptionToGroups() | ||
| 173 | + { | ||
| 174 | + return $this->hasMany(TaxOptionToGroup::className(), [ 'tax_option_id' => 'tax_option_id' ]) | ||
| 175 | + ->inverseOf('taxOption'); | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + /** | ||
| 179 | + * @return \yii\db\ActiveQuery | ||
| 180 | + */ | ||
| 181 | + public function getTaxOptionToOptions() | ||
| 182 | + { | ||
| 183 | + return $this->hasMany(TaxOptionToOption::className(), [ 'tax_option1_id' => 'tax_option_id' ]) | ||
| 184 | + ->inverseOf('taxOption1'); | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + /** | ||
| 188 | + * @return \yii\db\ActiveQuery | ||
| 189 | + */ | ||
| 190 | + public function getTaxOptionToOptions0() | ||
| 191 | + { | ||
| 192 | + return $this->hasMany(TaxOptionToOption::className(), [ 'tax_option2_id' => 'tax_option_id' ]) | ||
| 193 | + ->inverseOf('taxOption2'); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + public function getTaxValueString() | ||
| 197 | + { | ||
| 198 | + return $this->name; | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + /** | ||
| 202 | + */ | ||
| 203 | + public function getValue() | ||
| 204 | + { | ||
| 205 | + return $this->name; | ||
| 206 | + } | ||
| 207 | + public function setValue($value) | ||
| 208 | + { | ||
| 209 | + return $this->name = $value; | ||
| 210 | + } | ||
| 211 | + /** | ||
| 212 | + */ | ||
| 213 | + public function getValueRenderFlash() | ||
| 214 | + { | ||
| 215 | + return $this->name; | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + /** | ||
| 219 | + */ | ||
| 220 | + public function getValueRenderHTML() | ||
| 221 | + { | ||
| 222 | + return $this->name; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + /** | ||
| 226 | + * @return \yii\db\ActiveQuery | ||
| 227 | + */ | ||
| 228 | + public function getValues() | ||
| 229 | + { | ||
| 230 | + if ($valueClass = $this->getValueModelName()) { | ||
| 231 | + return $this->hasMany($valueClass, [ 'tax_option_id' => 'tax_option_id' ]) | ||
| 232 | + ->inverseOf('taxOption') | ||
| 233 | + ->cascadeOnDelete(); | ||
| 234 | + } | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + public function beforeSave($insert) | ||
| 238 | + { | ||
| 239 | + if (parent::beforeSave($insert)) { | ||
| 240 | + | ||
| 241 | + if (empty($this->parent_id)) { | ||
| 242 | + $this->parent_id = 0; | ||
| 243 | + } | ||
| 244 | + | ||
| 245 | + return true; | ||
| 246 | + } | ||
| 247 | + return false; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + public function getImageFile() | ||
| 251 | + { | ||
| 252 | + return empty($this->image) ? null : Yii::getAlias('@imagesDir/tax_option/' . $this->image); | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + public function getImageUrl() | ||
| 256 | + { | ||
| 257 | + return empty($this->image) ? null : Yii::getAlias('@imagesUrl/tax_option/' . $this->image); | ||
| 258 | + } | ||
| 259 | + | ||
| 260 | + /** | ||
| 261 | + * @return ActiveQuery | ||
| 262 | + */ | ||
| 263 | + public function getProducts() | ||
| 264 | + { | ||
| 265 | + return $this->hasMany(Product::className(), [ 'product_id' => 'product_id' ]) | ||
| 266 | + ->viaTable('product_option', [ 'option_id' => 'tax_option_id' ]); | ||
| 267 | + } | ||
| 222 | } | 268 | } |
| 223 | -} |
console/controllers/SiteMapController.php
| @@ -4,22 +4,17 @@ | @@ -4,22 +4,17 @@ | ||
| 4 | 4 | ||
| 5 | use common\models\Articles; | 5 | use common\models\Articles; |
| 6 | use common\models\Seo; | 6 | use common\models\Seo; |
| 7 | - use common\modules\product\helpers\FilterHelper; | ||
| 8 | - use common\modules\product\models\Brand; | ||
| 9 | use common\modules\product\models\Category; | 7 | use common\modules\product\models\Category; |
| 10 | use common\modules\product\models\Product; | 8 | use common\modules\product\models\Product; |
| 11 | use common\modules\rubrication\models\TaxOption; | 9 | use common\modules\rubrication\models\TaxOption; |
| 12 | use frontend\models\ProductFrontendSearch; | 10 | use frontend\models\ProductFrontendSearch; |
| 13 | use Yii; | 11 | use Yii; |
| 14 | use common\models\Page; | 12 | use common\models\Page; |
| 15 | - use common\models\PageSearch; | 13 | + use yii\db\Query; |
| 16 | use yii\helpers\ArrayHelper; | 14 | use yii\helpers\ArrayHelper; |
| 17 | use yii\helpers\Console; | 15 | use yii\helpers\Console; |
| 18 | use yii\helpers\Url; | 16 | use yii\helpers\Url; |
| 19 | use yii\console\Controller; | 17 | use yii\console\Controller; |
| 20 | - use yii\web\NotFoundHttpException; | ||
| 21 | - use yii\filters\VerbFilter; | ||
| 22 | - use developeruz\db_rbac\behaviors\AccessBehavior; | ||
| 23 | 18 | ||
| 24 | /** | 19 | /** |
| 25 | * PageController implements the CRUD actions for Page model. | 20 | * PageController implements the CRUD actions for Page model. |
| @@ -30,6 +25,8 @@ | @@ -30,6 +25,8 @@ | ||
| 30 | private $urlList = [ 'http://www.linija-svitla.ua/' ]; | 25 | private $urlList = [ 'http://www.linija-svitla.ua/' ]; |
| 31 | private $count = 1; | 26 | private $count = 1; |
| 32 | 27 | ||
| 28 | + private $addedFilters = []; | ||
| 29 | + | ||
| 33 | public function checkFilter($category, $filter) | 30 | public function checkFilter($category, $filter) |
| 34 | { | 31 | { |
| 35 | $productModel = new ProductFrontendSearch(); | 32 | $productModel = new ProductFrontendSearch(); |
| @@ -48,7 +45,6 @@ | @@ -48,7 +45,6 @@ | ||
| 48 | { | 45 | { |
| 49 | return [ | 46 | return [ |
| 50 | 'https://www.linija-svitla.ua', | 47 | 'https://www.linija-svitla.ua', |
| 51 | - 'https://www.linija-svitla.ua/catalog', | ||
| 52 | ]; | 48 | ]; |
| 53 | } | 49 | } |
| 54 | 50 | ||
| @@ -72,7 +68,14 @@ | @@ -72,7 +68,14 @@ | ||
| 72 | [ | 68 | [ |
| 73 | 'not like', | 69 | 'not like', |
| 74 | 'meta', | 70 | 'meta', |
| 75 | - '%noindex%', | 71 | + 'noindex', |
| 72 | + ] | ||
| 73 | + ) | ||
| 74 | + ->andWhere( | ||
| 75 | + [ | ||
| 76 | + '!=', | ||
| 77 | + 'url', | ||
| 78 | + '/', | ||
| 76 | ] | 79 | ] |
| 77 | ) | 80 | ) |
| 78 | ->all(); | 81 | ->all(); |
| @@ -94,6 +97,7 @@ | @@ -94,6 +97,7 @@ | ||
| 94 | public function getCategories() | 97 | public function getCategories() |
| 95 | { | 98 | { |
| 96 | return Category::find() | 99 | return Category::find() |
| 100 | + ->with('brands') | ||
| 97 | ->all(); | 101 | ->all(); |
| 98 | } | 102 | } |
| 99 | 103 | ||
| @@ -129,6 +133,21 @@ | @@ -129,6 +133,21 @@ | ||
| 129 | 'taxGroup.category', | 133 | 'taxGroup.category', |
| 130 | ] | 134 | ] |
| 131 | ) | 135 | ) |
| 136 | + ->where( | ||
| 137 | + [ | ||
| 138 | + 'tax_group.is_filter' => true, | ||
| 139 | + ] | ||
| 140 | + ) | ||
| 141 | + ->joinWith('products') | ||
| 142 | + ->andWhere( | ||
| 143 | + [ | ||
| 144 | + | ||
| 145 | + 'product.product_id' => ( new Query() )->select(['pid' => 'product.product_id']) | ||
| 146 | + ->from('product')->join('INNER JOIN', 'product_variant', 'product.product_id = product_variant.product_id') | ||
| 147 | + ->where(['!=','product_variant.stock',0]) | ||
| 148 | + | ||
| 149 | + ] | ||
| 150 | + ) | ||
| 132 | ->all(); | 151 | ->all(); |
| 133 | 152 | ||
| 134 | } | 153 | } |
| @@ -191,7 +210,7 @@ | @@ -191,7 +210,7 @@ | ||
| 191 | true | 210 | true |
| 192 | ); | 211 | ); |
| 193 | 212 | ||
| 194 | - $this->createRow($url, 1, $content); | 213 | + $this->createRow($url, 0.5, $content); |
| 195 | } | 214 | } |
| 196 | $this->stdout('Add categories' . "\n", Console::FG_BLUE); | 215 | $this->stdout('Add categories' . "\n", Console::FG_BLUE); |
| 197 | 216 | ||
| @@ -204,7 +223,7 @@ | @@ -204,7 +223,7 @@ | ||
| 204 | ], | 223 | ], |
| 205 | true | 224 | true |
| 206 | ); | 225 | ); |
| 207 | - $this->createRow($url, 1, $content); | 226 | + $this->createRow($url, 0.9, $content); |
| 208 | } | 227 | } |
| 209 | 228 | ||
| 210 | $this->stdout('Add products' . "\n", Console::FG_BLUE); | 229 | $this->stdout('Add products' . "\n", Console::FG_BLUE); |
| @@ -218,7 +237,7 @@ | @@ -218,7 +237,7 @@ | ||
| 218 | ], | 237 | ], |
| 219 | true | 238 | true |
| 220 | ); | 239 | ); |
| 221 | - $this->createRow($url, 0.9, $content); | 240 | + $this->createRow($url, 0.7, $content); |
| 222 | } | 241 | } |
| 223 | 242 | ||
| 224 | $this->stdout('Add articles' . "\n", Console::FG_BLUE); | 243 | $this->stdout('Add articles' . "\n", Console::FG_BLUE); |
| @@ -232,25 +251,23 @@ | @@ -232,25 +251,23 @@ | ||
| 232 | ], | 251 | ], |
| 233 | true | 252 | true |
| 234 | ); | 253 | ); |
| 235 | - $this->createRow($url, 0.8, $content); | 254 | + $this->createRow($url, 0.7, $content); |
| 236 | 255 | ||
| 237 | } | 256 | } |
| 238 | 257 | ||
| 239 | $this->stdout('Add brands' . "\n", Console::FG_BLUE); | 258 | $this->stdout('Add brands' . "\n", Console::FG_BLUE); |
| 240 | 259 | ||
| 241 | foreach ($this->getCategories() as $category) { | 260 | foreach ($this->getCategories() as $category) { |
| 242 | - foreach ($this->getBrands($category) as $brand) { | ||
| 243 | - if ($this->checkFilter($category, [ 'brands' => [ $brand->brand_id ] ])) { | ||
| 244 | - $url = Url::to( | ||
| 245 | - [ | ||
| 246 | - 'catalog/category', | ||
| 247 | - 'category' => $category, | ||
| 248 | - 'filters' => [ 'brands' => [ $brand->alias ] ], | ||
| 249 | - ], | ||
| 250 | - true | ||
| 251 | - ); | ||
| 252 | - $this->createRow($url, 0.8, $content); | ||
| 253 | - } | 261 | + foreach ($category->brands as $brand) { |
| 262 | + $url = Url::to( | ||
| 263 | + [ | ||
| 264 | + 'catalog/category', | ||
| 265 | + 'category' => $category, | ||
| 266 | + 'filters' => [ 'brands' => [ $brand->alias ] ], | ||
| 267 | + ], | ||
| 268 | + true | ||
| 269 | + ); | ||
| 270 | + $this->createRow($url, 0.8, $content); | ||
| 254 | } | 271 | } |
| 255 | } | 272 | } |
| 256 | 273 | ||
| @@ -265,6 +282,7 @@ | @@ -265,6 +282,7 @@ | ||
| 265 | ], | 282 | ], |
| 266 | true | 283 | true |
| 267 | ); | 284 | ); |
| 285 | + $this->addedFilters[] = $url; | ||
| 268 | $this->createRow($url, 0.8, $content); | 286 | $this->createRow($url, 0.8, $content); |
| 269 | } | 287 | } |
| 270 | 288 | ||
| @@ -272,7 +290,10 @@ | @@ -272,7 +290,10 @@ | ||
| 272 | 290 | ||
| 273 | foreach ($this->getSeoLinks() as $link) { | 291 | foreach ($this->getSeoLinks() as $link) { |
| 274 | $url = Yii::$app->urlManager->baseUrl . $link->url; | 292 | $url = Yii::$app->urlManager->baseUrl . $link->url; |
| 275 | - $this->createRow($url, 0.7, $content); | 293 | + if (in_array($url, $this->addedFilters)) { |
| 294 | + continue; | ||
| 295 | + } | ||
| 296 | + $this->createRow($url, 0.8, $content); | ||
| 276 | 297 | ||
| 277 | } | 298 | } |
| 278 | 299 |
console/migrations/m170608_122754_add_sort_column_to_category_table.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use yii\db\Migration; | ||
| 4 | + | ||
| 5 | + /** | ||
| 6 | + * Handles adding sort to table `category`. | ||
| 7 | + */ | ||
| 8 | + class m170608_122754_add_sort_column_to_category_table extends Migration | ||
| 9 | + { | ||
| 10 | + /** | ||
| 11 | + * @inheritdoc | ||
| 12 | + */ | ||
| 13 | + public function up() | ||
| 14 | + { | ||
| 15 | + $this->addColumn('category', 'sort', $this->integer()); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * @inheritdoc | ||
| 20 | + */ | ||
| 21 | + public function down() | ||
| 22 | + { | ||
| 23 | + $this->dropColumn('category', 'sort'); | ||
| 24 | + } | ||
| 25 | + } |
console/migrations/m170612_153331_add_sort_column_to_brand_table.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use yii\db\Migration; | ||
| 4 | + | ||
| 5 | + /** | ||
| 6 | + * Handles adding sort to table `brand`. | ||
| 7 | + */ | ||
| 8 | + class m170612_153331_add_sort_column_to_brand_table extends Migration | ||
| 9 | + { | ||
| 10 | + /** | ||
| 11 | + * @inheritdoc | ||
| 12 | + */ | ||
| 13 | + public function up() | ||
| 14 | + { | ||
| 15 | + $this->addColumn('brand', 'sort', $this->integer()); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * @inheritdoc | ||
| 20 | + */ | ||
| 21 | + public function down() | ||
| 22 | + { | ||
| 23 | + $this->dropColumn('brand', 'sort'); | ||
| 24 | + } | ||
| 25 | + } |
frontend/controllers/CatalogController.php
| @@ -24,8 +24,8 @@ class CatalogController extends \yii\web\Controller | @@ -24,8 +24,8 @@ class CatalogController extends \yii\web\Controller | ||
| 24 | 24 | ||
| 25 | public function actionCategory() | 25 | public function actionCategory() |
| 26 | { | 26 | { |
| 27 | - | ||
| 28 | - | 27 | + |
| 28 | + | ||
| 29 | /** @var Category $category */ | 29 | /** @var Category $category */ |
| 30 | $category = Yii::$app->request->get('category'); | 30 | $category = Yii::$app->request->get('category'); |
| 31 | $filter = Yii::$app->request->get('filters', [ ]); | 31 | $filter = Yii::$app->request->get('filters', [ ]); |
| @@ -151,7 +151,7 @@ class CatalogController extends \yii\web\Controller | @@ -151,7 +151,7 @@ class CatalogController extends \yii\web\Controller | ||
| 151 | 151 | ||
| 152 | 152 | ||
| 153 | $priceLimits = $productModel->priceLimits($category, $params); | 153 | $priceLimits = $productModel->priceLimits($category, $params); |
| 154 | - | 154 | + |
| 155 | 155 | ||
| 156 | return $this->render('products', [ | 156 | return $this->render('products', [ |
| 157 | 'category' => $category, | 157 | 'category' => $category, |
frontend/controllers/SearchController.php
| @@ -54,7 +54,7 @@ class SearchController extends \yii\web\Controller | @@ -54,7 +54,7 @@ class SearchController extends \yii\web\Controller | ||
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | $productModel = new ProductFrontendSearch(); | 56 | $productModel = new ProductFrontendSearch(); |
| 57 | - $productProvider = $productModel->search(null, $params, false); | 57 | + $productProvider = $productModel->search(null, $params, false, false); |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | return $this->render( | 60 | return $this->render( |
frontend/models/ProductFrontendSearch.php
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | -namespace frontend\models; | ||
| 4 | - | ||
| 5 | -use common\modules\product\helpers\FilterHelper; | ||
| 6 | -use common\modules\product\helpers\ProductHelper; | ||
| 7 | -use common\modules\product\models\Category; | ||
| 8 | -use Yii; | ||
| 9 | -use yii\base\Model; | ||
| 10 | -use yii\data\ActiveDataProvider; | ||
| 11 | -use yii\data\ArrayDataProvider; | ||
| 12 | -use yii\db\ActiveQuery; | ||
| 13 | - | ||
| 14 | -use common\modules\product\models\Product; | ||
| 15 | -use common\modules\product\models\ProductVariant; | ||
| 16 | -use yii\helpers\ArrayHelper; | ||
| 17 | - | ||
| 18 | -class ProductFrontendSearch extends Product { | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - public $price_interval; | ||
| 22 | - public $brands; | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | - * @inheritdoc | ||
| 27 | - */ | ||
| 28 | - public function rules() | 2 | + |
| 3 | + namespace frontend\models; | ||
| 4 | + | ||
| 5 | + use common\modules\product\helpers\ProductHelper; | ||
| 6 | + use common\modules\product\models\Category; | ||
| 7 | + use yii\base\Model; | ||
| 8 | + use yii\data\ArrayDataProvider; | ||
| 9 | + use yii\db\ActiveQuery; | ||
| 10 | + | ||
| 11 | + use common\modules\product\models\Product; | ||
| 12 | + use common\modules\product\models\ProductVariant; | ||
| 13 | + use yii\db\Query; | ||
| 14 | + | ||
| 15 | + class ProductFrontendSearch extends Product | ||
| 29 | { | 16 | { |
| 30 | - return [ | ||
| 31 | - [['price_interval', 'brands'], 'safe'], | ||
| 32 | - ]; | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - /** | ||
| 36 | - * @inheritdoc | ||
| 37 | - */ | ||
| 38 | - public function scenarios() | ||
| 39 | - { | ||
| 40 | - // bypass scenarios() implementation in the parent class | ||
| 41 | - return Model::scenarios(); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - /** | ||
| 45 | - * Creates data provider instance with search query applied for frontend | ||
| 46 | - * | ||
| 47 | - * @param array $params | ||
| 48 | - * | ||
| 49 | - * @return ActiveDataProvider | ||
| 50 | - */ | ||
| 51 | - public function search($category = null, $params = [], $in_stock = true) { | ||
| 52 | - | ||
| 53 | - | ||
| 54 | - $dataProvider = new ArrayDataProvider([ | ||
| 55 | - 'allModels' => $this->getSearchQuery($category, $params, $in_stock)->with([ | ||
| 56 | - 'images', | ||
| 57 | - 'events', | ||
| 58 | - 'variant', | ||
| 59 | - 'variant.image', | ||
| 60 | - 'comments', | ||
| 61 | - 'averageRating', | ||
| 62 | - ])->all(), | ||
| 63 | - 'pagination' => [ | ||
| 64 | - 'pageSize' => 15, | ||
| 65 | - ], | ||
| 66 | - 'sort' => [ | ||
| 67 | - 'attributes' => [ | ||
| 68 | - 'name' => [ | ||
| 69 | - 'asc' => ['name' => SORT_ASC], | ||
| 70 | - 'desc' => ['name' => SORT_DESC], | ||
| 71 | - 'default' => SORT_DESC, | ||
| 72 | - 'label' => 'имени', | ||
| 73 | - ], | ||
| 74 | - 'price' => [ | ||
| 75 | - 'asc' => ['price' => SORT_ASC], | ||
| 76 | - 'desc' => ['price' => SORT_DESC], | ||
| 77 | - 'default' => SORT_DESC, | ||
| 78 | - 'label' => 'по цене', | 17 | + |
| 18 | + public $price_interval; | ||
| 19 | + public $brands; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * @inheritdoc | ||
| 23 | + */ | ||
| 24 | + public function rules() | ||
| 25 | + { | ||
| 26 | + return [ | ||
| 27 | + [ | ||
| 28 | + [ | ||
| 29 | + 'price_interval', | ||
| 30 | + 'brands', | ||
| 79 | ], | 31 | ], |
| 32 | + 'safe', | ||
| 80 | ], | 33 | ], |
| 81 | - ] | ||
| 82 | - ]); | ||
| 83 | - | ||
| 84 | - return $dataProvider; | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - public function getSearchQuery($category = null, $params = [], $in_stock = true) { | ||
| 88 | - | ||
| 89 | - if (!empty($category)) { | ||
| 90 | - /** @var ActiveQuery $query */ | ||
| 91 | - /**@var Category $category **/ | ||
| 92 | - $query = $category->getProducts(); | ||
| 93 | - | ||
| 94 | - } else { | ||
| 95 | - $query = Product::find(); | 34 | + ]; |
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * @inheritdoc | ||
| 39 | + */ | ||
| 40 | + public function scenarios() | ||
| 41 | + { | ||
| 42 | + // bypass scenarios() implementation in the parent class | ||
| 43 | + return Model::scenarios(); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * Creates data provider instance with search query applied for frontend | ||
| 48 | + * | ||
| 49 | + * @param array $params | ||
| 50 | + * | ||
| 51 | + * @return ArrayDataProvider | ||
| 52 | + */ | ||
| 53 | + public function search($category = null, $params = [], $in_stock = true, $without_sale = true) | ||
| 54 | + { | ||
| 55 | + | ||
| 56 | + $dataProvider = new ArrayDataProvider( | ||
| 57 | + [ | ||
| 58 | + 'allModels' => $this->getSearchQuery($category, $params, $in_stock, $without_sale) | ||
| 59 | + ->with( | ||
| 60 | + [ | ||
| 61 | + 'images', | ||
| 62 | + 'events', | ||
| 63 | + 'variant', | ||
| 64 | + 'variant.image', | ||
| 65 | + 'comments', | ||
| 66 | + 'averageRating', | ||
| 67 | + ] | ||
| 68 | + ) | ||
| 69 | + ->all(), | ||
| 70 | + 'pagination' => [ | ||
| 71 | + 'pageSize' => 15, | ||
| 72 | + ], | ||
| 73 | + 'sort' => [ | ||
| 74 | + 'attributes' => [ | ||
| 75 | + 'name' => [ | ||
| 76 | + 'asc' => [ 'name' => SORT_ASC ], | ||
| 77 | + 'desc' => [ 'name' => SORT_DESC ], | ||
| 78 | + 'default' => SORT_DESC, | ||
| 79 | + 'label' => 'имени', | ||
| 80 | + ], | ||
| 81 | + 'price' => [ | ||
| 82 | + 'asc' => [ 'price' => SORT_ASC ], | ||
| 83 | + 'desc' => [ 'price' => SORT_DESC ], | ||
| 84 | + 'default' => SORT_DESC, | ||
| 85 | + 'label' => 'по цене', | ||
| 86 | + ], | ||
| 87 | + ], | ||
| 88 | + ], | ||
| 89 | + ] | ||
| 90 | + ); | ||
| 91 | + | ||
| 92 | + return $dataProvider; | ||
| 96 | } | 93 | } |
| 97 | - | ||
| 98 | - $query->select(['product.*']); | ||
| 99 | - $query->joinWith(['enabledVariants','brand','options', 'category']); | ||
| 100 | - | ||
| 101 | -// $query->groupBy(['product.product_id', 'product_variant.price', 'product_variant.stock']); | ||
| 102 | - $query->orderBy(['product_variant.stock' => SORT_DESC]); | ||
| 103 | - ProductHelper::_setQueryParams($query, $params); | ||
| 104 | - if($in_stock){ | ||
| 105 | - $query->andWhere(['!=', ProductVariant::tableName() .'.status', 1]); | 94 | + |
| 95 | + public function getSearchQuery($category = null, $params = [], $in_stock = true, $without_sale = true) | ||
| 96 | + { | ||
| 97 | + | ||
| 98 | + if (!empty($category)) { | ||
| 99 | + /** @var ActiveQuery $query */ | ||
| 100 | + /**@var Category $category * */ | ||
| 101 | + $query = $category->getProducts(); | ||
| 102 | + | ||
| 103 | + } else { | ||
| 104 | + $query = Product::find(); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + $query->select([ 'product.*' ]); | ||
| 108 | + $query->joinWith( | ||
| 109 | + [ | ||
| 110 | + 'enabledVariants', | ||
| 111 | + 'brand', | ||
| 112 | + 'options', | ||
| 113 | + 'category', | ||
| 114 | + ] | ||
| 115 | + ); | ||
| 116 | + | ||
| 117 | + // $query->groupBy(['product.product_id', 'product_variant.price', 'product_variant.stock']); | ||
| 118 | + $query->orderBy([ | ||
| 119 | + 'brand.sort' => SORT_ASC, | ||
| 120 | + 'product_variant.stock' => SORT_DESC, | ||
| 121 | + ]); | ||
| 122 | + ProductHelper::_setQueryParams($query, $params); | ||
| 123 | + if ($in_stock) { | ||
| 124 | + $query->andWhere( | ||
| 125 | + [ | ||
| 126 | + '!=', | ||
| 127 | + ProductVariant::tableName() . '.status', | ||
| 128 | + 1, | ||
| 129 | + ] | ||
| 130 | + ); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * Removing products that currently in events | ||
| 135 | + */ | ||
| 136 | + if ($without_sale) { | ||
| 137 | + $query->andWhere( | ||
| 138 | + [ | ||
| 139 | + 'not', | ||
| 140 | + [ | ||
| 141 | + 'product.product_id' => ( new Query() )->select('events_to_products.product_id') | ||
| 142 | + ->from('events_to_products') | ||
| 143 | + ->innerJoin( | ||
| 144 | + 'event', | ||
| 145 | + 'event.event_id=events_to_products.event_id' | ||
| 146 | + )->where(['event.sale' => true]), | ||
| 147 | + ], | ||
| 148 | + ] | ||
| 149 | + ); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + return $query; | ||
| 106 | } | 153 | } |
| 107 | - | ||
| 108 | - | ||
| 109 | - return $query; | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - | ||
| 113 | - /** | ||
| 114 | - * @param Category|null $category | ||
| 115 | - * @return array | ||
| 116 | - */ | ||
| 117 | - | ||
| 118 | - public function priceLimits($category = null, $params = []) { | ||
| 119 | - if (!empty($category)) { | ||
| 120 | - /** @var ActiveQuery $query */ | ||
| 121 | -// $query = $category->getRelations('product_categories'); | ||
| 122 | - $query = $category->getProducts(); | ||
| 123 | - } else { | ||
| 124 | - $query = Product::find(); | 154 | + |
| 155 | + /** | ||
| 156 | + * @param Category|null $category | ||
| 157 | + * | ||
| 158 | + * @return array | ||
| 159 | + */ | ||
| 160 | + | ||
| 161 | + public function priceLimits($category = null, $params = []) | ||
| 162 | + { | ||
| 163 | + if (!empty($category)) { | ||
| 164 | + /** @var ActiveQuery $query */ | ||
| 165 | + // $query = $category->getRelations('product_categories'); | ||
| 166 | + $query = $category->getProducts(); | ||
| 167 | + } else { | ||
| 168 | + $query = Product::find(); | ||
| 169 | + } | ||
| 170 | + $query->joinWith('variant'); | ||
| 171 | + | ||
| 172 | + // Price filter fix | ||
| 173 | + unset($params[ 'prices' ]); | ||
| 174 | + | ||
| 175 | + ProductHelper::_setQueryParams($query, $params); | ||
| 176 | + $query->andWhere( | ||
| 177 | + [ | ||
| 178 | + '>=', | ||
| 179 | + ProductVariant::tableName() . '.stock', | ||
| 180 | + 1, | ||
| 181 | + ] | ||
| 182 | + ); | ||
| 183 | + return [ | ||
| 184 | + 'min' => $query->min(ProductVariant::tableName() . '.price'), | ||
| 185 | + 'max' => $query->max(ProductVariant::tableName() . '.price'), | ||
| 186 | + ]; | ||
| 125 | } | 187 | } |
| 126 | - $query->joinWith('variant'); | ||
| 127 | - | ||
| 128 | - // Price filter fix | ||
| 129 | - unset($params['prices']); | ||
| 130 | - | ||
| 131 | - ProductHelper::_setQueryParams($query, $params); | ||
| 132 | - $query->andWhere( | ||
| 133 | - [ | ||
| 134 | - '>=', | ||
| 135 | - ProductVariant::tableName() . '.stock', | ||
| 136 | - 1, | ||
| 137 | - ] | ||
| 138 | - ); | ||
| 139 | - return [ | ||
| 140 | - 'min' => $query->min(ProductVariant::tableName() .'.price'), | ||
| 141 | - 'max' => $query->max(ProductVariant::tableName() .'.price'), | ||
| 142 | - ]; | ||
| 143 | - } | ||
| 144 | -} | ||
| 145 | \ No newline at end of file | 188 | \ No newline at end of file |
| 189 | + } | ||
| 146 | \ No newline at end of file | 190 | \ No newline at end of file |
frontend/views/catalog/_product_item.php
| @@ -38,12 +38,23 @@ use yii\helpers\Url; | @@ -38,12 +38,23 @@ use yii\helpers\Url; | ||
| 38 | ?> | 38 | ?> |
| 39 | 39 | ||
| 40 | </div> | 40 | </div> |
| 41 | - <?= \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list', [ | ||
| 42 | - 'alt' => $model->getFullName(), | ||
| 43 | - 'title' => $model->getFullName(), | ||
| 44 | - 'class' => 'selected', | ||
| 45 | - 'itemprop' => 'image' | ||
| 46 | - ]) ?> | 41 | + <?php |
| 42 | + try { | ||
| 43 | + echo \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list', [ | ||
| 44 | + 'alt' => $model->getFullName(), | ||
| 45 | + 'title' => $model->getFullName(), | ||
| 46 | + 'class' => 'selected', | ||
| 47 | + 'itemprop' => 'image' | ||
| 48 | + ]); | ||
| 49 | + } catch(Exception $exception) { | ||
| 50 | + echo \common\components\artboximage\ArtboxImageHelper::getImage('/storage/no_photo.png', 'list', [ | ||
| 51 | + 'alt' => $model->getFullName(), | ||
| 52 | + 'title' => $model->getFullName(), | ||
| 53 | + 'class' => 'selected', | ||
| 54 | + 'itemprop' => 'image' | ||
| 55 | + ]); | ||
| 56 | + } | ||
| 57 | + ?> | ||
| 47 | </a> | 58 | </a> |
| 48 | <div class="info_icons"> | 59 | <div class="info_icons"> |
| 49 | <?php if($model->variant->status != 1){?> | 60 | <?php if($model->variant->status != 1){?> |
frontend/views/catalog/product.php
| @@ -13,7 +13,6 @@ | @@ -13,7 +13,6 @@ | ||
| 13 | use yii\bootstrap\ActiveForm; | 13 | use yii\bootstrap\ActiveForm; |
| 14 | use yii\bootstrap\Html; | 14 | use yii\bootstrap\Html; |
| 15 | use yii\helpers\Url; | 15 | use yii\helpers\Url; |
| 16 | - use yii\helpers\VarDumper; | ||
| 17 | use yii\web\View; | 16 | use yii\web\View; |
| 18 | use yii\widgets\MaskedInput; | 17 | use yii\widgets\MaskedInput; |
| 19 | use frontend\assets\FlipclockAsset; | 18 | use frontend\assets\FlipclockAsset; |
| @@ -45,8 +44,8 @@ | @@ -45,8 +44,8 @@ | ||
| 45 | $this->params['remarketing']['type'] = 'offerdetail'; | 44 | $this->params['remarketing']['type'] = 'offerdetail'; |
| 46 | $this->params['remarketing']['id'] = $product->variant->product_variant_id; | 45 | $this->params['remarketing']['id'] = $product->variant->product_variant_id; |
| 47 | $this->params['remarketing']['price'] = $product->getPrice(); | 46 | $this->params['remarketing']['price'] = $product->getPrice(); |
| 47 | + | ||
| 48 | ?> | 48 | ?> |
| 49 | - | ||
| 50 | <div class="wrapper white item_container"> | 49 | <div class="wrapper white item_container"> |
| 51 | <div class="container"> | 50 | <div class="container"> |
| 52 | <div class="product_detail" itemscope itemtype="http://schema.org/Product"> | 51 | <div class="product_detail" itemscope itemtype="http://schema.org/Product"> |
| @@ -61,7 +60,6 @@ | @@ -61,7 +60,6 @@ | ||
| 61 | <div class="product_code">Код:<?= $product->variant->sku ?></div> | 60 | <div class="product_code">Код:<?= $product->variant->sku ?></div> |
| 62 | <div class="clearfix"></div> | 61 | <div class="clearfix"></div> |
| 63 | <!-- Image part --> | 62 | <!-- Image part --> |
| 64 | - | ||
| 65 | <div class="img_part"> | 63 | <div class="img_part"> |
| 66 | 64 | ||
| 67 | <div class="position"> | 65 | <div class="position"> |
| @@ -70,7 +68,6 @@ | @@ -70,7 +68,6 @@ | ||
| 70 | <div class="fotorama" data-allowfullscreen="true" data-nav="thumbs" | 68 | <div class="fotorama" data-allowfullscreen="true" data-nav="thumbs" |
| 71 | data-width="342" | 69 | data-width="342" |
| 72 | data-height="350"> | 70 | data-height="350"> |
| 73 | - | ||
| 74 | <?php foreach($product->images as $image) : ?> | 71 | <?php foreach($product->images as $image) : ?> |
| 75 | <a href="<?= $image->imageUrl ?>"> | 72 | <a href="<?= $image->imageUrl ?>"> |
| 76 | <?= ArtboxImageHelper::getImage($image->imageUrl, 'product_show') ?> | 73 | <?= ArtboxImageHelper::getImage($image->imageUrl, 'product_show') ?> |
| @@ -79,11 +76,21 @@ | @@ -79,11 +76,21 @@ | ||
| 79 | </div> | 76 | </div> |
| 80 | <?php else : ?> | 77 | <?php else : ?> |
| 81 | <a href="<?= $product->imageUrl ?>" data-lightbox="image-1" data-title="<?= $product->fullname;?>"> | 78 | <a href="<?= $product->imageUrl ?>" data-lightbox="image-1" data-title="<?= $product->fullname;?>"> |
| 82 | - <?= ArtboxImageHelper::getImage($product->imageUrl, 'product_show',[ | ||
| 83 | - 'alt'=>$product->fullname, | ||
| 84 | - 'title' => $product->fullname, | ||
| 85 | - 'itemprop' => 'image' | ||
| 86 | - ]) ?> | 79 | + <?php |
| 80 | + try { | ||
| 81 | + echo ArtboxImageHelper::getImage($product->imageUrl, 'product_show',[ | ||
| 82 | + 'alt'=>$product->fullname, | ||
| 83 | + 'title' => $product->fullname, | ||
| 84 | + 'itemprop' => 'image' | ||
| 85 | + ]); | ||
| 86 | + } catch(Exception $exception) { | ||
| 87 | + echo ArtboxImageHelper::getImage('/storage/no_photo.png', 'product_show',[ | ||
| 88 | + 'alt'=>$product->fullname, | ||
| 89 | + 'title' => $product->fullname, | ||
| 90 | + 'itemprop' => 'image' | ||
| 91 | + ]); | ||
| 92 | + } | ||
| 93 | + ?> | ||
| 87 | </a> | 94 | </a> |
| 88 | 95 | ||
| 89 | <?php endif ?> | 96 | <?php endif ?> |
| @@ -227,6 +234,8 @@ | @@ -227,6 +234,8 @@ | ||
| 227 | <td class="left_count available"> | 234 | <td class="left_count available"> |
| 228 | <?php if($product->variant->status == 1){?> | 235 | <?php if($product->variant->status == 1){?> |
| 229 | снят с производства | 236 | снят с производства |
| 237 | + <?php } elseif($product->variant->status == 2) {?> | ||
| 238 | + в ожидании | ||
| 230 | <?php } elseif($product->variant->stock > 0) {?> | 239 | <?php } elseif($product->variant->stock > 0) {?> |
| 231 | в наличии | 240 | в наличии |
| 232 | <?php } else {?> | 241 | <?php } else {?> |
frontend/views/catalog/products.php
| @@ -60,7 +60,6 @@ | @@ -60,7 +60,6 @@ | ||
| 60 | 'priceLimits' => $priceLimits, | 60 | 'priceLimits' => $priceLimits, |
| 61 | //'filterBrands' => $filterBrands | 61 | //'filterBrands' => $filterBrands |
| 62 | ])?> | 62 | ])?> |
| 63 | - | ||
| 64 | <div class="clearfix"></div> | 63 | <div class="clearfix"></div> |
| 65 | 64 | ||
| 66 | 65 | ||
| @@ -102,6 +101,7 @@ | @@ -102,6 +101,7 @@ | ||
| 102 | ]); | 101 | ]); |
| 103 | ?> | 102 | ?> |
| 104 | </div> | 103 | </div> |
| 104 | + | ||
| 105 | <div class="clearfix"></div> | 105 | <div class="clearfix"></div> |
| 106 | </div> | 106 | </div> |
| 107 | 107 | ||
| @@ -117,14 +117,12 @@ | @@ -117,14 +117,12 @@ | ||
| 117 | 117 | ||
| 118 | 118 | ||
| 119 | <div class="catalog_product_list view_table"> | 119 | <div class="catalog_product_list view_table"> |
| 120 | - | ||
| 121 | - | ||
| 122 | <?= ListView::widget([ | 120 | <?= ListView::widget([ |
| 123 | 'dataProvider' => $productProvider, | 121 | 'dataProvider' => $productProvider, |
| 124 | 'itemView' => function ($model, $key, $index, $widget) use($category) { | 122 | 'itemView' => function ($model, $key, $index, $widget) use($category) { |
| 125 | return $this->render('_product_item',[ | 123 | return $this->render('_product_item',[ |
| 126 | 'model' => $model, | 124 | 'model' => $model, |
| 127 | - 'category' => $category | 125 | + 'category' => $category, |
| 128 | ]); | 126 | ]); |
| 129 | }, | 127 | }, |
| 130 | 'layout' => "{items}<div class=\"clearfix\"></div>{pager}", | 128 | 'layout' => "{items}<div class=\"clearfix\"></div>{pager}", |
| @@ -132,9 +130,6 @@ | @@ -132,9 +130,6 @@ | ||
| 132 | 130 | ||
| 133 | ?> | 131 | ?> |
| 134 | 132 | ||
| 135 | - | ||
| 136 | - | ||
| 137 | - | ||
| 138 | <div class="clearfix"></div> | 133 | <div class="clearfix"></div> |
| 139 | </div> | 134 | </div> |
| 140 | 135 | ||
| @@ -142,4 +137,3 @@ | @@ -142,4 +137,3 @@ | ||
| 142 | </div> | 137 | </div> |
| 143 | <?php Pjax::end()?> | 138 | <?php Pjax::end()?> |
| 144 | 139 | ||
| 145 | - |
frontend/views/layouts/main-menu.php
| @@ -4,7 +4,7 @@ use common\modules\product\models\Category; | @@ -4,7 +4,7 @@ use common\modules\product\models\Category; | ||
| 4 | use yii\helpers\Html; | 4 | use yii\helpers\Html; |
| 5 | use yii\helpers\Url; | 5 | use yii\helpers\Url; |
| 6 | 6 | ||
| 7 | -$models = Category::find()->all(); | 7 | +$models = Category::find()->orderBy(['sort' => SORT_ASC])->all(); |
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | ?> | 10 | ?> |