Commit ccc7a9d3dfbff0e810c213d72495c55bb116b44a
1 parent
7ba4acc5
Karnovsky 12052016
Showing
46 changed files
with
1186 additions
and
1279 deletions
Show diff stats
.htaccess
@@ -55,10 +55,12 @@ AddDefaultCharset utf-8 | @@ -55,10 +55,12 @@ AddDefaultCharset utf-8 | ||
55 | 55 | ||
56 | RewriteRule ^img/(.*)$ frontend/web/img/$1 [L] | 56 | RewriteRule ^img/(.*)$ frontend/web/img/$1 [L] |
57 | 57 | ||
58 | + RewriteRule ^files/(.*)$ frontend/web/files/$1 [L] | ||
59 | + | ||
58 | RewriteRule ^fonts/(.*)$ frontend/web/fonts/$1 [L] | 60 | RewriteRule ^fonts/(.*)$ frontend/web/fonts/$1 [L] |
59 | 61 | ||
60 | 62 | ||
61 | - RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css|js|images|img|fonts)/ | 63 | + RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css|js|images|fonts|img|files)/ |
62 | 64 | ||
63 | RewriteCond %{REQUEST_URI} !index.php | 65 | RewriteCond %{REQUEST_URI} !index.php |
64 | 66 |
backend/config/bootstrap.php
@@ -2,4 +2,4 @@ | @@ -2,4 +2,4 @@ | ||
2 | Yii::setAlias('@uploadDir', dirname(dirname(__DIR__)) . '/storage/sync'); | 2 | Yii::setAlias('@uploadDir', dirname(dirname(__DIR__)) . '/storage/sync'); |
3 | Yii::setAlias('@uploadFileProducts', 'products.csv'); | 3 | Yii::setAlias('@uploadFileProducts', 'products.csv'); |
4 | 4 | ||
5 | -Yii::setAlias('@productsDir', dirname(dirname(__DIR__)) . '/storage/products'); | ||
6 | \ No newline at end of file | 5 | \ No newline at end of file |
6 | +Yii::setAlias('@productsDir', 'images/products'); | ||
7 | \ No newline at end of file | 7 | \ No newline at end of file |
backend/views/category/_form.php
@@ -68,19 +68,6 @@ use kartik\select2\Select2; | @@ -68,19 +68,6 @@ use kartik\select2\Select2; | ||
68 | 68 | ||
69 | <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?> | 69 | <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?> |
70 | 70 | ||
71 | - <?= $form->field($model, 'remote_category')->widget(Select2::className(), [ | ||
72 | - 'data' => \yii\helpers\ArrayHelper::map(\common\modules\product\models\RemoteCategories::find()->all(), 'ID', 'Name'), | ||
73 | - 'language' => 'ru', | ||
74 | - 'options' => [ | ||
75 | - 'placeholder' => 'Select a remote category', | ||
76 | - 'multiple' => true, | ||
77 | - ], | ||
78 | - 'pluginOptions' => [ | ||
79 | - 'allowClear' => true | ||
80 | - ], | ||
81 | - ] | ||
82 | - ) ?> | ||
83 | - | ||
84 | <?php if (!empty($model) && $model->depth == 2) :?> | 71 | <?php if (!empty($model) && $model->depth == 2) :?> |
85 | <?= $form->field($model, 'populary')->checkbox() ?> | 72 | <?= $form->field($model, 'populary')->checkbox() ?> |
86 | <?php endif?> | 73 | <?php endif?> |
backend/views/layouts/main-sidebar.php
@@ -25,14 +25,16 @@ use yii\widgets\Menu; | @@ -25,14 +25,16 @@ use yii\widgets\Menu; | ||
25 | ['label' => 'MAIN NAVIGATION', 'options'=>['class'=>'header']], | 25 | ['label' => 'MAIN NAVIGATION', 'options'=>['class'=>'header']], |
26 | ['label' => 'Заказы', 'url' => ['/orders/index'], 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-shopping-cart"></i> <span>{label}</span></a>'], | 26 | ['label' => 'Заказы', 'url' => ['/orders/index'], 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-shopping-cart"></i> <span>{label}</span></a>'], |
27 | [ | 27 | [ |
28 | - 'label' => 'Products', | 28 | + 'label' => 'eCommerce', |
29 | 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-barcode"></i> <span>{label}</span></a>', | 29 | 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-barcode"></i> <span>{label}</span></a>', |
30 | 'url' => ['/product/manage'], | 30 | 'url' => ['/product/manage'], |
31 | 'items' => [ | 31 | 'items' => [ |
32 | ['label' => 'Товары', 'url' => ['/product/manage']], | 32 | ['label' => 'Товары', 'url' => ['/product/manage']], |
33 | - ['label' => 'Импорт товаров', 'url' => ['/product/manage/import']], | ||
34 | ['label' => 'Категории', 'url' => ['/category']], | 33 | ['label' => 'Категории', 'url' => ['/category']], |
35 | ['label' => 'Бренды', 'url' => ['/brand']], | 34 | ['label' => 'Бренды', 'url' => ['/brand']], |
35 | + ['label' => 'Характеристики', 'url' => ['/rubrication/tax-group']], | ||
36 | + ['label' => 'Единицы измерения', 'url' => ['/product/product-unit']], | ||
37 | + ['label' => 'Статистика импорта', 'url' => ['/product/manage/import-stat']], | ||
36 | ] | 38 | ] |
37 | ], | 39 | ], |
38 | [ | 40 | [ |
common/modules/product/CatalogUrlManager.php
@@ -111,6 +111,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -111,6 +111,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
111 | $params['word'] = [$params['word']]; | 111 | $params['word'] = [$params['word']]; |
112 | } | 112 | } |
113 | $url .= 'word:'. implode(';', $params['word']); | 113 | $url .= 'word:'. implode(';', $params['word']); |
114 | + unset($params['word']); | ||
114 | } | 115 | } |
115 | 116 | ||
116 | $filter = []; | 117 | $filter = []; |
@@ -147,6 +148,10 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -147,6 +148,10 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
147 | $url .= 'filter:'. implode(';', $filter); | 148 | $url .= 'filter:'. implode(';', $filter); |
148 | } | 149 | } |
149 | 150 | ||
151 | + if (!empty($params) && ($query = http_build_query($params)) !== '') { | ||
152 | + $url .= '?' . $query; | ||
153 | + } | ||
154 | + | ||
150 | return $url; | 155 | return $url; |
151 | break; | 156 | break; |
152 | 157 | ||
@@ -155,6 +160,11 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -155,6 +160,11 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
155 | $product_alias = is_object($params['product']) ? $params['product']->alias : strtolower($params['product']); | 160 | $product_alias = is_object($params['product']) ? $params['product']->alias : strtolower($params['product']); |
156 | } | 161 | } |
157 | $url = 'product/'. $product_alias; | 162 | $url = 'product/'. $product_alias; |
163 | + | ||
164 | + if (!empty($params) && ($query = http_build_query($params)) !== '') { | ||
165 | + $url .= '?' . $query; | ||
166 | + } | ||
167 | + | ||
158 | return $url; | 168 | return $url; |
159 | break; | 169 | break; |
160 | } | 170 | } |
common/modules/product/controllers/ManageController.php
@@ -4,6 +4,7 @@ namespace common\modules\product\controllers; | @@ -4,6 +4,7 @@ namespace common\modules\product\controllers; | ||
4 | 4 | ||
5 | use common\modules\product\helpers\ProductHelper; | 5 | use common\modules\product\helpers\ProductHelper; |
6 | use common\modules\product\models\Category; | 6 | use common\modules\product\models\Category; |
7 | +use common\modules\product\models\ProductImage; | ||
7 | use common\modules\product\models\ProductVariant; | 8 | use common\modules\product\models\ProductVariant; |
8 | use common\modules\product\models\RemoteProductsSearch; | 9 | use common\modules\product\models\RemoteProductsSearch; |
9 | use Yii; | 10 | use Yii; |
@@ -12,6 +13,10 @@ use common\modules\product\models\ProductSearch; | @@ -12,6 +13,10 @@ use common\modules\product\models\ProductSearch; | ||
12 | use yii\web\Controller; | 13 | use yii\web\Controller; |
13 | use yii\web\NotFoundHttpException; | 14 | use yii\web\NotFoundHttpException; |
14 | use yii\filters\VerbFilter; | 15 | use yii\filters\VerbFilter; |
16 | +use common\modules\product\models\Brand; | ||
17 | +use common\modules\product\models\BrandName; | ||
18 | +use common\modules\product\models\RemoteProducts; | ||
19 | +use yii\web\UploadedFile; | ||
15 | 20 | ||
16 | /** | 21 | /** |
17 | * ManageController implements the CRUD actions for Product model. | 22 | * ManageController implements the CRUD actions for Product model. |
@@ -119,8 +124,25 @@ class ManageController extends Controller | @@ -119,8 +124,25 @@ class ManageController extends Controller | ||
119 | { | 124 | { |
120 | $model = new Product(); | 125 | $model = new Product(); |
121 | 126 | ||
122 | - if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
123 | - return $this->redirect(['view', 'id' => $model->product_id]); | 127 | + if ($model->load(Yii::$app->request->post())) { |
128 | + $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); | ||
129 | + | ||
130 | + if ($model->save()) { | ||
131 | + foreach ($model->images as $image) { | ||
132 | + $image->delete(); | ||
133 | + } | ||
134 | + | ||
135 | + if ( ($images = $model->imagesUpload()) !== FALSE) { | ||
136 | + foreach ($images as $image) { | ||
137 | + $imageModel = new ProductImage(); | ||
138 | + $imageModel->product_id = $model->product_id; | ||
139 | + $imageModel->image = $image; | ||
140 | + $imageModel->save(); | ||
141 | + } | ||
142 | + } | ||
143 | + | ||
144 | + return $this->redirect(['view', 'id' => $model->product_id]); | ||
145 | + } | ||
124 | } else { | 146 | } else { |
125 | return $this->render('create', [ | 147 | return $this->render('create', [ |
126 | 'model' => $model, | 148 | 'model' => $model, |
@@ -138,8 +160,25 @@ class ManageController extends Controller | @@ -138,8 +160,25 @@ class ManageController extends Controller | ||
138 | { | 160 | { |
139 | $model = $this->findModel($id); | 161 | $model = $this->findModel($id); |
140 | 162 | ||
141 | - if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
142 | - return $this->redirect(['view', 'id' => $model->product_id]); | 163 | + if ($model->load(Yii::$app->request->post())) { |
164 | + $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); | ||
165 | + | ||
166 | + if ($model->save()) { | ||
167 | + foreach ($model->images as $image) { | ||
168 | + $image->delete(); | ||
169 | + } | ||
170 | + | ||
171 | + if ( ($images = $model->imagesUpload()) !== FALSE) { | ||
172 | + foreach ($images as $image) { | ||
173 | + $imageModel = new ProductImage(); | ||
174 | + $imageModel->product_id = $model->product_id; | ||
175 | + $imageModel->image = $image; | ||
176 | + $imageModel->save(); | ||
177 | + } | ||
178 | + } | ||
179 | + | ||
180 | + return $this->redirect(['view', 'id' => $model->product_id]); | ||
181 | + } | ||
143 | } else { | 182 | } else { |
144 | $groups = $model->category->getTaxGroups(); | 183 | $groups = $model->category->getTaxGroups(); |
145 | 184 | ||
@@ -163,6 +202,18 @@ class ManageController extends Controller | @@ -163,6 +202,18 @@ class ManageController extends Controller | ||
163 | return $this->redirect(['index']); | 202 | return $this->redirect(['index']); |
164 | } | 203 | } |
165 | 204 | ||
205 | + public function actionDelimg($id) | ||
206 | + { | ||
207 | + $image = ProductImage::findOne($id); | ||
208 | + | ||
209 | + if ($image) { | ||
210 | + $image->delete(); | ||
211 | + } | ||
212 | + | ||
213 | + print '1'; | ||
214 | + exit; | ||
215 | + } | ||
216 | + | ||
166 | public function actionImport() { | 217 | public function actionImport() { |
167 | $searchModel = new RemoteProductsSearch(); | 218 | $searchModel = new RemoteProductsSearch(); |
168 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | 219 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); |
@@ -173,6 +224,47 @@ class ManageController extends Controller | @@ -173,6 +224,47 @@ class ManageController extends Controller | ||
173 | ]); | 224 | ]); |
174 | } | 225 | } |
175 | 226 | ||
227 | + public function actionImportStat() { | ||
228 | + $all_products = $new_products = $linked_products = $orpahed_products = 0; | ||
229 | + $remoteProducts = RemoteProducts::find()->all(); | ||
230 | + | ||
231 | + $not_linked_cats = []; | ||
232 | + | ||
233 | + foreach($remoteProducts as $product) { | ||
234 | + if (!empty($product->product->product_id)) { | ||
235 | + $linked_products++; | ||
236 | + } elseif (!empty($product->remoteCategory) && !empty($product->remoteCategory->category) && !empty($product->remoteCategory->category->category_id)) { | ||
237 | + $new_products++; | ||
238 | + } else { | ||
239 | + if (!empty($product->remoteCategory)) { | ||
240 | + if (empty($not_linked_cats[$product->remoteCategory->ID])) { | ||
241 | + $not_linked_cats[$product->remoteCategory->ID] = $product->remoteCategory->Name ." (". $product->remoteCategory->ID .")"; | ||
242 | + } | ||
243 | + } | ||
244 | + $orpahed_products++; | ||
245 | + } | ||
246 | + $all_products++; | ||
247 | + } | ||
248 | + | ||
249 | + $op = []; | ||
250 | + | ||
251 | + $op[] = "Всего $all_products товаров, $new_products новых и $linked_products уже связанных."; | ||
252 | + if (!empty($not_linked_cats)) { | ||
253 | + $op[] = "$orpahed_products товаров не привязаны к категориям:"; | ||
254 | + foreach ($not_linked_cats as $not_linked_cat) { | ||
255 | + $op[] = "$not_linked_cat"; | ||
256 | + } | ||
257 | + } | ||
258 | + | ||
259 | + return $this->render('import-stat', [ | ||
260 | + 'all_products' => $all_products, | ||
261 | + 'new_products' => $new_products, | ||
262 | + 'linked_products' => $linked_products, | ||
263 | + 'orpahed_products' => $orpahed_products, | ||
264 | + 'not_linked_cats' => $not_linked_cats, | ||
265 | + ]); | ||
266 | + } | ||
267 | + | ||
176 | /** | 268 | /** |
177 | * Finds the Product model based on its primary key value. | 269 | * Finds the Product model based on its primary key value. |
178 | * If the model is not found, a 404 HTTP exception will be thrown. | 270 | * If the model is not found, a 404 HTTP exception will be thrown. |
common/modules/product/controllers/ProductUnitController.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\controllers; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use common\modules\product\models\ProductUnit; | ||
7 | +use common\modules\product\models\ProductUnitSearch; | ||
8 | +use yii\web\Controller; | ||
9 | +use yii\web\NotFoundHttpException; | ||
10 | +use yii\filters\VerbFilter; | ||
11 | + | ||
12 | +/** | ||
13 | + * ProductUnitController implements the CRUD actions for ProductUnit model. | ||
14 | + */ | ||
15 | +class ProductUnitController extends Controller | ||
16 | +{ | ||
17 | + /** | ||
18 | + * @inheritdoc | ||
19 | + */ | ||
20 | + public function behaviors() | ||
21 | + { | ||
22 | + return [ | ||
23 | + 'verbs' => [ | ||
24 | + 'class' => VerbFilter::className(), | ||
25 | + 'actions' => [ | ||
26 | + 'delete' => ['POST'], | ||
27 | + ], | ||
28 | + ], | ||
29 | + ]; | ||
30 | + } | ||
31 | + | ||
32 | + /** | ||
33 | + * Lists all ProductUnit models. | ||
34 | + * @return mixed | ||
35 | + */ | ||
36 | + public function actionIndex() | ||
37 | + { | ||
38 | + $searchModel = new ProductUnitSearch(); | ||
39 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
40 | + | ||
41 | + return $this->render('index', [ | ||
42 | + 'searchModel' => $searchModel, | ||
43 | + 'dataProvider' => $dataProvider, | ||
44 | + ]); | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * Displays a single ProductUnit model. | ||
49 | + * @param integer $id | ||
50 | + * @return mixed | ||
51 | + */ | ||
52 | + public function actionView($id) | ||
53 | + { | ||
54 | + return $this->render('view', [ | ||
55 | + 'model' => $this->findModel($id), | ||
56 | + ]); | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * Creates a new ProductUnit model. | ||
61 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
62 | + * @return mixed | ||
63 | + */ | ||
64 | + public function actionCreate() | ||
65 | + { | ||
66 | + $model = new ProductUnit(); | ||
67 | + | ||
68 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
69 | + return $this->redirect(['view', 'id' => $model->product_unit_id]); | ||
70 | + } else { | ||
71 | + return $this->render('create', [ | ||
72 | + 'model' => $model, | ||
73 | + ]); | ||
74 | + } | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * Updates an existing ProductUnit model. | ||
79 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
80 | + * @param integer $id | ||
81 | + * @return mixed | ||
82 | + */ | ||
83 | + public function actionUpdate($id) | ||
84 | + { | ||
85 | + $model = $this->findModel($id); | ||
86 | + | ||
87 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
88 | + return $this->redirect(['view', 'id' => $model->product_unit_id]); | ||
89 | + } else { | ||
90 | + return $this->render('update', [ | ||
91 | + 'model' => $model, | ||
92 | + ]); | ||
93 | + } | ||
94 | + } | ||
95 | + | ||
96 | + /** | ||
97 | + * Deletes an existing ProductUnit model. | ||
98 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
99 | + * @param integer $id | ||
100 | + * @return mixed | ||
101 | + */ | ||
102 | + public function actionDelete($id) | ||
103 | + { | ||
104 | + $this->findModel($id)->delete(); | ||
105 | + | ||
106 | + return $this->redirect(['index']); | ||
107 | + } | ||
108 | + | ||
109 | + /** | ||
110 | + * Finds the ProductUnit model based on its primary key value. | ||
111 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
112 | + * @param integer $id | ||
113 | + * @return ProductUnit the loaded model | ||
114 | + * @throws NotFoundHttpException if the model cannot be found | ||
115 | + */ | ||
116 | + protected function findModel($id) | ||
117 | + { | ||
118 | + if (($model = ProductUnit::findOne($id)) !== null) { | ||
119 | + return $model; | ||
120 | + } else { | ||
121 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
122 | + } | ||
123 | + } | ||
124 | +} |
common/modules/product/models/Brand.php
@@ -10,6 +10,7 @@ use Yii; | @@ -10,6 +10,7 @@ use Yii; | ||
10 | * This is the model class for table "brand". | 10 | * This is the model class for table "brand". |
11 | * | 11 | * |
12 | * @property integer $brand_id | 12 | * @property integer $brand_id |
13 | + * @property string $remote_id | ||
13 | * @property integer $brand_name_id | 14 | * @property integer $brand_name_id |
14 | * @property string $alias | 15 | * @property string $alias |
15 | * @property string $image | 16 | * @property string $image |
@@ -24,6 +25,8 @@ use Yii; | @@ -24,6 +25,8 @@ use Yii; | ||
24 | */ | 25 | */ |
25 | class Brand extends \yii\db\ActiveRecord | 26 | class Brand extends \yii\db\ActiveRecord |
26 | { | 27 | { |
28 | + public $imageUpload; | ||
29 | + | ||
27 | public function behaviors() | 30 | public function behaviors() |
28 | { | 31 | { |
29 | return [ | 32 | return [ |
@@ -39,7 +42,7 @@ class Brand extends \yii\db\ActiveRecord | @@ -39,7 +42,7 @@ class Brand extends \yii\db\ActiveRecord | ||
39 | 'valueKeyName' => 'value', | 42 | 'valueKeyName' => 'value', |
40 | 'slugKeyName' => 'alias', | 43 | 'slugKeyName' => 'alias', |
41 | 'translit' => true | 44 | 'translit' => true |
42 | - ] | 45 | + ], |
43 | ], | 46 | ], |
44 | ]; | 47 | ]; |
45 | } | 48 | } |
@@ -64,6 +67,9 @@ class Brand extends \yii\db\ActiveRecord | @@ -64,6 +67,9 @@ class Brand extends \yii\db\ActiveRecord | ||
64 | [['alias', 'name'], 'string', 'max' => 250], | 67 | [['alias', 'name'], 'string', 'max' => 250], |
65 | [['image', 'meta_title'], 'string', 'max' => 255], | 68 | [['image', 'meta_title'], 'string', 'max' => 255], |
66 | [['meta_robots'], 'string', 'max' => 50], | 69 | [['meta_robots'], 'string', 'max' => 50], |
70 | + [['remote_id'], 'string', 'max' => 25], | ||
71 | + [['imageUpload'], 'safe'], | ||
72 | + [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], | ||
67 | // [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']], | 73 | // [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']], |
68 | ]; | 74 | ]; |
69 | } | 75 | } |
@@ -79,10 +85,12 @@ class Brand extends \yii\db\ActiveRecord | @@ -79,10 +85,12 @@ class Brand extends \yii\db\ActiveRecord | ||
79 | 'brand_name_id' => Yii::t('product', 'Brand Name ID'), | 85 | 'brand_name_id' => Yii::t('product', 'Brand Name ID'), |
80 | 'alias' => Yii::t('product', 'Alias'), | 86 | 'alias' => Yii::t('product', 'Alias'), |
81 | 'image' => Yii::t('product', 'Image'), | 87 | 'image' => Yii::t('product', 'Image'), |
88 | + 'imageUrl' => Yii::t('product', 'Image'), | ||
82 | 'meta_title' => Yii::t('product', 'Meta Title'), | 89 | 'meta_title' => Yii::t('product', 'Meta Title'), |
83 | 'meta_desc' => Yii::t('product', 'Meta Desc'), | 90 | 'meta_desc' => Yii::t('product', 'Meta Desc'), |
84 | 'meta_robots' => Yii::t('product', 'Meta Robots'), | 91 | 'meta_robots' => Yii::t('product', 'Meta Robots'), |
85 | 'seo_text' => Yii::t('product', 'Seo Text'), | 92 | 'seo_text' => Yii::t('product', 'Seo Text'), |
93 | + 'remote_id' => Yii::t('product', '1C brand name'), | ||
86 | ]; | 94 | ]; |
87 | } | 95 | } |
88 | 96 | ||
@@ -113,4 +121,12 @@ class Brand extends \yii\db\ActiveRecord | @@ -113,4 +121,12 @@ class Brand extends \yii\db\ActiveRecord | ||
113 | public function getName() { | 121 | public function getName() { |
114 | return empty($this->brand_name_id) ? null : $this->brandName->value; | 122 | return empty($this->brand_name_id) ? null : $this->brandName->value; |
115 | } | 123 | } |
124 | + | ||
125 | + public function getImageFile() { | ||
126 | + return empty($this->image) ? null : '/images/brand/'. $this->image; | ||
127 | + } | ||
128 | + | ||
129 | + public function getImageUrl() { | ||
130 | + return empty($this->image) ? null : '/images/brand/'. $this->image; | ||
131 | + } | ||
116 | } | 132 | } |
common/modules/product/models/BrandSearch.php
@@ -12,6 +12,7 @@ use common\modules\product\models\Brand; | @@ -12,6 +12,7 @@ use common\modules\product\models\Brand; | ||
12 | */ | 12 | */ |
13 | class BrandSearch extends Brand | 13 | class BrandSearch extends Brand |
14 | { | 14 | { |
15 | + public $brand_name; | ||
15 | /** | 16 | /** |
16 | * @inheritdoc | 17 | * @inheritdoc |
17 | */ | 18 | */ |
@@ -19,7 +20,7 @@ class BrandSearch extends Brand | @@ -19,7 +20,7 @@ class BrandSearch extends Brand | ||
19 | { | 20 | { |
20 | return [ | 21 | return [ |
21 | [['brand_id', 'brand_name_id'], 'integer'], | 22 | [['brand_id', 'brand_name_id'], 'integer'], |
22 | - [['alias', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text'], 'safe'], | 23 | + [['alias', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text', 'brand_name'], 'safe'], |
23 | ]; | 24 | ]; |
24 | } | 25 | } |
25 | 26 | ||
@@ -57,18 +58,28 @@ class BrandSearch extends Brand | @@ -57,18 +58,28 @@ class BrandSearch extends Brand | ||
57 | return $dataProvider; | 58 | return $dataProvider; |
58 | }*/ | 59 | }*/ |
59 | 60 | ||
61 | + $dataProvider->setSort([ | ||
62 | + 'attributes' => [ | ||
63 | + 'brand_name', | ||
64 | + 'alias' | ||
65 | + ] | ||
66 | + ]); | ||
67 | + | ||
60 | // grid filtering conditions | 68 | // grid filtering conditions |
61 | $query->andFilterWhere([ | 69 | $query->andFilterWhere([ |
62 | 'brand_id' => $this->brand_id, | 70 | 'brand_id' => $this->brand_id, |
63 | 'brand_name_id' => $this->brand_name_id, | 71 | 'brand_name_id' => $this->brand_name_id, |
64 | ]); | 72 | ]); |
65 | 73 | ||
66 | - $query->andFilterWhere(['like', 'alias', $this->alias]) | ||
67 | - ->andFilterWhere(['like', 'image', $this->image]) | ||
68 | - ->andFilterWhere(['like', 'meta_title', $this->meta_title]) | ||
69 | - ->andFilterWhere(['like', 'meta_desc', $this->meta_desc]) | ||
70 | - ->andFilterWhere(['like', 'meta_robots', $this->meta_robots]) | ||
71 | - ->andFilterWhere(['like', 'seo_text', $this->seo_text]); | 74 | + $query->joinWith('brandName'); |
75 | + | ||
76 | + $query->andFilterWhere(['ilike', 'alias', $this->alias]) | ||
77 | + ->andFilterWhere(['ilike', 'image', $this->image]) | ||
78 | + ->andFilterWhere(['ilike', 'meta_title', $this->meta_title]) | ||
79 | + ->andFilterWhere(['ilike', 'meta_desc', $this->meta_desc]) | ||
80 | + ->andFilterWhere(['ilike', 'meta_robots', $this->meta_robots]) | ||
81 | + ->andFilterWhere(['ilike', 'seo_text', $this->seo_text]) | ||
82 | + ->andFilterWhere(['ilike', 'brand_name.value', $this->brand_name]); | ||
72 | 83 | ||
73 | return $dataProvider; | 84 | return $dataProvider; |
74 | } | 85 | } |
common/modules/product/models/Category.php
@@ -34,6 +34,8 @@ use Yii; | @@ -34,6 +34,8 @@ use Yii; | ||
34 | */ | 34 | */ |
35 | class Category extends \yii\db\ActiveRecord | 35 | class Category extends \yii\db\ActiveRecord |
36 | { | 36 | { |
37 | + public $imageUpload; | ||
38 | + | ||
37 | public function behaviors() | 39 | public function behaviors() |
38 | { | 40 | { |
39 | return [ | 41 | return [ |
@@ -89,7 +91,8 @@ class Category extends \yii\db\ActiveRecord | @@ -89,7 +91,8 @@ class Category extends \yii\db\ActiveRecord | ||
89 | [['populary'], 'boolean'], | 91 | [['populary'], 'boolean'], |
90 | [['group_to_category', 'remote_category'], 'safe'], | 92 | [['group_to_category', 'remote_category'], 'safe'], |
91 | [['category_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => CategoryName::className(), 'targetAttribute' => ['category_name_id' => 'category_name_id']], | 93 | [['category_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => CategoryName::className(), 'targetAttribute' => ['category_name_id' => 'category_name_id']], |
92 | - // [['image'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif'], | 94 | + [['imageUpload'], 'safe'], |
95 | + [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], | ||
93 | // [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']], | 96 | // [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']], |
94 | ]; | 97 | ]; |
95 | } | 98 | } |
@@ -105,6 +108,7 @@ class Category extends \yii\db\ActiveRecord | @@ -105,6 +108,7 @@ class Category extends \yii\db\ActiveRecord | ||
105 | 'path' => Yii::t('product', 'Path'), | 108 | 'path' => Yii::t('product', 'Path'), |
106 | 'depth' => Yii::t('product', 'Depth'), | 109 | 'depth' => Yii::t('product', 'Depth'), |
107 | 'image' => Yii::t('product', 'Image'), | 110 | 'image' => Yii::t('product', 'Image'), |
111 | + 'imageUrl' => Yii::t('product', 'Image'), | ||
108 | 'meta_title' => Yii::t('product', 'Meta Title'), | 112 | 'meta_title' => Yii::t('product', 'Meta Title'), |
109 | 'meta_desc' => Yii::t('product', 'Meta Desc'), | 113 | 'meta_desc' => Yii::t('product', 'Meta Desc'), |
110 | 'meta_robots' => Yii::t('product', 'Meta Robots'), | 114 | 'meta_robots' => Yii::t('product', 'Meta Robots'), |
@@ -117,7 +121,8 @@ class Category extends \yii\db\ActiveRecord | @@ -117,7 +121,8 @@ class Category extends \yii\db\ActiveRecord | ||
117 | ]; | 121 | ]; |
118 | } | 122 | } |
119 | 123 | ||
120 | - public static function find() { | 124 | + public static function find() |
125 | + { | ||
121 | return new CategoryQuery(get_called_class()); | 126 | return new CategoryQuery(get_called_class()); |
122 | } | 127 | } |
123 | 128 | ||
@@ -145,28 +150,38 @@ class Category extends \yii\db\ActiveRecord | @@ -145,28 +150,38 @@ class Category extends \yii\db\ActiveRecord | ||
145 | return $this->hasMany(ProductCategory::className(), ['category_id' => 'category_id']); | 150 | return $this->hasMany(ProductCategory::className(), ['category_id' => 'category_id']); |
146 | } | 151 | } |
147 | 152 | ||
148 | - public function getTaxGroups() { | 153 | + public function getTaxGroups() |
154 | + { | ||
149 | return $this->getRelations('tax_group_to_category'); | 155 | return $this->getRelations('tax_group_to_category'); |
150 | } | 156 | } |
151 | 157 | ||
152 | - public function getRemote_category() { | 158 | + public function getRemote_category() |
159 | + { | ||
153 | return ArtboxTreeHelper::getArrayField($this->remote_id); | 160 | return ArtboxTreeHelper::getArrayField($this->remote_id); |
154 | } | 161 | } |
155 | 162 | ||
156 | - public function setRemote_category($value) { | 163 | + public function setRemote_category($value) |
164 | + { | ||
157 | if (!empty($value) && is_array($value)) { | 165 | if (!empty($value) && is_array($value)) { |
158 | $this->remote_id = ArtboxTreeHelper::setArrayField($value, false); | 166 | $this->remote_id = ArtboxTreeHelper::setArrayField($value, false); |
159 | } | 167 | } |
160 | } | 168 | } |
161 | 169 | ||
162 | - public function getCategoryName() { | 170 | + public function getCategoryName() |
171 | + { | ||
163 | return $this->hasOne(CategoryName::className(), ['category_name_id' => 'category_name_id']); | 172 | return $this->hasOne(CategoryName::className(), ['category_name_id' => 'category_name_id']); |
164 | } | 173 | } |
165 | 174 | ||
166 | - public function getName() { | 175 | + public function getName() |
176 | + { | ||
167 | return empty($this->categoryName) ? null : $this->categoryName->value; | 177 | return empty($this->categoryName) ? null : $this->categoryName->value; |
168 | } | 178 | } |
169 | 179 | ||
180 | + public function getImageUrl() | ||
181 | + { | ||
182 | + return empty($this->image) ? null : '/images/category/' . $this->image; | ||
183 | + } | ||
184 | + | ||
170 | public function beforeSave($insert) | 185 | public function beforeSave($insert) |
171 | { | 186 | { |
172 | if (parent::beforeSave($insert)) { | 187 | if (parent::beforeSave($insert)) { |
common/modules/product/models/Product.php
@@ -7,23 +7,23 @@ use common\modules\rubrication\models\TaxOption; | @@ -7,23 +7,23 @@ use common\modules\rubrication\models\TaxOption; | ||
7 | use Yii; | 7 | use Yii; |
8 | use common\modules\relation\relationBehavior; | 8 | use common\modules\relation\relationBehavior; |
9 | use yii\db\ActiveQuery; | 9 | use yii\db\ActiveQuery; |
10 | +use yii\helpers\Html; | ||
11 | +use yii\web\UploadedFile; | ||
10 | 12 | ||
11 | /** | 13 | /** |
12 | * This is the model class for table "{{%product}}". | 14 | * This is the model class for table "{{%product}}". |
13 | * | 15 | * |
14 | - * @property integer $product_id | ||
15 | * @property string $name | 16 | * @property string $name |
16 | - * @property string $alias | ||
17 | - * @property string $video | ||
18 | - * @property string $description | ||
19 | * @property integer $brand_id | 17 | * @property integer $brand_id |
20 | - * @property Brand $brand | 18 | + * @property integer $product_id |
21 | * @property Category $category | 19 | * @property Category $category |
22 | * @property array $categories | 20 | * @property array $categories |
21 | + * @property array of ProductVariant $variants | ||
23 | * @property ProductVariant $variant | 22 | * @property ProductVariant $variant |
24 | - * @property array $variants | ||
25 | * @property ProductImage $image | 23 | * @property ProductImage $image |
26 | * @property array $images | 24 | * @property array $images |
25 | + * @property boolean $is_top | ||
26 | + * @property boolean $is_new | ||
27 | */ | 27 | */ |
28 | class Product extends \yii\db\ActiveRecord | 28 | class Product extends \yii\db\ActiveRecord |
29 | { | 29 | { |
@@ -71,9 +71,10 @@ class Product extends \yii\db\ActiveRecord | @@ -71,9 +71,10 @@ class Product extends \yii\db\ActiveRecord | ||
71 | [['brand_id'], 'integer'], | 71 | [['brand_id'], 'integer'], |
72 | [['name'], 'string', 'max' => 150], | 72 | [['name'], 'string', 'max' => 150], |
73 | [['alias'], 'string', 'max' => 250], | 73 | [['alias'], 'string', 'max' => 250], |
74 | - [['categories', 'variants', 'options'], 'safe'], | ||
75 | -// [['imagesUpload'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif'], | 74 | + [['categories', 'variants', 'options', 'imagesUpload'], 'safe'], |
75 | + [['imagesUpload'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif', 'maxFiles' => 50], | ||
76 | [['description', 'video'], 'safe'], | 76 | [['description', 'video'], 'safe'], |
77 | + [['is_top', 'is_new'], 'boolean'], | ||
77 | // [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], | 78 | // [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], |
78 | ]; | 79 | ]; |
79 | } | 80 | } |
@@ -91,6 +92,11 @@ class Product extends \yii\db\ActiveRecord | @@ -91,6 +92,11 @@ class Product extends \yii\db\ActiveRecord | ||
91 | 'category' => Yii::t('product', 'Category'), // relation behavior field | 92 | 'category' => Yii::t('product', 'Category'), // relation behavior field |
92 | 'image' => Yii::t('product', 'Image'), | 93 | 'image' => Yii::t('product', 'Image'), |
93 | 'images' => Yii::t('product', 'Images'), | 94 | 'images' => Yii::t('product', 'Images'), |
95 | + 'description' => Yii::t('product', 'Description'), | ||
96 | + 'video' => Yii::t('product', 'Video embeded'), | ||
97 | + 'variants' => Yii::t('product', 'Variants'), | ||
98 | + 'is_top' => Yii::t('product', 'Is top'), | ||
99 | + 'is_new' => Yii::t('product', 'Is new'), | ||
94 | ]; | 100 | ]; |
95 | } | 101 | } |
96 | 102 | ||
@@ -118,10 +124,6 @@ class Product extends \yii\db\ActiveRecord | @@ -118,10 +124,6 @@ class Product extends \yii\db\ActiveRecord | ||
118 | return $this->hasMany(ProductImage::className(), ['product_id' => 'product_id']); | 124 | return $this->hasMany(ProductImage::className(), ['product_id' => 'product_id']); |
119 | } | 125 | } |
120 | 126 | ||
121 | - public function setImages($images) { | ||
122 | - $this->_images = $images; | ||
123 | - } | ||
124 | - | ||
125 | /** | 127 | /** |
126 | * @return \yii\db\ActiveQuery | 128 | * @return \yii\db\ActiveQuery |
127 | */ | 129 | */ |
@@ -151,7 +153,8 @@ class Product extends \yii\db\ActiveRecord | @@ -151,7 +153,8 @@ class Product extends \yii\db\ActiveRecord | ||
151 | } | 153 | } |
152 | 154 | ||
153 | public function getCategories() { | 155 | public function getCategories() { |
154 | - return $this->getRelations('product_categories'); | 156 | + return $this->hasMany(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']); |
157 | +// return $this->getRelations('product_categories'); | ||
155 | } | 158 | } |
156 | 159 | ||
157 | public function getCategoriesNames() { | 160 | public function getCategoriesNames() { |
@@ -163,12 +166,7 @@ class Product extends \yii\db\ActiveRecord | @@ -163,12 +166,7 @@ class Product extends \yii\db\ActiveRecord | ||
163 | } | 166 | } |
164 | 167 | ||
165 | public function getCategory() { | 168 | public function getCategory() { |
166 | - /** @var ActiveQuery $categories */ | ||
167 | - $categories = $this->getRelations('product_categories'); | ||
168 | - $count = $categories->count(); | ||
169 | - if ($count == 0) | ||
170 | - return; | ||
171 | - return $categories->one(); | 169 | + return $this->hasOne(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']); |
172 | } | 170 | } |
173 | 171 | ||
174 | public function getOptions() { | 172 | public function getOptions() { |
@@ -188,8 +186,18 @@ class Product extends \yii\db\ActiveRecord | @@ -188,8 +186,18 @@ class Product extends \yii\db\ActiveRecord | ||
188 | { | 186 | { |
189 | parent::afterSave($insert, $changedAttributes); | 187 | parent::afterSave($insert, $changedAttributes); |
190 | 188 | ||
191 | -// foreach($this->imagesUpload as $image) { | ||
192 | -// $image->saveAs('/images/items/' . $image->baseName .'_'. uniqid() . '.' . $image->extension); | 189 | +// $images = UploadedFile::getInstance($this, 'imagesUpload'); |
190 | +// var_dump($images);exit; | ||
191 | + | ||
192 | +// if (!empty($this->imagesUpload)) { | ||
193 | +// if (!is_array($this->imagesUpload)) { | ||
194 | +// $this->imagesUpload = [$this->imagesUpload]; | ||
195 | +// } | ||
196 | +// foreach($this->imagesUpload as $image) { | ||
197 | +// $image->saveAs((Yii::getAlias('@frontend/web/storage/products/original/' . $image->baseName .'_'. uniqid() . '.' . $image->extension))); | ||
198 | +// } | ||
199 | +// | ||
200 | +// | ||
193 | // } | 201 | // } |
194 | 202 | ||
195 | $todel = []; | 203 | $todel = []; |
@@ -214,4 +222,53 @@ class Product extends \yii\db\ActiveRecord | @@ -214,4 +222,53 @@ class Product extends \yii\db\ActiveRecord | ||
214 | ProductVariant::deleteAll(['product_variant_id' => $todel]); | 222 | ProductVariant::deleteAll(['product_variant_id' => $todel]); |
215 | } | 223 | } |
216 | } | 224 | } |
225 | + | ||
226 | + public function imagesUpload() | ||
227 | + { | ||
228 | + if ($this->validate()) { | ||
229 | + $images = []; | ||
230 | + foreach ($this->imagesUpload as $image) { | ||
231 | + $imageName = $image->baseName .'.'. $image->extension; | ||
232 | + $i = 0; | ||
233 | + while(file_exists(Yii::getAlias('@frontend/web/images/products/' . $imageName))) { | ||
234 | + $i++; | ||
235 | + $imageName = $image->baseName .'_'. $i .'.'. $image->extension; | ||
236 | + } | ||
237 | + | ||
238 | + $image->saveAs(Yii::getAlias('@frontend/web/images/products/' .$imageName)); | ||
239 | + $images[] = $imageName; | ||
240 | + } | ||
241 | + return $images; | ||
242 | + } else { | ||
243 | + return false; | ||
244 | + } | ||
245 | + } | ||
246 | + | ||
247 | + public function getImagesHTML() { | ||
248 | + $op = []; | ||
249 | + if ($this->images) { | ||
250 | + foreach ($this->images as $image) { | ||
251 | + $op[] = Html::img($image->imageUrl); | ||
252 | + } | ||
253 | + } | ||
254 | + return $op; | ||
255 | + } | ||
256 | + | ||
257 | + public function getImagesConfig() { | ||
258 | + $op = []; | ||
259 | + if ($this->images) { | ||
260 | + foreach ($this->images as $image) { | ||
261 | + $op[] = [ | ||
262 | + 'caption' => $image->image, | ||
263 | + 'width' => '120px', | ||
264 | + 'url' => \yii\helpers\Url::to(['/product/manage/delimg', 'id' => $image->product_image_id]), | ||
265 | + 'key' => $image->product_image_id, | ||
266 | + 'extra' => [ | ||
267 | + 'id' => $image->product_image_id, | ||
268 | + ], | ||
269 | + ]; | ||
270 | + } | ||
271 | + } | ||
272 | + return $op; | ||
273 | + } | ||
217 | } | 274 | } |
common/modules/product/models/ProductImage.php
@@ -9,16 +9,17 @@ use yii\web\UploadedFile; | @@ -9,16 +9,17 @@ use yii\web\UploadedFile; | ||
9 | * This is the model class for table "product_image". | 9 | * This is the model class for table "product_image". |
10 | * | 10 | * |
11 | * @property integer $product_image_id | 11 | * @property integer $product_image_id |
12 | + * @property integer $product_id | ||
12 | * @property integer $product_variant_id | 13 | * @property integer $product_variant_id |
13 | * @property string $image | 14 | * @property string $image |
14 | * @property string $alt | 15 | * @property string $alt |
15 | * @property string $title | 16 | * @property string $title |
16 | - * | ||
17 | * @property Product $product | 17 | * @property Product $product |
18 | + * @property ProductVariant $productVariant | ||
18 | */ | 19 | */ |
19 | class ProductImage extends \yii\db\ActiveRecord | 20 | class ProductImage extends \yii\db\ActiveRecord |
20 | { | 21 | { |
21 | - public $image; | 22 | + public $imageUpload; |
22 | /** | 23 | /** |
23 | * @inheritdoc | 24 | * @inheritdoc |
24 | */ | 25 | */ |
@@ -33,12 +34,13 @@ class ProductImage extends \yii\db\ActiveRecord | @@ -33,12 +34,13 @@ class ProductImage extends \yii\db\ActiveRecord | ||
33 | public function rules() | 34 | public function rules() |
34 | { | 35 | { |
35 | return [ | 36 | return [ |
36 | - [['product_image_id', 'product_variant_id'], 'required'], | ||
37 | - [['product_image_id', 'product_variant_id'], 'integer'], | ||
38 | - [['alt', 'title'], 'string', 'max' => 255], | ||
39 | - [['image'], 'safe'], | 37 | + [['product_id'], 'required'], |
38 | + [['product_image_id', 'product_id', 'product_variant_id'], 'integer'], | ||
39 | + [['alt', 'title', 'image'], 'string', 'max' => 255], | ||
40 | + [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], | ||
40 | [['product_variant_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductVariant::className(), 'targetAttribute' => ['product_variant_id' => 'product_variant_id']], | 41 | [['product_variant_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductVariant::className(), 'targetAttribute' => ['product_variant_id' => 'product_variant_id']], |
41 | - [['image'], 'file', 'extensions'=>'jpg, gif, png'], | 42 | + [['imageUpload'], 'safe'], |
43 | + [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], | ||
42 | ]; | 44 | ]; |
43 | } | 45 | } |
44 | 46 | ||
@@ -49,7 +51,11 @@ class ProductImage extends \yii\db\ActiveRecord | @@ -49,7 +51,11 @@ class ProductImage extends \yii\db\ActiveRecord | ||
49 | { | 51 | { |
50 | return [ | 52 | return [ |
51 | 'product_image_id' => Yii::t('product', 'Product Image ID'), | 53 | 'product_image_id' => Yii::t('product', 'Product Image ID'), |
54 | + 'product_id' => Yii::t('product', 'Product ID'), | ||
52 | 'product_variant_id' => Yii::t('product', 'Product Variant ID'), | 55 | 'product_variant_id' => Yii::t('product', 'Product Variant ID'), |
56 | + 'product' => Yii::t('product', 'Product'), | ||
57 | + 'product' => Yii::t('product', 'Product'), | ||
58 | + 'product_variant' => Yii::t('product', 'Product Variant'), | ||
53 | 'image' => Yii::t('product', 'Image'), | 59 | 'image' => Yii::t('product', 'Image'), |
54 | 'alt' => Yii::t('product', 'Alt'), | 60 | 'alt' => Yii::t('product', 'Alt'), |
55 | 'title' => Yii::t('product', 'Title'), | 61 | 'title' => Yii::t('product', 'Title'), |
@@ -59,9 +65,21 @@ class ProductImage extends \yii\db\ActiveRecord | @@ -59,9 +65,21 @@ class ProductImage extends \yii\db\ActiveRecord | ||
59 | /** | 65 | /** |
60 | * @return \yii\db\ActiveQuery | 66 | * @return \yii\db\ActiveQuery |
61 | */ | 67 | */ |
68 | + public function getProduct() | ||
69 | + { | ||
70 | + $return = $this->hasOne(Product::className(), ['product_id' => 'product_id']); | ||
71 | + if (empty($return)) { | ||
72 | + $return = $this->productVariant->product_id; | ||
73 | + } | ||
74 | + return $return; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * @return \yii\db\ActiveQuery | ||
79 | + */ | ||
62 | public function getProductVariant() | 80 | public function getProductVariant() |
63 | { | 81 | { |
64 | - return $this->hasOne(ProductVariant::className(), ['product_variant_id' => 'product_variant_id']); | 82 | + return $this->hasOne(Product::className(), ['product_variant_id' => 'product_variant_id']); |
65 | } | 83 | } |
66 | 84 | ||
67 | /** | 85 | /** |
@@ -79,7 +97,7 @@ class ProductImage extends \yii\db\ActiveRecord | @@ -79,7 +97,7 @@ class ProductImage extends \yii\db\ActiveRecord | ||
79 | */ | 97 | */ |
80 | public function getImageFile() | 98 | public function getImageFile() |
81 | { | 99 | { |
82 | - return isset($this->image) ? Yii::$app->params['uploadPath'] . $this->image : null; | 100 | + return isset($this->image) ? '/images/products/' . $this->image : null; |
83 | } | 101 | } |
84 | 102 | ||
85 | /** | 103 | /** |
@@ -89,8 +107,7 @@ class ProductImage extends \yii\db\ActiveRecord | @@ -89,8 +107,7 @@ class ProductImage extends \yii\db\ActiveRecord | ||
89 | public function getImageUrl() | 107 | public function getImageUrl() |
90 | { | 108 | { |
91 | // return a default image placeholder if your source image is not found | 109 | // return a default image placeholder if your source image is not found |
92 | - $image = isset($this->image) ? $this->image : 'default.jpg'; | ||
93 | - return Yii::$app->params['uploadUrl'] . $image; | 110 | + return isset($this->image) ? '/images/products/'. $this->image : 'default.jpg'; |
94 | } | 111 | } |
95 | 112 | ||
96 | /** | 113 | /** |
@@ -102,7 +119,7 @@ class ProductImage extends \yii\db\ActiveRecord | @@ -102,7 +119,7 @@ class ProductImage extends \yii\db\ActiveRecord | ||
102 | // get the uploaded file instance. for multiple file uploads | 119 | // get the uploaded file instance. for multiple file uploads |
103 | // the following data will return an array (you may need to use | 120 | // the following data will return an array (you may need to use |
104 | // getInstances method) | 121 | // getInstances method) |
105 | - $image = UploadedFile::getInstance($this, 'image'); | 122 | + $image = UploadedFile::getInstance($this, 'imageUpload'); |
106 | 123 | ||
107 | // if no image was uploaded abort the upload | 124 | // if no image was uploaded abort the upload |
108 | if (empty($image)) { | 125 | if (empty($image)) { |
@@ -111,8 +128,7 @@ class ProductImage extends \yii\db\ActiveRecord | @@ -111,8 +128,7 @@ class ProductImage extends \yii\db\ActiveRecord | ||
111 | 128 | ||
112 | // store the source file name | 129 | // store the source file name |
113 | $this->filename = $image->name; | 130 | $this->filename = $image->name; |
114 | - $exploded = explode(".", $image->name); | ||
115 | - $ext = end($exploded); | 131 | + $ext = end((explode(".", $image->name))); |
116 | 132 | ||
117 | // generate a unique file name | 133 | // generate a unique file name |
118 | $this->image = Yii::$app->security->generateRandomString().".{$ext}"; | 134 | $this->image = Yii::$app->security->generateRandomString().".{$ext}"; |
common/modules/product/models/ProductSearch.php
@@ -13,14 +13,18 @@ use yii\web\NotFoundHttpException; | @@ -13,14 +13,18 @@ use yii\web\NotFoundHttpException; | ||
13 | */ | 13 | */ |
14 | class ProductSearch extends Product | 14 | class ProductSearch extends Product |
15 | { | 15 | { |
16 | + public $brand_name; | ||
17 | + public $category_name; | ||
18 | + | ||
16 | /** | 19 | /** |
17 | * @inheritdoc | 20 | * @inheritdoc |
18 | */ | 21 | */ |
19 | public function rules() | 22 | public function rules() |
20 | { | 23 | { |
21 | return [ | 24 | return [ |
22 | - [['name'], 'safe'], | 25 | + [['name', 'brand_name', 'category_name'], 'safe'], |
23 | [['tax_brand_id', 'product_id'], 'integer'], | 26 | [['tax_brand_id', 'product_id'], 'integer'], |
27 | + [['is_top', 'is_new'], 'boolean'], | ||
24 | ]; | 28 | ]; |
25 | } | 29 | } |
26 | 30 | ||
@@ -58,13 +62,27 @@ class ProductSearch extends Product | @@ -58,13 +62,27 @@ class ProductSearch extends Product | ||
58 | return $dataProvider; | 62 | return $dataProvider; |
59 | } | 63 | } |
60 | 64 | ||
65 | + $dataProvider->setSort([ | ||
66 | + 'attributes' => [ | ||
67 | + 'name', | ||
68 | + 'brand_name', | ||
69 | + 'category_name' | ||
70 | + ] | ||
71 | + ]); | ||
72 | + | ||
73 | + $query->joinWith(['brand', 'brand.brandNames', 'categories', 'categories.categoryNames']); | ||
74 | + | ||
61 | // grid filtering conditions | 75 | // grid filtering conditions |
62 | $query->andFilterWhere([ | 76 | $query->andFilterWhere([ |
63 | 'tax_brand_id' => $this->tax_brand_id, | 77 | 'tax_brand_id' => $this->tax_brand_id, |
64 | 'product_id' => $this->product_id, | 78 | 'product_id' => $this->product_id, |
79 | + 'is_top' => (bool)$this->is_top, | ||
80 | + 'is_new' => (bool)$this->is_new, | ||
65 | ]); | 81 | ]); |
66 | 82 | ||
67 | - $query->andFilterWhere(['like', 'name', $this->name]); | 83 | + $query->andFilterWhere(['ilike', 'name', $this->name]); |
84 | + $query->andFilterWhere(['ilike', 'brand_name.value', $this->brand_name]); | ||
85 | + $query->andFilterWhere(['ilike', 'category_name.value', $this->category_name]); | ||
68 | 86 | ||
69 | return $dataProvider; | 87 | return $dataProvider; |
70 | } | 88 | } |
common/modules/product/models/RemoteCategoriesSearch.php renamed to common/modules/product/models/ProductUnitSearch.php
100755 → 100644
@@ -5,12 +5,12 @@ namespace common\modules\product\models; | @@ -5,12 +5,12 @@ namespace common\modules\product\models; | ||
5 | use Yii; | 5 | use Yii; |
6 | use yii\base\Model; | 6 | use yii\base\Model; |
7 | use yii\data\ActiveDataProvider; | 7 | use yii\data\ActiveDataProvider; |
8 | -use common\modules\product\models\RemoteCategories; | 8 | +use common\modules\product\models\ProductUnit; |
9 | 9 | ||
10 | /** | 10 | /** |
11 | - * RemoteCategoriesSearch represents the model behind the search form about `common\modules\product\models\RemoteCategories`. | 11 | + * ProductUnitSearch represents the model behind the search form about `common\modules\product\models\ProductUnit`. |
12 | */ | 12 | */ |
13 | -class RemoteCategoriesSearch extends RemoteCategories | 13 | +class ProductUnitSearch extends ProductUnit |
14 | { | 14 | { |
15 | /** | 15 | /** |
16 | * @inheritdoc | 16 | * @inheritdoc |
@@ -18,8 +18,9 @@ class RemoteCategoriesSearch extends RemoteCategories | @@ -18,8 +18,9 @@ class RemoteCategoriesSearch extends RemoteCategories | ||
18 | public function rules() | 18 | public function rules() |
19 | { | 19 | { |
20 | return [ | 20 | return [ |
21 | - [['Name', 'ID_chief', 'ID'], 'safe'], | ||
22 | - [['local_id'], 'integer'], | 21 | + [['product_unit_id'], 'integer'], |
22 | + [['name', 'code'], 'safe'], | ||
23 | + [['is_default'], 'boolean'], | ||
23 | ]; | 24 | ]; |
24 | } | 25 | } |
25 | 26 | ||
@@ -41,7 +42,7 @@ class RemoteCategoriesSearch extends RemoteCategories | @@ -41,7 +42,7 @@ class RemoteCategoriesSearch extends RemoteCategories | ||
41 | */ | 42 | */ |
42 | public function search($params) | 43 | public function search($params) |
43 | { | 44 | { |
44 | - $query = RemoteCategories::find(); | 45 | + $query = ProductUnit::find(); |
45 | 46 | ||
46 | // add conditions that should always apply here | 47 | // add conditions that should always apply here |
47 | 48 | ||
@@ -59,12 +60,12 @@ class RemoteCategoriesSearch extends RemoteCategories | @@ -59,12 +60,12 @@ class RemoteCategoriesSearch extends RemoteCategories | ||
59 | 60 | ||
60 | // grid filtering conditions | 61 | // grid filtering conditions |
61 | $query->andFilterWhere([ | 62 | $query->andFilterWhere([ |
62 | - 'local_id' => $this->local_id, | 63 | + 'product_unit_id' => $this->product_unit_id, |
64 | + 'is_default' => $this->is_default, | ||
63 | ]); | 65 | ]); |
64 | 66 | ||
65 | - $query->andFilterWhere(['like', 'Name', $this->Name]) | ||
66 | - ->andFilterWhere(['like', 'ID_chief', $this->ID_chief]) | ||
67 | - ->andFilterWhere(['like', 'ID', $this->ID]); | 67 | + $query->andFilterWhere(['like', 'name', $this->name]) |
68 | + ->andFilterWhere(['like', 'code', $this->code]); | ||
68 | 69 | ||
69 | return $dataProvider; | 70 | return $dataProvider; |
70 | } | 71 | } |
common/modules/product/models/ProductVariant.php
@@ -16,12 +16,16 @@ use Yii; | @@ -16,12 +16,16 @@ use Yii; | ||
16 | * @property double $price_old | 16 | * @property double $price_old |
17 | * @property double $stock | 17 | * @property double $stock |
18 | * @property integer $product_unit_id | 18 | * @property integer $product_unit_id |
19 | - * @property ProductUnit $productUnit | ||
20 | * @property integer $product_variant_type_id | 19 | * @property integer $product_variant_type_id |
21 | - * @property ProductVariantType $productVariantType | 20 | + * @property ProductImage $image |
21 | + * @property array $images | ||
22 | + * | ||
23 | + * @property ProductUnit $productUnit | ||
22 | */ | 24 | */ |
23 | class ProductVariant extends \yii\db\ActiveRecord | 25 | class ProductVariant extends \yii\db\ActiveRecord |
24 | { | 26 | { |
27 | + /** @var array $_images */ | ||
28 | + public $imagesUpload = []; | ||
25 | /** | 29 | /** |
26 | * @inheritdoc | 30 | * @inheritdoc |
27 | */ | 31 | */ |
@@ -41,8 +45,9 @@ class ProductVariant extends \yii\db\ActiveRecord | @@ -41,8 +45,9 @@ class ProductVariant extends \yii\db\ActiveRecord | ||
41 | [['price', 'price_old', 'stock'], 'number'], | 45 | [['price', 'price_old', 'stock'], 'number'], |
42 | [['name', 'sku'], 'string', 'max' => 255], | 46 | [['name', 'sku'], 'string', 'max' => 255], |
43 | [['remote_id'], 'string', 'max' => 20], | 47 | [['remote_id'], 'string', 'max' => 20], |
48 | + [['imagesUpload'], 'safe'], | ||
49 | + [['imagesUpload'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif', 'maxFiles' => 50], | ||
44 | [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']], | 50 | [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']], |
45 | - [['product_variant_type_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductVariantType::className(), 'targetAttribute' => ['product_variant_type_id' => 'product_variant_type_id']], | ||
46 | ]; | 51 | ]; |
47 | } | 52 | } |
48 | 53 | ||
@@ -59,8 +64,11 @@ class ProductVariant extends \yii\db\ActiveRecord | @@ -59,8 +64,11 @@ class ProductVariant extends \yii\db\ActiveRecord | ||
59 | 'price' => Yii::t('product', 'Price'), | 64 | 'price' => Yii::t('product', 'Price'), |
60 | 'price_old' => Yii::t('product', 'Price Old'), | 65 | 'price_old' => Yii::t('product', 'Price Old'), |
61 | 'stock' => Yii::t('product', 'Stock'), | 66 | 'stock' => Yii::t('product', 'Stock'), |
62 | - 'product_unit_id' => Yii::t('product', 'Unit'), | ||
63 | - 'product_variant_type_id' => 'Type of the variant', | 67 | + 'product_unit_id' => Yii::t('product', 'Product Unit ID'), |
68 | + 'product_variant_type_id' => Yii::t('product', 'Product Variant Type ID'), | ||
69 | + 'stock_caption' => Yii::t('product', 'Stock'), | ||
70 | + 'image' => Yii::t('product', 'Image'), | ||
71 | + 'images' => Yii::t('product', 'Images'), | ||
64 | ]; | 72 | ]; |
65 | } | 73 | } |
66 | 74 | ||
@@ -75,30 +83,41 @@ class ProductVariant extends \yii\db\ActiveRecord | @@ -75,30 +83,41 @@ class ProductVariant extends \yii\db\ActiveRecord | ||
75 | /** | 83 | /** |
76 | * @return \yii\db\ActiveQuery | 84 | * @return \yii\db\ActiveQuery |
77 | */ | 85 | */ |
78 | - public function getProduct() | 86 | + public function getProductVariantType() |
79 | { | 87 | { |
80 | - return $this->hasOne(Product::className(), ['product_id' => 'product_id']); | 88 | + return $this->hasOne(ProductVariantType::className(), ['product_variant_type_id' => 'product_variant_type_id']); |
81 | } | 89 | } |
82 | 90 | ||
83 | /** | 91 | /** |
84 | * @return \yii\db\ActiveQuery | 92 | * @return \yii\db\ActiveQuery |
85 | */ | 93 | */ |
86 | - public function getProductVariantType() { | ||
87 | - return $this->hasOne(ProductVariantType::className(), ['product_variant_type_id' => 'product_variant_type_id']); | 94 | + public function getProduct() |
95 | + { | ||
96 | + return $this->hasOne(Product::className(), ['product_id' => 'product_id']); | ||
97 | + } | ||
98 | + | ||
99 | + public function getEnabled() { | ||
100 | + return $this->stock !== 0; | ||
101 | + } | ||
102 | + | ||
103 | + public function getStock_caption() { | ||
104 | + return is_null($this->stock) ? '∞' : intval($this->stock); | ||
88 | } | 105 | } |
89 | 106 | ||
90 | /** | 107 | /** |
91 | * @return \yii\db\ActiveQuery | 108 | * @return \yii\db\ActiveQuery |
92 | */ | 109 | */ |
93 | - public function getImages() { | ||
94 | - return $this->hasMany(ProductImage::className(), ['product_variant_id' => 'product_variant_id']); | 110 | + public function getImage() |
111 | + { | ||
112 | + return $this->hasOne(ProductImage::className(), ['product_variant_id' => 'product_variant_id']); | ||
95 | } | 113 | } |
96 | 114 | ||
97 | /** | 115 | /** |
98 | * @return \yii\db\ActiveQuery | 116 | * @return \yii\db\ActiveQuery |
99 | */ | 117 | */ |
100 | - public function getImage() { | ||
101 | - return $this->hasOne(ProductImage::className(), ['product_variant_id' => 'product_variant_id']); | 118 | + public function getImages() |
119 | + { | ||
120 | + return $this->hasMany(ProductImage::className(), ['product_variant_id' => 'product_variant_id']); | ||
102 | } | 121 | } |
103 | 122 | ||
104 | /** | 123 | /** |
common/modules/product/models/RemoteCategories.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace common\modules\product\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | - | ||
7 | -/** | ||
8 | - * This is the model class for table "remote_categories". | ||
9 | - * | ||
10 | - * @property string $Name | ||
11 | - * @property string $ID_chief | ||
12 | - * @property string $ID | ||
13 | - */ | ||
14 | -class RemoteCategories extends \yii\db\ActiveRecord | ||
15 | -{ | ||
16 | - /** | ||
17 | - * @inheritdoc | ||
18 | - */ | ||
19 | - public static function tableName() | ||
20 | - { | ||
21 | - return 'remote_categories'; | ||
22 | - } | ||
23 | - | ||
24 | - /** | ||
25 | - * @inheritdoc | ||
26 | - */ | ||
27 | - public function rules() | ||
28 | - { | ||
29 | - return [ | ||
30 | - [['Name'], 'string', 'max' => 100], | ||
31 | - [['ID_chief', 'ID'], 'string', 'max' => 20], | ||
32 | - ]; | ||
33 | - } | ||
34 | - | ||
35 | - /** | ||
36 | - * @inheritdoc | ||
37 | - */ | ||
38 | - public function attributeLabels() | ||
39 | - { | ||
40 | - return [ | ||
41 | - 'Name' => Yii::t('product', 'Name'), | ||
42 | - 'ID_chief' => Yii::t('product', 'Id Chief'), | ||
43 | - 'ID' => Yii::t('product', 'ID'), | ||
44 | - ]; | ||
45 | - } | ||
46 | - | ||
47 | - public function getCategory() { | ||
48 | - if (empty($this->ID)) { | ||
49 | - return null; | ||
50 | - } | ||
51 | - return CategorySearch::findByRemoteID($this->ID); | ||
52 | - } | ||
53 | - | ||
54 | - public static function findByID($id) { | ||
55 | - /** @var CategoryQuery $query */ | ||
56 | - $query = RemoteCategories::find() | ||
57 | - ->andFilterWhere(['ID' => $id]); | ||
58 | - if (($model = $query->one()) !== null) { | ||
59 | - return $model; | ||
60 | - } | ||
61 | - return null; | ||
62 | - } | ||
63 | -} |
common/modules/product/models/RemoteProducts.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace common\modules\product\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | - | ||
7 | -/** | ||
8 | - * This is the model class for table "remote_products". | ||
9 | - * | ||
10 | - * @property string $Name | ||
11 | - * @property string $Price | ||
12 | - * @property string $Price_old | ||
13 | - * @property string $ID_chief | ||
14 | - * @property string $Article | ||
15 | - * @property string $Brand | ||
16 | - * @property string $ID | ||
17 | - * @property string $Date_create | ||
18 | - * @property integer $local_id | ||
19 | - * @property ProductVariant $product | ||
20 | - * @property RemoteCategories $remoteCategory | ||
21 | - */ | ||
22 | -class RemoteProducts extends \yii\db\ActiveRecord | ||
23 | -{ | ||
24 | - /** | ||
25 | - * @inheritdoc | ||
26 | - */ | ||
27 | - public static function tableName() | ||
28 | - { | ||
29 | - return 'remote_products'; | ||
30 | - } | ||
31 | - | ||
32 | - /** | ||
33 | - * @inheritdoc | ||
34 | - */ | ||
35 | - public function rules() | ||
36 | - { | ||
37 | - return [ | ||
38 | - [['Price', 'Price_old'], 'number'], | ||
39 | - [['Date_create'], 'safe'], | ||
40 | - [['Name'], 'string', 'max' => 100], | ||
41 | - [['ID_chief', 'Article', 'ID'], 'string', 'max' => 20], | ||
42 | - [['Brand'], 'string', 'max' => 25], | ||
43 | - ]; | ||
44 | - } | ||
45 | - | ||
46 | - /** | ||
47 | - * @inheritdoc | ||
48 | - */ | ||
49 | - public function attributeLabels() | ||
50 | - { | ||
51 | - return [ | ||
52 | - 'Name' => Yii::t('product', 'Name'), | ||
53 | - 'Price' => Yii::t('product', 'Price'), | ||
54 | - 'Price_old' => Yii::t('product', 'Price Old'), | ||
55 | - 'ID_chief' => Yii::t('product', 'Id Chief'), | ||
56 | - 'Article' => Yii::t('product', 'Article'), | ||
57 | - 'Brand' => Yii::t('product', 'Brand'), | ||
58 | - 'ID' => Yii::t('product', 'ID'), | ||
59 | - 'Date_create' => Yii::t('product', 'Date Create'), | ||
60 | - 'local_id' => Yii::t('product', 'Local ID'), | ||
61 | - ]; | ||
62 | - } | ||
63 | - | ||
64 | - public function getRemoteCategory() { | ||
65 | - if (empty($this->ID_chief)) { | ||
66 | - return null; | ||
67 | - } | ||
68 | - return RemoteCategories::findByID($this->ID_chief); | ||
69 | - } | ||
70 | - | ||
71 | - public function getProduct() { | ||
72 | - if (empty($this->ID)) { | ||
73 | - return null; | ||
74 | - } | ||
75 | - return ProductVariantSearch::findByRemoteID($this->ID); | ||
76 | - } | ||
77 | -} |
common/modules/product/models/RemoteProductsSearch.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace common\modules\product\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | -use yii\base\Model; | ||
7 | -use yii\data\ActiveDataProvider; | ||
8 | -use common\modules\product\models\RemoteProducts; | ||
9 | - | ||
10 | -/** | ||
11 | - * RemoteProductsSearch represents the model behind the search form about `common\modules\product\models\RemoteProducts`. | ||
12 | - */ | ||
13 | -class RemoteProductsSearch extends RemoteProducts | ||
14 | -{ | ||
15 | - /** | ||
16 | - * @inheritdoc | ||
17 | - */ | ||
18 | - public function rules() | ||
19 | - { | ||
20 | - return [ | ||
21 | - [['Name', 'ID_chief', 'Article', 'Brand', 'ID', 'Date_create'], 'safe'], | ||
22 | - [['Price', 'Price_old'], 'number'], | ||
23 | - [['local_id'], 'integer'], | ||
24 | - ]; | ||
25 | - } | ||
26 | - | ||
27 | - /** | ||
28 | - * @inheritdoc | ||
29 | - */ | ||
30 | - public function scenarios() | ||
31 | - { | ||
32 | - // bypass scenarios() implementation in the parent class | ||
33 | - return Model::scenarios(); | ||
34 | - } | ||
35 | - | ||
36 | - /** | ||
37 | - * Creates data provider instance with search query applied | ||
38 | - * | ||
39 | - * @param array $params | ||
40 | - * | ||
41 | - * @return ActiveDataProvider | ||
42 | - */ | ||
43 | - public function search($params) | ||
44 | - { | ||
45 | - $query = RemoteProducts::find(); | ||
46 | - | ||
47 | - // add conditions that should always apply here | ||
48 | - | ||
49 | - $dataProvider = new ActiveDataProvider([ | ||
50 | - 'query' => $query, | ||
51 | - ]); | ||
52 | - | ||
53 | - $this->load($params); | ||
54 | - | ||
55 | - if (!$this->validate()) { | ||
56 | - // uncomment the following line if you do not want to return any records when validation fails | ||
57 | - // $query->where('0=1'); | ||
58 | - return $dataProvider; | ||
59 | - } | ||
60 | - | ||
61 | - // grid filtering conditions | ||
62 | - $query->andFilterWhere([ | ||
63 | - 'Price' => $this->Price, | ||
64 | - 'Price_old' => $this->Price_old, | ||
65 | - 'Date_create' => $this->Date_create, | ||
66 | - 'local_id' => $this->local_id, | ||
67 | - ]); | ||
68 | - | ||
69 | - $query->andFilterWhere(['like', 'Name', $this->Name]) | ||
70 | - ->andFilterWhere(['like', 'ID_chief', $this->ID_chief]) | ||
71 | - ->andFilterWhere(['like', 'Article', $this->Article]) | ||
72 | - ->andFilterWhere(['like', 'Brand', $this->Brand]) | ||
73 | - ->andFilterWhere(['like', 'ID', $this->ID]); | ||
74 | - | ||
75 | - return $dataProvider; | ||
76 | - } | ||
77 | -} |
common/modules/product/views/manage/_form.php
@@ -17,12 +17,14 @@ use kartik\select2\Select2; | @@ -17,12 +17,14 @@ use kartik\select2\Select2; | ||
17 | 17 | ||
18 | <div class="product-form"> | 18 | <div class="product-form"> |
19 | 19 | ||
20 | - <?php $form = ActiveForm::begin(); ?> | 20 | + <?php $form = ActiveForm::begin([ |
21 | + 'options' => ['enctype' => 'multipart/form-data'] | ||
22 | + ]); ?> | ||
21 | 23 | ||
22 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> | 24 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> |
23 | 25 | ||
24 | <?= $form->field($model, 'description')->widget(\mihaildev\ckeditor\CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> | 26 | <?= $form->field($model, 'description')->widget(\mihaildev\ckeditor\CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> |
25 | - <?= $form->field($model, 'video')->textarea()->label('Video embeded'); ?> | 27 | + <?= $form->field($model, 'video')->textarea(); ?> |
26 | 28 | ||
27 | <?= $form->field($model, 'brand_id')->dropDownList( | 29 | <?= $form->field($model, 'brand_id')->dropDownList( |
28 | ArrayHelper::map(ProductHelper::getBrands()->all(), 'brand_id', 'name'), | 30 | ArrayHelper::map(ProductHelper::getBrands()->all(), 'brand_id', 'name'), |
@@ -35,7 +37,7 @@ use kartik\select2\Select2; | @@ -35,7 +37,7 @@ use kartik\select2\Select2; | ||
35 | 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'), | 37 | 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'), |
36 | 'language' => 'ru', | 38 | 'language' => 'ru', |
37 | 'options' => [ | 39 | 'options' => [ |
38 | - 'placeholder' => 'Select a state ...', | 40 | + 'placeholder' => Yii::t('product', 'Select categories'), |
39 | 'multiple' => true, | 41 | 'multiple' => true, |
40 | ], | 42 | ], |
41 | 'pluginOptions' => [ | 43 | 'pluginOptions' => [ |
@@ -44,14 +46,24 @@ use kartik\select2\Select2; | @@ -44,14 +46,24 @@ use kartik\select2\Select2; | ||
44 | ] | 46 | ] |
45 | ) ?> | 47 | ) ?> |
46 | 48 | ||
47 | - | ||
48 | - | ||
49 | - <?php /*= $form->field($model, 'imagesUpload[]')->widget(FileInput::classname(), [ | 49 | + <?= $form->field($model, 'imagesUpload[]')->widget(\kartik\file\FileInput::classname(), [ |
50 | + 'language' => 'ru', | ||
50 | 'options' => [ | 51 | 'options' => [ |
51 | 'accept' => 'image/*', | 52 | 'accept' => 'image/*', |
52 | 'multiple' => true, | 53 | 'multiple' => true, |
53 | ], | 54 | ], |
54 | - ]);*/?> | 55 | + 'pluginOptions' => [ |
56 | + 'allowedFileExtensions' => ['jpg', 'gif', 'png'], | ||
57 | + 'initialPreview' => !empty($model->imagesHTML) ? $model->imagesHTML : [], | ||
58 | + 'initialPreviewConfig' => $model->imagesConfig, | ||
59 | + 'overwriteInitial' => false, | ||
60 | + 'showRemove' => false, | ||
61 | + 'showUpload' => false, | ||
62 | +// 'uploadUrl' => empty($model->product_id) ? null : \yii\helpers\Url::to(['/product/manage/uploadImage']), | ||
63 | + 'uploadAsync' => !empty($model->product_id), | ||
64 | + 'previewFileType' => 'image', | ||
65 | + ], | ||
66 | + ]); ?> | ||
55 | 67 | ||
56 | <?= $form->field($model, 'variants')->widget(MultipleInput::className(), [ | 68 | <?= $form->field($model, 'variants')->widget(MultipleInput::className(), [ |
57 | 'columns' => [ | 69 | 'columns' => [ |
@@ -62,33 +74,33 @@ use kartik\select2\Select2; | @@ -62,33 +74,33 @@ use kartik\select2\Select2; | ||
62 | [ | 74 | [ |
63 | 'name' => 'name', | 75 | 'name' => 'name', |
64 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, | 76 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, |
65 | - 'title' => 'Name', | 77 | + 'title' => Yii::t('product', 'Name'), |
66 | ], | 78 | ], |
67 | [ | 79 | [ |
68 | 'name' => 'sku', | 80 | 'name' => 'sku', |
69 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, | 81 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, |
70 | - 'title' => 'SKU', | 82 | + 'title' => Yii::t('product', 'SKU'), |
71 | ], | 83 | ], |
72 | [ | 84 | [ |
73 | 'name' => 'price', | 85 | 'name' => 'price', |
74 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, | 86 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, |
75 | - 'title' => 'Price', | 87 | + 'title' => Yii::t('product', 'Price'), |
76 | ], | 88 | ], |
77 | [ | 89 | [ |
78 | 'name' => 'price_old', | 90 | 'name' => 'price_old', |
79 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, | 91 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, |
80 | - 'title' => 'Old Price', | 92 | + 'title' => Yii::t('product', 'Old Price'), |
81 | ], | 93 | ], |
82 | [ | 94 | [ |
83 | 'name' => 'product_unit_id', | 95 | 'name' => 'product_unit_id', |
84 | 'type' => MultipleInputColumn::TYPE_DROPDOWN, | 96 | 'type' => MultipleInputColumn::TYPE_DROPDOWN, |
85 | - 'title' => 'Unit', | 97 | + 'title' => Yii::t('product', 'Unit'), |
86 | 'items' => ArrayHelper::map(\common\modules\product\models\ProductUnit::find()->all(), 'product_unit_id', 'name'), | 98 | 'items' => ArrayHelper::map(\common\modules\product\models\ProductUnit::find()->all(), 'product_unit_id', 'name'), |
87 | ], | 99 | ], |
88 | [ | 100 | [ |
89 | 'name' => 'stock', | 101 | 'name' => 'stock', |
90 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, | 102 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, |
91 | - 'title' => 'Stock', | 103 | + 'title' => Yii::t('product', 'Stock'), |
92 | 'options' => [ | 104 | 'options' => [ |
93 | 'placeholder' => '∞' | 105 | 'placeholder' => '∞' |
94 | ], | 106 | ], |
common/modules/product/views/manage/index.php
@@ -22,12 +22,57 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -22,12 +22,57 @@ $this->params['breadcrumbs'][] = $this->title; | ||
22 | 'filterModel' => $searchModel, | 22 | 'filterModel' => $searchModel, |
23 | 'columns' => [ | 23 | 'columns' => [ |
24 | ['class' => 'yii\grid\SerialColumn'], | 24 | ['class' => 'yii\grid\SerialColumn'], |
25 | - 'product_id', | 25 | +// 'product_id', |
26 | 'name', | 26 | 'name', |
27 | - 'brand.name', | ||
28 | - 'category.name', | 27 | + [ |
28 | + 'label' => Yii::t('product', 'Brand'), | ||
29 | + 'attribute' => 'brand_name', | ||
30 | + 'value' => 'brand.name', | ||
31 | + ], | ||
32 | + [ | ||
33 | + 'label' => Yii::t('product', 'Category'), | ||
34 | + 'attribute' => 'category_name', | ||
35 | + 'value' => 'category.name', | ||
36 | + ], | ||
37 | + 'variant.price', | ||
38 | + 'variant.stock_caption', | ||
29 | 39 | ||
30 | - ['class' => 'yii\grid\ActionColumn'], | 40 | + |
41 | + [ | ||
42 | + 'class' => 'yii\grid\ActionColumn', | ||
43 | + 'template' => '{view} {is_top} {is_new} {update} {delete}', | ||
44 | + 'buttons' => [ | ||
45 | + 'is_top' => function ($url, $model) { | ||
46 | + return Html::a('<span class="glyphicon glyphicon-star' . ($model->is_top ? '' : '-empty') . '"></span>', $url, [ | ||
47 | + 'title' => Yii::t('product', ($model->is_top ? 'Set not is top' : 'Set is top')), | ||
48 | + ]); | ||
49 | + }, | ||
50 | + 'is_new' => function ($url, $model) { | ||
51 | + return Html::a('<span class="glyphicon glyphicon-heart' . ($model->is_new ? '' : '-empty') . '"></span>', $url, [ | ||
52 | + 'title' => Yii::t('product', ($model->is_new ? 'Set not is new' : 'Set is new')), | ||
53 | + ]); | ||
54 | + }, | ||
55 | + ], | ||
56 | + 'urlCreator' => function ($action, $model, $key, $index) { | ||
57 | + switch ($action) { | ||
58 | + case 'is_top': | ||
59 | + return \yii\helpers\Url::to(['manage/is_top', 'id' => $model->product_id]); | ||
60 | + break; | ||
61 | + case 'is_new': | ||
62 | + return \yii\helpers\Url::to(['manage/is_new', 'id' => $model->product_id]); | ||
63 | + break; | ||
64 | + case 'view': | ||
65 | + return \yii\helpers\Url::to(['/catalog/product', 'id' => $model->product_id, ['target' => '_blank']]); | ||
66 | + break; | ||
67 | + case 'update': | ||
68 | + return \yii\helpers\Url::to(['manage/update', 'id' => $model->product_id]); | ||
69 | + break; | ||
70 | + case 'delete': | ||
71 | + return \yii\helpers\Url::to(['manage/delete', 'id' => $model->product_id]); | ||
72 | + break; | ||
73 | + } | ||
74 | + } | ||
75 | + ], | ||
31 | ], | 76 | ], |
32 | ]); ?> | 77 | ]); ?> |
33 | </div> | 78 | </div> |
common/modules/product/views/manage/view.php
@@ -33,6 +33,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -33,6 +33,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
33 | 'fullname', | 33 | 'fullname', |
34 | 'brand.name', | 34 | 'brand.name', |
35 | 'category.name', | 35 | 'category.name', |
36 | + 'image.imageUrl:image' | ||
36 | ], | 37 | ], |
37 | ]) ?> | 38 | ]) ?> |
38 | 39 |
common/modules/product/views/product-unit/_form.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\ActiveForm; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model common\modules\product\models\ProductUnit */ | ||
8 | +/* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="product-unit-form"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin(); ?> | ||
14 | + | ||
15 | + <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> | ||
16 | + | ||
17 | + <?= $form->field($model, 'code')->textInput(['maxlength' => true]) ?> | ||
18 | + | ||
19 | + <?= $form->field($model, 'is_default')->checkbox() ?> | ||
20 | + | ||
21 | + <div class="form-group"> | ||
22 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
23 | + </div> | ||
24 | + | ||
25 | + <?php ActiveForm::end(); ?> | ||
26 | + | ||
27 | +</div> |
common/modules/product/views/product-unit/_search.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\ActiveForm; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model common\modules\product\models\ProductUnitSearch */ | ||
8 | +/* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="product-unit-search"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin([ | ||
14 | + 'action' => ['index'], | ||
15 | + 'method' => 'get', | ||
16 | + ]); ?> | ||
17 | + | ||
18 | + <?= $form->field($model, 'product_unit_id') ?> | ||
19 | + | ||
20 | + <?= $form->field($model, 'name') ?> | ||
21 | + | ||
22 | + <?= $form->field($model, 'code') ?> | ||
23 | + | ||
24 | + <?= $form->field($model, 'is_default')->checkbox() ?> | ||
25 | + | ||
26 | + <div class="form-group"> | ||
27 | + <?= Html::submitButton(Yii::t('product', 'Search'), ['class' => 'btn btn-primary']) ?> | ||
28 | + <?= Html::resetButton(Yii::t('product', 'Reset'), ['class' => 'btn btn-default']) ?> | ||
29 | + </div> | ||
30 | + | ||
31 | + <?php ActiveForm::end(); ?> | ||
32 | + | ||
33 | +</div> |
common/modules/product/views/product-unit/create.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | + | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model common\modules\product\models\ProductUnit */ | ||
8 | + | ||
9 | +$this->title = Yii::t('product', 'Create Product Unit'); | ||
10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Units'), 'url' => ['index']]; | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="product-unit-create"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + | ||
17 | + <?= $this->render('_form', [ | ||
18 | + 'model' => $model, | ||
19 | + ]) ?> | ||
20 | + | ||
21 | +</div> |
common/modules/product/views/product-unit/index.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\grid\GridView; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $searchModel common\modules\product\models\ProductUnitSearch */ | ||
8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
9 | + | ||
10 | +$this->title = Yii::t('product', 'Product Units'); | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="product-unit-index"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
17 | + | ||
18 | + <p> | ||
19 | + <?= Html::a(Yii::t('product', 'Create Product Unit'), ['create'], ['class' => 'btn btn-success']) ?> | ||
20 | + </p> | ||
21 | + <?= GridView::widget([ | ||
22 | + 'dataProvider' => $dataProvider, | ||
23 | + 'filterModel' => $searchModel, | ||
24 | + 'columns' => [ | ||
25 | + ['class' => 'yii\grid\SerialColumn'], | ||
26 | + | ||
27 | + 'name', | ||
28 | + 'code:html', | ||
29 | + 'is_default:boolean', | ||
30 | + | ||
31 | + ['class' => 'yii\grid\ActionColumn'], | ||
32 | + ], | ||
33 | + ]); ?> | ||
34 | +</div> |
common/modules/product/views/product-unit/update.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | + | ||
5 | +/* @var $this yii\web\View */ | ||
6 | +/* @var $model common\modules\product\models\ProductUnit */ | ||
7 | + | ||
8 | +$this->title = Yii::t('product', 'Update {modelClass}: ', [ | ||
9 | + 'modelClass' => 'Product Unit', | ||
10 | +]) . $model->name; | ||
11 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Units'), 'url' => ['index']]; | ||
12 | +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->product_unit_id]]; | ||
13 | +$this->params['breadcrumbs'][] = Yii::t('product', 'Update'); | ||
14 | +?> | ||
15 | +<div class="product-unit-update"> | ||
16 | + | ||
17 | + <h1><?= Html::encode($this->title) ?></h1> | ||
18 | + | ||
19 | + <?= $this->render('_form', [ | ||
20 | + 'model' => $model, | ||
21 | + ]) ?> | ||
22 | + | ||
23 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\DetailView; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model common\modules\product\models\ProductUnit */ | ||
8 | + | ||
9 | +$this->title = $model->name; | ||
10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Units'), 'url' => ['index']]; | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="product-unit-view"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + | ||
17 | + <p> | ||
18 | + <?= Html::a(Yii::t('product', 'Update'), ['update', 'id' => $model->product_unit_id], ['class' => 'btn btn-primary']) ?> | ||
19 | + <?= Html::a(Yii::t('product', 'Delete'), ['delete', 'id' => $model->product_unit_id], [ | ||
20 | + 'class' => 'btn btn-danger', | ||
21 | + 'data' => [ | ||
22 | + 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), | ||
23 | + 'method' => 'post', | ||
24 | + ], | ||
25 | + ]) ?> | ||
26 | + </p> | ||
27 | + | ||
28 | + <?= DetailView::widget([ | ||
29 | + 'model' => $model, | ||
30 | + 'attributes' => [ | ||
31 | + 'product_unit_id', | ||
32 | + 'name', | ||
33 | + 'code', | ||
34 | + 'is_default:boolean', | ||
35 | + ], | ||
36 | + ]) ?> | ||
37 | + | ||
38 | +</div> |
common/modules/product/widgets/views/brandsCarousel.php
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <div class="prods_carousel"> | 3 | <div class="prods_carousel"> |
4 | <ul> | 4 | <ul> |
5 | <?php foreach($brands as $brand) :?> | 5 | <?php foreach($brands as $brand) :?> |
6 | - <li><span><a href="<?= \yii\helpers\Url::to('/brands/'. $brand->alias)?>" title="<?= $brand->name?>"><img src="<?= $brand->image?>"></a></span></li> | 6 | + <li><span><a href="<?= \yii\helpers\Url::to('/brands/'. $brand->alias)?>" title="<?= $brand->name?>"><?= $brand->imageFile ? Yii::$app->imageCache->thumb($brand->imageFile, 'brandlist') : ''?></a></span></li> |
7 | <?php endforeach?> | 7 | <?php endforeach?> |
8 | </ul> | 8 | </ul> |
9 | </div> | 9 | </div> |
common/modules/product/widgets/views/submenu.php
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | <?php if (empty($_item->image)) :?> | 12 | <?php if (empty($_item->image)) :?> |
13 | <img valign="top" src="/images/no_photo.png"> | 13 | <img valign="top" src="/images/no_photo.png"> |
14 | <?php else :?> | 14 | <?php else :?> |
15 | - <img valign="top" src="<?= $_item->image?>"> | 15 | + <?= $_item->imageUrl ? Yii::$app->imageCache->thumb($_item->imageUrl, 'mainmenu') : ''?> |
16 | <?php endif?> | 16 | <?php endif?> |
17 | </div> | 17 | </div> |
18 | <div class="title"><?= $_item->categoryName->value?></div> | 18 | <div class="title"><?= $_item->categoryName->value?></div> |
@@ -34,7 +34,7 @@ | @@ -34,7 +34,7 @@ | ||
34 | <?php if (empty($_item['item']->image)) :?> | 34 | <?php if (empty($_item['item']->image)) :?> |
35 | <img valign="top" src="/images/no_photo.png"> | 35 | <img valign="top" src="/images/no_photo.png"> |
36 | <?php else :?> | 36 | <?php else :?> |
37 | - <img valign="top" src="<?= $_item['item']->image?>" alt="<?= $_item['item']->categoryName->value?>"> | 37 | + <?= $_item['item']->imageUrl ? Yii::$app->imageCache->thumb($_item['item']->imageUrl, 'mainmenu') : ''?> |
38 | <?php endif?> | 38 | <?php endif?> |
39 | </div> | 39 | </div> |
40 | <div class="title"><?= $_item['item']->categoryName->value?></div> | 40 | <div class="title"><?= $_item['item']->categoryName->value?></div> |
common/modules/rubrication/behaviors/ArtboxSynonymBehavior.php
@@ -114,7 +114,7 @@ class ArtboxSynonymBehavior extends Behavior { | @@ -114,7 +114,7 @@ class ArtboxSynonymBehavior extends Behavior { | ||
114 | $valueModel->setAttribute($field, $this->$key); | 114 | $valueModel->setAttribute($field, $this->$key); |
115 | } | 115 | } |
116 | if ($isave) { | 116 | if ($isave) { |
117 | - $valueModel->setAttribute($this->valueOptionId, $this->owner->{$this->keyNameId}); | 117 | + $valueModel->setAttribute($this->valueOptionId, $this->owner->getAttribute($this->keyNameId)); |
118 | $valueModel->save(); | 118 | $valueModel->save(); |
119 | if (!empty($this->slug) && empty($this->owner->{$this->slug['slugKeyName']})) { | 119 | if (!empty($this->slug) && empty($this->owner->{$this->slug['slugKeyName']})) { |
120 | $this->owner->{$this->slug['slugKeyName']} = $this->slugify($valueModel->{$this->slug['valueKeyName']}); | 120 | $this->owner->{$this->slug['slugKeyName']} = $this->slugify($valueModel->{$this->slug['valueKeyName']}); |
common/modules/rubrication/models/TaxGroup.php
@@ -15,7 +15,7 @@ use Yii; | @@ -15,7 +15,7 @@ use Yii; | ||
15 | * @property string $module | 15 | * @property string $module |
16 | * @property boolean $hierarchical | 16 | * @property boolean $hierarchical |
17 | * @property string $settings | 17 | * @property string $settings |
18 | - * @property boolean $is_filter | 18 | + * @property boolean is_filter |
19 | * | 19 | * |
20 | * @property TaxGroupToGroup[] $taxGroupToGroups | 20 | * @property TaxGroupToGroup[] $taxGroupToGroups |
21 | * @property TaxGroupToGroup[] $taxGroupToGroups0 | 21 | * @property TaxGroupToGroup[] $taxGroupToGroups0 |
@@ -62,7 +62,7 @@ class TaxGroup extends \yii\db\ActiveRecord | @@ -62,7 +62,7 @@ class TaxGroup extends \yii\db\ActiveRecord | ||
62 | return [ | 62 | return [ |
63 | [['name', 'module'], 'required'], | 63 | [['name', 'module'], 'required'], |
64 | [['description', 'settings'], 'string'], | 64 | [['description', 'settings'], 'string'], |
65 | - [['hierarchical', 'is_filter'], 'boolean'], | 65 | + [['hierarchical'], 'boolean'], |
66 | [['alias', 'module'], 'string', 'max' => 50], | 66 | [['alias', 'module'], 'string', 'max' => 50], |
67 | [['name'], 'string', 'max' => 255], | 67 | [['name'], 'string', 'max' => 255], |
68 | [['group_to_category'], 'safe'] | 68 | [['group_to_category'], 'safe'] |
common/modules/rubrication/models/TaxValueString.php
@@ -53,6 +53,6 @@ class TaxValueString extends \yii\db\ActiveRecord | @@ -53,6 +53,6 @@ class TaxValueString extends \yii\db\ActiveRecord | ||
53 | */ | 53 | */ |
54 | public function getTaxOption() | 54 | public function getTaxOption() |
55 | { | 55 | { |
56 | - return $this->hasOne(TaxOption::className(), ['tax_option_id' => 'tax_option_id'])->inverseOf('taxValueStrings'); | 56 | + return $this->hasOne(TaxOption::className(), ['tax_option_id' => 'tax_option_id']); |
57 | } | 57 | } |
58 | } | 58 | } |
common/modules/rubrication/views/tax-group/_form.php
@@ -15,10 +15,10 @@ use common\components\artboxtree\ArtboxTreeHelper; | @@ -15,10 +15,10 @@ use common\components\artboxtree\ArtboxTreeHelper; | ||
15 | 15 | ||
16 | <?php $form = ActiveForm::begin(); ?> | 16 | <?php $form = ActiveForm::begin(); ?> |
17 | 17 | ||
18 | - <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?> | ||
19 | - | ||
20 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> | 18 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> |
21 | 19 | ||
20 | + <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?> | ||
21 | + | ||
22 | <?= $form->field($model, 'description')->textarea(['rows' => 6]) ?> | 22 | <?= $form->field($model, 'description')->textarea(['rows' => 6]) ?> |
23 | 23 | ||
24 | <?= $form->field($model, 'module')->dropDownList(RubricationHelper::OptionTypes(), [ | 24 | <?= $form->field($model, 'module')->dropDownList(RubricationHelper::OptionTypes(), [ |
common/translation/ru/product.php
console/config/bootstrap.php
@@ -2,4 +2,4 @@ | @@ -2,4 +2,4 @@ | ||
2 | Yii::setAlias('@uploadDir', dirname(dirname(__DIR__)) . '/storage/sync'); | 2 | Yii::setAlias('@uploadDir', dirname(dirname(__DIR__)) . '/storage/sync'); |
3 | Yii::setAlias('@uploadFileProducts', 'products.csv'); | 3 | Yii::setAlias('@uploadFileProducts', 'products.csv'); |
4 | 4 | ||
5 | -Yii::setAlias('@productsDir', dirname(dirname(__DIR__)) . '/storage/products'); | 5 | +Yii::setAlias('@productsDir', '/images/products'); |
console/controllers/ImportController.php
@@ -4,6 +4,7 @@ namespace console\controllers; | @@ -4,6 +4,7 @@ namespace console\controllers; | ||
4 | 4 | ||
5 | use common\modules\product\models\Category; | 5 | use common\modules\product\models\Category; |
6 | use common\modules\product\models\CategoryName; | 6 | use common\modules\product\models\CategoryName; |
7 | +use common\modules\product\models\ProductImage; | ||
7 | use common\modules\product\models\ProductVariantType; | 8 | use common\modules\product\models\ProductVariantType; |
8 | use common\modules\rubrication\models\TaxOption; | 9 | use common\modules\rubrication\models\TaxOption; |
9 | use common\modules\rubrication\models\TaxValueString; | 10 | use common\modules\rubrication\models\TaxValueString; |
@@ -100,7 +101,7 @@ class ImportController extends Controller { | @@ -100,7 +101,7 @@ class ImportController extends Controller { | ||
100 | $product_cost_old = $data[9]; | 101 | $product_cost_old = $data[9]; |
101 | 102 | ||
102 | // 11 Цена | 103 | // 11 Цена |
103 | - $produc_cost = $data[10]; | 104 | + $product_cost = $data[10]; |
104 | 105 | ||
105 | // 12 Акция | 106 | // 12 Акция |
106 | $product_akciya = (bool)$data[11]; | 107 | $product_akciya = (bool)$data[11]; |
@@ -133,6 +134,8 @@ class ImportController extends Controller { | @@ -133,6 +134,8 @@ class ImportController extends Controller { | ||
133 | $_product = new Product(); | 134 | $_product = new Product(); |
134 | } | 135 | } |
135 | 136 | ||
137 | + $is_new_product = empty($_product->product_id); | ||
138 | + | ||
136 | // ==== Set category ==== | 139 | // ==== Set category ==== |
137 | if ( ($category = CategoryName::find()->filterWhere(['ilike', 'value', trim($catalog_name)])->one()) !== null ) { | 140 | if ( ($category = CategoryName::find()->filterWhere(['ilike', 'value', trim($catalog_name)])->one()) !== null ) { |
138 | $_product->categories = [$category->category_id]; | 141 | $_product->categories = [$category->category_id]; |
@@ -160,9 +163,9 @@ class ImportController extends Controller { | @@ -160,9 +163,9 @@ class ImportController extends Controller { | ||
160 | $_product->name = $product_name; | 163 | $_product->name = $product_name; |
161 | $_product->video = $product_video; | 164 | $_product->video = $product_video; |
162 | $_product->description = $product_body_ru; | 165 | $_product->description = $product_body_ru; |
163 | - $_product->top = $product_top; | 166 | + $_product->is_top = $product_top; |
164 | $_product->akciya = $product_akciya; | 167 | $_product->akciya = $product_akciya; |
165 | - $_product->new = $product_new; | 168 | + $_product->is_new = $product_new; |
166 | 169 | ||
167 | 170 | ||
168 | $_product->save(); | 171 | $_product->save(); |
@@ -195,52 +198,61 @@ class ImportController extends Controller { | @@ -195,52 +198,61 @@ class ImportController extends Controller { | ||
195 | $mod_size = $mod_arr[1]; | 198 | $mod_size = $mod_arr[1]; |
196 | $mod_color = $mod_arr[2]; | 199 | $mod_color = $mod_arr[2]; |
197 | $mod_image = $mod_arr[3]; | 200 | $mod_image = $mod_arr[3]; |
198 | - $mod_cost = $produc_cost; | 201 | + $mod_cost = $product_cost; |
199 | $mod_old_cost = $product_cost_old; | 202 | $mod_old_cost = $product_cost_old; |
200 | 203 | ||
201 | // Check product variant | 204 | // Check product variant |
202 | - if ( ($_productVariant = ProductVariant::find()->andWhere(['ilike', 'sku', $mod_art])->andWhere(['product_id' => $_product->product_id])->one()) === null ) { | 205 | + if ( ($_productVariant = ProductVariant::find()->andFilterWhere(['ilike', 'sku', $mod_art])->andFilterWhere(['product_id' => $_product->product_id])->one()) === null ) { |
203 | $_productVariant = new ProductVariant(); | 206 | $_productVariant = new ProductVariant(); |
204 | $_productVariant->product_id = $_product->product_id; | 207 | $_productVariant->product_id = $_product->product_id; |
205 | } | 208 | } |
209 | + $_productVariant->product_unit_id = 1; | ||
206 | 210 | ||
207 | $_productVariant->sku = $mod_art; | 211 | $_productVariant->sku = $mod_art; |
208 | $_productVariant->price = $mod_cost; | 212 | $_productVariant->price = $mod_cost; |
209 | $_productVariant->price_old = $mod_old_cost; | 213 | $_productVariant->price_old = $mod_old_cost; |
210 | - | ||
211 | - $_productVariant->save(); | ||
212 | - | ||
213 | - $MOD_ARRAY[] = $_productVariant->product_variant_id; | ||
214 | - | ||
215 | - | ||
216 | - $dir = Yii::getAlias('@productsDir').'/'; | ||
217 | - if (is_file ($dir . $mod_image)) | ||
218 | - { | ||
219 | - $resizeObj = new resize ($dir . $mod_image); | ||
220 | - $resizeObj->resizeImage (40, 40, 'crop'); | ||
221 | - $resizeObj->saveImage ($dir.'ico/' . $mod_image, 100); | ||
222 | - $resizeObj->resizeImage (370, 370, 'auto'); | ||
223 | - $resizeObj->saveImage ($dir.'/big/' . $mod_image, 100); | ||
224 | - } | 214 | + $_productVariant->stock = 1; |
225 | 215 | ||
226 | $product_variant_type_name = ''; | 216 | $product_variant_type_name = ''; |
227 | - if (! empty ($mod_color)) | 217 | + if (! empty ($mod_color)) { |
228 | $product_variant_type_name = 'Цвет'; | 218 | $product_variant_type_name = 'Цвет'; |
229 | - elseif (! empty ($mod_size)) | 219 | + $_productVariant->name = $mod_color; |
220 | + } | ||
221 | + elseif (! empty ($mod_size)) { | ||
230 | $product_variant_type_name = 'Размер'; | 222 | $product_variant_type_name = 'Размер'; |
223 | + $_productVariant->name = $mod_size; | ||
224 | + } | ||
231 | 225 | ||
232 | // ===== Set variant type ==== | 226 | // ===== Set variant type ==== |
233 | if ( $product_variant_type_name ) { | 227 | if ( $product_variant_type_name ) { |
234 | if ( ($product_variant_type = ProductVariantType::find()->filterWhere(['ilike', 'name', $product_variant_type_name])->one()) !== null ) { | 228 | if ( ($product_variant_type = ProductVariantType::find()->filterWhere(['ilike', 'name', $product_variant_type_name])->one()) !== null ) { |
235 | $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id; | 229 | $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id; |
236 | } else { | 230 | } else { |
237 | - // Create brand | ||
238 | $product_variant_type = new ProductVariantType(); | 231 | $product_variant_type = new ProductVariantType(); |
239 | $product_variant_type->name = $product_variant_type_name; | 232 | $product_variant_type->name = $product_variant_type_name; |
240 | $product_variant_type->save(); | 233 | $product_variant_type->save(); |
241 | $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id; | 234 | $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id; |
242 | } | 235 | } |
243 | } | 236 | } |
237 | + | ||
238 | + $_productVariant->save(); | ||
239 | + | ||
240 | + $MOD_ARRAY[] = $_productVariant->product_variant_id; | ||
241 | + | ||
242 | + if ($mod_image) { | ||
243 | + $url = 'http://rukzachok.com.ua/upload/mod/' . $mod_image; | ||
244 | + $image = file_get_contents($url); | ||
245 | + if ($image) { | ||
246 | + if (($variantImage = ProductImage::find()->andFilterWhere(['ilike', 'image', $mod_image])->andFilterWhere(['product_variant_id' => $_productVariant->product_variant_id])->one()) === null) { | ||
247 | + file_put_contents(Yii::getAlias('@productsDir') . "/" . $mod_image, $image); | ||
248 | + $variantImage = new ProductImage(); | ||
249 | + $variantImage->product_id = $_product->product_id; | ||
250 | + $variantImage->product_variant_id = $_productVariant->product_variant_id; | ||
251 | + $variantImage->image = $mod_image; | ||
252 | + $variantImage->save(); | ||
253 | + } | ||
254 | + } | ||
255 | + } | ||
244 | } | 256 | } |
245 | } | 257 | } |
246 | 258 | ||
@@ -282,353 +294,6 @@ class ImportController extends Controller { | @@ -282,353 +294,6 @@ class ImportController extends Controller { | ||
282 | } | 294 | } |
283 | }*/ | 295 | }*/ |
284 | 296 | ||
285 | - // ======================== | ||
286 | - // ==== ХАРАКТЕРИСТИКИ ==== | ||
287 | - // ======================== | ||
288 | - | ||
289 | - // есть общие характеристики, которые относятся product_id, такие как brand, gender... | ||
290 | - // есть характеристики, которые относятся mod_id, такие как цвет, размер... | ||
291 | - | ||
292 | - // ==== gender ==== | ||
293 | - | ||
294 | - /*if (! empty ($gender)) | ||
295 | - { | ||
296 | - $bookGender = Book::find () | ||
297 | - ->where ('book_alias=:book', [ | ||
298 | - ':book' => 'gender' | ||
299 | - ]) | ||
300 | - ->one (); | ||
301 | - | ||
302 | - foreach ($gender as $filter) | ||
303 | - { | ||
304 | - if (! empty ($filter)) | ||
305 | - { | ||
306 | - $bookGenderValue = BookValue::find () | ||
307 | - ->where (' | ||
308 | - book_id=:book | ||
309 | - AND book_value_title=:value | ||
310 | - AND book_value_alias=:alias | ||
311 | - ', [ | ||
312 | - ':book' => $bookGender->book_id, | ||
313 | - ':value' => $filter, | ||
314 | - ':alias' => Translite::rusencode ($filter), | ||
315 | - ] | ||
316 | - ) | ||
317 | - ->one(); | ||
318 | - | ||
319 | - if (! isset ($bookGenderValue->book_value_id) || empty ($bookGenderValue->book_value_id)) | ||
320 | - { | ||
321 | - $db->createCommand () | ||
322 | - ->insert (BookValue::tableName (), [ | ||
323 | - 'book_id' => $bookGender->book_id, | ||
324 | - 'book_value_title' => $filter, | ||
325 | - 'book_value_alias' => Translite::rusencode ($filter), | ||
326 | - ]) | ||
327 | - ->execute (); | ||
328 | - | ||
329 | - $book_value_id = Yii::$app->db->lastInsertID; | ||
330 | - } | ||
331 | - else | ||
332 | - { | ||
333 | - $book_value_id = $bookGenderValue->book_value_id; | ||
334 | - } | ||
335 | - | ||
336 | - // + products_value | ||
337 | - $db->createCommand (' | ||
338 | - INSERT IGNORE products_value | ||
339 | - SET | ||
340 | - product_id = '.(int)$product_id.', | ||
341 | - book_value_id = '.(int)$book_value_id.' | ||
342 | - ') | ||
343 | - ->execute (); | ||
344 | - } | ||
345 | - } | ||
346 | - } | ||
347 | - | ||
348 | - // есть характеристики, которые относятся mod_id, такие как цвет, размер... | ||
349 | - | ||
350 | - // ==== destination ==== | ||
351 | - | ||
352 | - if (! empty ($filters)) | ||
353 | - { | ||
354 | - $bookDestination = Book::find () | ||
355 | - ->where ('book_alias=:book', [ | ||
356 | - ':book' => 'destination' | ||
357 | - ]) | ||
358 | - ->one (); | ||
359 | - | ||
360 | - foreach ($filters as $filter) | ||
361 | - { | ||
362 | - if (! empty ($filter)) | ||
363 | - { | ||
364 | - $bookDestinationValue = BookValue::find () | ||
365 | - ->where (' | ||
366 | - book_id=:book | ||
367 | - AND book_value_title=:value | ||
368 | - AND book_value_alias=:alias | ||
369 | - ', [ | ||
370 | - ':book' => $bookDestination->book_id, | ||
371 | - ':value' => $filter, | ||
372 | - ':alias' => Translite::rusencode ($filter), | ||
373 | - ] | ||
374 | - ) | ||
375 | - ->one(); | ||
376 | - | ||
377 | - if (! isset ($bookDestinationValue->book_value_id) || empty ($bookDestinationValue->book_value_id)) | ||
378 | - { | ||
379 | - $db->createCommand () | ||
380 | - ->insert (BookValue::tableName (), [ | ||
381 | - 'book_id' => $bookDestination->book_id, | ||
382 | - 'book_value_title' => $filter, | ||
383 | - 'book_value_alias' => Translite::rusencode ($filter), | ||
384 | - ]) | ||
385 | - ->execute (); | ||
386 | - | ||
387 | - $book_value_id = Yii::$app->db->lastInsertID; | ||
388 | - } | ||
389 | - else | ||
390 | - { | ||
391 | - $book_value_id = $bookDestinationValue->book_value_id; | ||
392 | - } | ||
393 | - | ||
394 | - if (! empty ($MOD_ARRAY)) | ||
395 | - { | ||
396 | - foreach ($MOD_ARRAY as $id) | ||
397 | - { | ||
398 | - // + products_value | ||
399 | - $db->createCommand (' | ||
400 | - INSERT IGNORE mod_value | ||
401 | - SET | ||
402 | - mod_id = '.(int)$id.', | ||
403 | - book_value_id = '.(int)$book_value_id.' | ||
404 | - ') | ||
405 | - ->execute (); | ||
406 | - } | ||
407 | - } | ||
408 | - } | ||
409 | - } | ||
410 | - } | ||
411 | - | ||
412 | - // ==== special ==== | ||
413 | - | ||
414 | - if (! empty ($filters_extra)) | ||
415 | - { | ||
416 | - $bookSpecial = Book::find () | ||
417 | - ->where ('book_alias=:book', [ | ||
418 | - ':book' => 'special' | ||
419 | - ]) | ||
420 | - ->one (); | ||
421 | - | ||
422 | - foreach ($filters_extra as $filter) | ||
423 | - { | ||
424 | - if (! empty ($filter)) | ||
425 | - { | ||
426 | - $bookSpecialValue = BookValue::find () | ||
427 | - ->where (' | ||
428 | - book_id=:book | ||
429 | - AND book_value_title=:value | ||
430 | - AND book_value_alias=:alias | ||
431 | - ', [ | ||
432 | - ':book' => $bookSpecial->book_id, | ||
433 | - ':value' => $filter, | ||
434 | - ':alias' => Translite::rusencode ($filter), | ||
435 | - ] | ||
436 | - ) | ||
437 | - ->one(); | ||
438 | - | ||
439 | - if (! isset ($bookSpecialValue->book_value_id) || empty ($bookSpecialValue->book_value_id)) | ||
440 | - { | ||
441 | - $db->createCommand () | ||
442 | - ->insert (BookValue::tableName (), [ | ||
443 | - 'book_id' => $bookSpecial->book_id, | ||
444 | - 'book_value_title' => $filter, | ||
445 | - 'book_value_alias' => Translite::rusencode ($filter), | ||
446 | - ]) | ||
447 | - ->execute (); | ||
448 | - | ||
449 | - $book_value_id = Yii::$app->db->lastInsertID; | ||
450 | - } | ||
451 | - else | ||
452 | - { | ||
453 | - $book_value_id = $bookSpecialValue->book_value_id; | ||
454 | - } | ||
455 | - | ||
456 | - if (! empty ($MOD_ARRAY)) | ||
457 | - { | ||
458 | - foreach ($MOD_ARRAY as $id) | ||
459 | - { | ||
460 | - // + products_value | ||
461 | - $db->createCommand (' | ||
462 | - INSERT IGNORE mod_value | ||
463 | - SET | ||
464 | - mod_id = '.(int)$id.', | ||
465 | - book_value_id = '.(int)$book_value_id.' | ||
466 | - ') | ||
467 | - ->execute (); | ||
468 | - } | ||
469 | - } | ||
470 | - } | ||
471 | - } | ||
472 | - } | ||
473 | - | ||
474 | - // ==== year ==== | ||
475 | - | ||
476 | - if (! empty ($years)) | ||
477 | - { | ||
478 | - $bookYear = Book::find () | ||
479 | - ->where ('book_alias=:book', [ | ||
480 | - ':book' => 'year' | ||
481 | - ]) | ||
482 | - ->one (); | ||
483 | - | ||
484 | - foreach ($years as $filter) | ||
485 | - { | ||
486 | - if (! empty ($filter)) | ||
487 | - { | ||
488 | - $bookYearValue = BookValue::find () | ||
489 | - ->where (' | ||
490 | - book_id=:book | ||
491 | - AND book_value_title=:value | ||
492 | - AND book_value_alias=:alias | ||
493 | - ', [ | ||
494 | - ':book' => $bookYear->book_id, | ||
495 | - ':value' => $filter, | ||
496 | - ':alias' => Translite::rusencode ($filter), | ||
497 | - ] | ||
498 | - ) | ||
499 | - ->one(); | ||
500 | - | ||
501 | - if (! isset ($bookYearValue->book_value_id) || empty ($bookYearValue->book_value_id)) | ||
502 | - { | ||
503 | - $db->createCommand () | ||
504 | - ->insert (BookValue::tableName (), [ | ||
505 | - 'book_id' => $bookYear->book_id, | ||
506 | - 'book_value_title' => $filter, | ||
507 | - 'book_value_alias' => Translite::rusencode ($filter), | ||
508 | - ]) | ||
509 | - ->execute (); | ||
510 | - | ||
511 | - $book_value_id = Yii::$app->db->lastInsertID; | ||
512 | - } | ||
513 | - else | ||
514 | - { | ||
515 | - $book_value_id = $bookYearValue->book_value_id; | ||
516 | - } | ||
517 | - | ||
518 | - if (! empty ($MOD_ARRAY)) | ||
519 | - { | ||
520 | - foreach ($MOD_ARRAY as $id) | ||
521 | - { | ||
522 | - // + products_value | ||
523 | - $db->createCommand (' | ||
524 | - INSERT IGNORE mod_value | ||
525 | - SET | ||
526 | - mod_id = '.(int)$id.', | ||
527 | - book_value_id = '.(int)$book_value_id.' | ||
528 | - ') | ||
529 | - ->execute (); | ||
530 | - } | ||
531 | - } | ||
532 | - } | ||
533 | - } | ||
534 | - } | ||
535 | - | ||
536 | - // ==== $feature ==== | ||
537 | - | ||
538 | - if (! empty ($feature)) | ||
539 | - { | ||
540 | - foreach ($feature as $string) | ||
541 | - { | ||
542 | - $string = str_replace([':', '.'], '', $string); | ||
543 | - | ||
544 | - if (! empty ($string)) | ||
545 | - { | ||
546 | - list ($book_title, $value_title) = explode ('*', $string); | ||
547 | - | ||
548 | - $book_title = trim ($book_title); | ||
549 | - $value_title = trim ($value_title); | ||
550 | - | ||
551 | - if (empty ($book_title) || empty ($value_title)) | ||
552 | - { | ||
553 | - CONTINUE; | ||
554 | - } | ||
555 | - | ||
556 | - $bookFeature = Book::find () | ||
557 | - ->where ('book_title=:book', [ | ||
558 | - ':book' => $book_title | ||
559 | - ]) | ||
560 | - ->one (); | ||
561 | - | ||
562 | - if (! isset ($bookFeature->book_id) || empty ($bookFeature->book_id)) | ||
563 | - { | ||
564 | - $db->createCommand () | ||
565 | - ->insert (Book::tableName (), [ | ||
566 | - 'book_title' => $book_title, | ||
567 | - 'book_alias' => Translite::rusencode ($book_title), | ||
568 | - ]) | ||
569 | - ->execute (); | ||
570 | - | ||
571 | - $book_id = Yii::$app->db->lastInsertID; | ||
572 | - } | ||
573 | - else | ||
574 | - { | ||
575 | - $book_id = $bookFeature->book_id; | ||
576 | - } | ||
577 | - | ||
578 | - $bookFeatureValue = BookValue::find () | ||
579 | - ->where (' | ||
580 | - book_id=:book | ||
581 | - AND book_value_title=:value | ||
582 | - AND book_value_alias=:alias | ||
583 | - ', [ | ||
584 | - ':book' => $book_id, | ||
585 | - ':value' => $value_title, | ||
586 | - ':alias' => Translite::rusencode ($value_title), | ||
587 | - ] | ||
588 | - ) | ||
589 | - ->one(); | ||
590 | - | ||
591 | - if (! isset ($bookFeatureValue->book_value_id) || empty ($bookFeatureValue->book_value_id)) | ||
592 | - { | ||
593 | - $db->createCommand () | ||
594 | - ->insert (BookValue::tableName (), [ | ||
595 | - 'book_id' => $book_id, | ||
596 | - 'book_value_title' => $value_title, | ||
597 | - 'book_value_alias' => Translite::rusencode ($value_title), | ||
598 | - ]) | ||
599 | - ->execute (); | ||
600 | - | ||
601 | - $book_value_id = Yii::$app->db->lastInsertID; | ||
602 | - } | ||
603 | - else | ||
604 | - { | ||
605 | - $book_value_id = $bookFeatureValue->book_value_id; | ||
606 | - } | ||
607 | - | ||
608 | - if (! empty ($MOD_ARRAY)) | ||
609 | - { | ||
610 | - foreach ($MOD_ARRAY as $id) | ||
611 | - { | ||
612 | - // + products_value | ||
613 | - $db->createCommand (' | ||
614 | - INSERT IGNORE mod_value | ||
615 | - SET | ||
616 | - mod_id = '.(int)$id.', | ||
617 | - book_value_id = '.(int)$book_value_id.' | ||
618 | - ') | ||
619 | - ->execute (); | ||
620 | - } | ||
621 | - } | ||
622 | - } | ||
623 | - } | ||
624 | - }*/ | ||
625 | - | ||
626 | - // ==== IMPORTANT ==== | ||
627 | - | ||
628 | - // записуем ID обработанной записи | ||
629 | - | ||
630 | - $is_new_product = empty($_product->product_id); | ||
631 | - | ||
632 | $options = []; | 297 | $options = []; |
633 | 298 | ||
634 | if (! empty ($filters)) { | 299 | if (! empty ($filters)) { |
frontend/config/main.php
@@ -38,7 +38,22 @@ return [ | @@ -38,7 +38,22 @@ return [ | ||
38 | 'errorHandler' => [ | 38 | 'errorHandler' => [ |
39 | 'errorAction' => 'site/error', | 39 | 'errorAction' => 'site/error', |
40 | ], | 40 | ], |
41 | - | 41 | + 'imageCache' => [ |
42 | + 'class' => 'iutbay\yii2imagecache\ImageCache', | ||
43 | + 'sourcePath' => '@app/web/images', | ||
44 | + 'sourceUrl' => '@web/images', | ||
45 | + 'sizes' => [ | ||
46 | + 'brandlist' => [128, 128], | ||
47 | + 'product' => [300, 300], | ||
48 | + 'product_trumb' => [80, 80], | ||
49 | + 'product_trumb2' => [100, 100], | ||
50 | + 'product_list' => [130, 70], | ||
51 | + 'product_list2' => [130, 70], | ||
52 | + 'product_variant' => [40, 40], | ||
53 | + 'mainmenu' => [160, 170], | ||
54 | + 'large' => [600, 600], | ||
55 | + ], | ||
56 | + ], | ||
42 | 'urlManager' => [ | 57 | 'urlManager' => [ |
43 | 'enablePrettyUrl' => true, | 58 | 'enablePrettyUrl' => true, |
44 | 'showScriptName' => false, | 59 | 'showScriptName' => false, |
@@ -48,12 +63,20 @@ return [ | @@ -48,12 +63,20 @@ return [ | ||
48 | 'iam' => 'iam/index', | 63 | 'iam' => 'iam/index', |
49 | 'text/<translit:\w+>' => 'text/index', | 64 | 'text/<translit:\w+>' => 'text/index', |
50 | '<language:(ru|ua|en)>/text/<translit:\w+>' => 'text/index', | 65 | '<language:(ru|ua|en)>/text/<translit:\w+>' => 'text/index', |
51 | - 'catalog' => 'catalog/all', | ||
52 | - 'catalog/<translit:\w+>' => 'catalog/index', | ||
53 | - 'products/search' => 'products/search', | ||
54 | - 'products/compare' => 'products/compare', | ||
55 | - 'products/<translit:\w+>' => 'products/index', | ||
56 | - 'products/<translit_rubric:\w+>/<translit:[\w\-]+>-<id:\d+>' => 'products/show', | 66 | + [ |
67 | + 'class' => '\common\modules\product\CatalogUrlManager', | ||
68 | + 'route_map' => [ | ||
69 | + 'catalog' => 'catalog/category', | ||
70 | + 'product' => 'catalog/product', | ||
71 | + 'brand' => 'catalog/brand', | ||
72 | + ] | ||
73 | + ], | ||
74 | +// 'catalog' => 'catalog/all', | ||
75 | +// 'catalog/<translit:\w+>' => 'catalog/index', | ||
76 | +// 'products/search' => 'products/search', | ||
77 | +// 'products/compare' => 'products/compare', | ||
78 | +// 'products/<translit:\w+>' => 'products/index', | ||
79 | +// 'products/<translit_rubric:\w+>/<translit:[\w\-]+>-<id:\d+>' => 'products/show', | ||
57 | 'news/<translit:\w+>-<id:\d+>' => 'news/show', | 80 | 'news/<translit:\w+>-<id:\d+>' => 'news/show', |
58 | 'brends/<translit:[\w\-]+>' => 'brends/show', | 81 | 'brends/<translit:[\w\-]+>' => 'brends/show', |
59 | 'brends' => 'brends/index', | 82 | 'brends' => 'brends/index', |
frontend/controllers/CatalogController.php
@@ -78,14 +78,6 @@ class CatalogController extends \yii\web\Controller | @@ -78,14 +78,6 @@ class CatalogController extends \yii\web\Controller | ||
78 | ] | 78 | ] |
79 | ); | 79 | ); |
80 | 80 | ||
81 | - } elseif ($category->depth < 2) { | ||
82 | - return $this->render( | ||
83 | - 'categories', | ||
84 | - [ | ||
85 | - 'category' => $category, | ||
86 | - 'last_products' => $last_products, | ||
87 | - ] | ||
88 | - ); | ||
89 | } else { | 81 | } else { |
90 | $params = []; | 82 | $params = []; |
91 | 83 | ||
@@ -161,6 +153,7 @@ class CatalogController extends \yii\web\Controller | @@ -161,6 +153,7 @@ class CatalogController extends \yii\web\Controller | ||
161 | 153 | ||
162 | public function actionProduct() | 154 | public function actionProduct() |
163 | { | 155 | { |
156 | + /** @var Product $product */ | ||
164 | $product = Yii::$app->request->get('product'); | 157 | $product = Yii::$app->request->get('product'); |
165 | 158 | ||
166 | $groups = []; | 159 | $groups = []; |
@@ -174,12 +167,14 @@ class CatalogController extends \yii\web\Controller | @@ -174,12 +167,14 @@ class CatalogController extends \yii\web\Controller | ||
174 | if (empty($group->_options)) | 167 | if (empty($group->_options)) |
175 | unset($groups[$i]); | 168 | unset($groups[$i]); |
176 | } | 169 | } |
170 | + $category = $product->category; | ||
177 | 171 | ||
178 | $last_products = ProductHelper::getLastProducts(true); | 172 | $last_products = ProductHelper::getLastProducts(true); |
179 | ProductHelper::addLastProsucts($product->product_id); | 173 | ProductHelper::addLastProsucts($product->product_id); |
180 | 174 | ||
181 | return $this->render('product', [ | 175 | return $this->render('product', [ |
182 | 'product' => $product, | 176 | 'product' => $product, |
177 | + 'category' => $category, | ||
183 | 'properties' => $groups, | 178 | 'properties' => $groups, |
184 | 'last_products' => $last_products | 179 | 'last_products' => $last_products |
185 | ]); | 180 | ]); |
frontend/controllers/SiteController.php
@@ -11,7 +11,15 @@ use common\models\Products; | @@ -11,7 +11,15 @@ use common\models\Products; | ||
11 | 11 | ||
12 | class SiteController extends Controller | 12 | class SiteController extends Controller |
13 | { | 13 | { |
14 | - | 14 | + /** |
15 | + * @inheritdoc | ||
16 | + */ | ||
17 | + public function actions() | ||
18 | + { | ||
19 | + return [ | ||
20 | + 'thumb' => 'iutbay\yii2imagecache\ThumbAction', | ||
21 | + ]; | ||
22 | + } | ||
15 | 23 | ||
16 | public function actionIndex() | 24 | public function actionIndex() |
17 | { | 25 | { |
@@ -43,4 +51,6 @@ class SiteController extends Controller | @@ -43,4 +51,6 @@ class SiteController extends Controller | ||
43 | ]); | 51 | ]); |
44 | } | 52 | } |
45 | 53 | ||
54 | + | ||
55 | + | ||
46 | } | 56 | } |
47 | \ No newline at end of file | 57 | \ No newline at end of file |
frontend/models/ProductFrontendSearch.php
@@ -51,7 +51,7 @@ class ProductFrontendSearch extends Product { | @@ -51,7 +51,7 @@ class ProductFrontendSearch extends Product { | ||
51 | } else { | 51 | } else { |
52 | $query = Product::find(); | 52 | $query = Product::find(); |
53 | } | 53 | } |
54 | - $query->joinWith('variant'); | 54 | +// $query->joinWith('variant'); |
55 | $query->joinWith('brand'); | 55 | $query->joinWith('brand'); |
56 | $query->joinWith('image'); | 56 | $query->joinWith('image'); |
57 | $query->joinWith('categories'); | 57 | $query->joinWith('categories'); |
@@ -59,7 +59,7 @@ class ProductFrontendSearch extends Product { | @@ -59,7 +59,7 @@ class ProductFrontendSearch extends Product { | ||
59 | $dataProvider = new ActiveDataProvider([ | 59 | $dataProvider = new ActiveDataProvider([ |
60 | 'query' => $query, | 60 | 'query' => $query, |
61 | 'pagination' => [ | 61 | 'pagination' => [ |
62 | - 'pageSize' => 24, | 62 | + 'pageSize' => 15, |
63 | ], | 63 | ], |
64 | 'sort' => [ | 64 | 'sort' => [ |
65 | 'attributes' => [ | 65 | 'attributes' => [ |
frontend/views/catalog/product.php
1 | <?php | 1 | <?php |
2 | -/** @var $this \yii\web\View */ | ||
3 | -/** @var $dataProvider \yii\data\ActiveDataProvider */ | 2 | +use yii\widgets\Breadcrumbs; |
3 | +use yii\web\View; | ||
4 | +use yii\helpers\Url; | ||
5 | + | ||
4 | $this->title = $product->name; | 6 | $this->title = $product->name; |
7 | +//$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->name; | ||
8 | +//$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->name)]); | ||
9 | +//$this->registerMetaTag (['name' => 'keywords', 'content' => $product->meta_keywords]); | ||
10 | + | ||
5 | foreach($product->category->getParents()->all() as $parent) { | 11 | foreach($product->category->getParents()->all() as $parent) { |
6 | $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; | 12 | $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; |
7 | } | 13 | } |
8 | $this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]]; | 14 | $this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]]; |
9 | $this->params['breadcrumbs'][] = $product->name .' #'. $product->variant->sku; | 15 | $this->params['breadcrumbs'][] = $product->name .' #'. $product->variant->sku; |
10 | -?> | ||
11 | -<h1 class="open_card_item_title"><?= $product->name .' '. $product->variant->name?></h1> | ||
12 | - | ||
13 | -<div class="item_3_blocks_wrap" id="one_item_block" data-id="<?= $product->variant->product_variant_id?>"> <!-- flex container --> | ||
14 | - <div class="item_img_block"> <!-- блок с фотографиями --> | ||
15 | - <div class="main_img"> | ||
16 | - <?php if (empty($product->image)) :?> | ||
17 | - <img src="/images/no_photo_big.png" alt="<?= $product->name?>"> | ||
18 | - <?php else :?> | ||
19 | - <img src="/images/<?= $product->image->image?>" alt="<?= $product->image->alt ? $product->image->alt : $product->name?>"> | ||
20 | - <?php endif?> | ||
21 | - | ||
22 | - <!--<span class="new">НОВИНКА</span> | ||
23 | - <span class="top">ТОП</span>--> | ||
24 | - </div> | ||
25 | - <div class="product_service"> | ||
26 | - <ul> | ||
27 | - <li class="item1"><a id="add_to_bookmarks" href="#">Добавить в закладки</a> | ||
28 | - </li> | ||
29 | - <li class="item3"><a id="add_to_compare" href="#">Добавить в | ||
30 | - сравнение</a></li> | ||
31 | - </ul> | ||
32 | - </div> | ||
33 | - <?php if (!empty($product->images)) :?> | ||
34 | - <div class="main_img_slide"> | ||
35 | - <?php foreach($product->images as $image) :?> | ||
36 | - <div class="small_img_block active"> | ||
37 | - <img src="/images/<?= $image->image?>" alt="<?= $image->alt ? $image->alt : $product->name?>"> | ||
38 | - </div> | ||
39 | - <?php endforeach?> | ||
40 | 16 | ||
41 | - <img class="slider_arrow_right" src="/images/slider_right.png" alt=""> | ||
42 | - <img class="slider_arrow_left" src="/images/slider_left.png" alt=""> | ||
43 | - </div> | ||
44 | - <?php endif?> | 17 | +$this->registerJs (' |
45 | 18 | ||
46 | - </div> <!-- конец блока с фотографиями --> | 19 | + var checkData = function($index) |
20 | + { | ||
21 | + var $source = $(".productLeftBar .product_mod > li").eq($index).find("a"); | ||
22 | + var $target = $(".productLeftBar .cost_box"); | ||
47 | 23 | ||
24 | + $("#cost").text($source.data("cost")); | ||
25 | + $("#old_cost").text($source.data("old_cost")); | ||
48 | 26 | ||
49 | - <div class="busket_block"> <!-- блок с счетчиком и кнопкой добавить в корзину --> | ||
50 | - <div class="top_code"> | ||
51 | - <span class="code">Код: <?= $product->variant->sku?></span> | ||
52 | - <span class="have"><img src="/images/ok_icon_green.png" alt=""><?= $product->stock !== 0 && $product->variant->price > 0 ? ' есть в наличии' : ' нет в наличии'?></span> | ||
53 | - </div> | 27 | + if (parseInt ($source.data("old_cost")) == 0) |
28 | + { | ||
29 | + $target.find("strike").hide(); | ||
30 | + } | ||
31 | + else | ||
32 | + { | ||
33 | + $target.find("strike").show(); | ||
34 | + } | ||
54 | 35 | ||
55 | - <div class="grey_bg"> | ||
56 | - <div class="counter"> | ||
57 | - <?php if ($product->variant->price > 0) :?> | ||
58 | - <div class="price"> | ||
59 | - <?= $product->variant->price?> | ||
60 | - </div> | ||
61 | - <div class="sign">грн.</div> | ||
62 | - <?php else :?> | ||
63 | - <div class="price"></div> | ||
64 | - <?php endif?> | ||
65 | - | ||
66 | - <div class="count_block"> | ||
67 | - <input type="text" name="" class="form-control buy_one_item" value="1"> | ||
68 | - <div class="count_buttons"> | ||
69 | - <div class="button_plus">+</div> | ||
70 | - <div class="button_minus">-</div> | ||
71 | - </div> | ||
72 | - </div> | ||
73 | - </div> | 36 | + $("#product_id").val($source.data("id")); |
37 | + $("#art").text($source.data("art")); | ||
38 | + $("#color").text($source.data("color")); | ||
39 | + $("#pic").attr("src",$source.data("image")); | ||
40 | + $("#picoriginal").attr("href",$source.data("imageoriginal")); | ||
41 | + } | ||
74 | 42 | ||
75 | - <div class="in_cart_btn"> | ||
76 | - <a href="#"> | ||
77 | - <button class="cart_btn" data-id="<?= $product->variant->product_variant_id?>"> в корзину <img src="/images/ico_basket_white.png" alt=""></button> | ||
78 | - </a> | ||
79 | - </div> | 43 | + $(".product_mod > li").click(function() |
44 | + { | ||
45 | + checkData($(this).index()); | ||
80 | 46 | ||
81 | - <!--<div class="to_compare_link"> | ||
82 | - <img src="/images/ico_scales.png" alt=""> | ||
83 | - <a href="#" class="add_to_compare">добавить к сравнению</a> | ||
84 | - </div>--> | ||
85 | - </div> | ||
86 | - <div class="quick_order"> | ||
87 | - <form action=""> | ||
88 | - <span class="text">БЫСТРЫЙ ЗАКАЗ</span> | ||
89 | - <input type="text" class="quick_order_phone" name="quick_order_phone" placeholder="(0XX) XXX-XX-XX"> | ||
90 | - <button type="submit">заказать</button> | ||
91 | - </form> | ||
92 | - </div> | 47 | + Shadowbox.setup($("#picoriginal")); |
93 | 48 | ||
94 | - <div class="delivery"> | ||
95 | - <p> | ||
96 | - Доставка товара на следующий день после выставления счета. Мы доставим “День в <br> день” — уточните это у менеджера. | ||
97 | - </p> | ||
98 | - <a href="#">Подробно о доставке</a> | ||
99 | - </div> | 49 | + return false; |
50 | + }); | ||
100 | 51 | ||
101 | - </div><!-- конец блока с счетчиком и кнопкой добавить в корзину --> | ||
102 | - | ||
103 | - <div class="character_block"> <!-- блок с характеристиками --> | ||
104 | - <?php if (!empty($properties)) :?> | ||
105 | - <h3>Характеристики</h3> | ||
106 | - <ul> | ||
107 | - <?php foreach($properties as $group) :?> | ||
108 | - <li> | ||
109 | - <div class="each"> | ||
110 | - <div class="title"><?= $group->name?></div> | ||
111 | - <div class="tech"> | ||
112 | - <?php foreach($group->_options as $option) :?> <?= $option->ValueRenderHTML?><?php endforeach?> | ||
113 | - </div> | ||
114 | - </div> | ||
115 | - </li> | ||
116 | - <?php endforeach?> | 52 | + checkData(0); |
53 | + | ||
54 | + ', View::POS_READY, 'fasovka'); | ||
55 | + | ||
56 | +$this->registerJs (" | ||
57 | + $('#nav_product li a').addClass('active'); | ||
58 | + $('#nav_product li').find('.info').toggle(); | ||
59 | + | ||
60 | + $('#nav_product li a').bind('click',function() | ||
61 | + { | ||
62 | + if($(this).parent().find('.info').css('display')=='none')$(this).addClass('active'); | ||
63 | + else $(this).removeClass('active'); | ||
64 | + $(this).parent().find('.info').toggle(); | ||
65 | + | ||
66 | + return false; | ||
67 | + }); | ||
68 | + ", View::POS_READY, 'nav_product'); | ||
69 | + | ||
70 | +$this->registerCssFile (Yii::$app->request->BaseUrl . '/js/shadowbox-3.0.3/shadowbox.css'); | ||
71 | +$this->registerJsFile (Yii::$app->request->baseUrl . '/js/shadowbox-3.0.3/shadowbox.js', ['position' => View::POS_HEAD, 'depends' => ['yii\web\JqueryAsset']]); | ||
72 | +$this->registerJs (" | ||
73 | + Shadowbox.init({ | ||
74 | + | ||
75 | + }); | ||
76 | + ", View::POS_READY, 'Shadowbox'); | ||
77 | +?> | ||
78 | + | ||
79 | + | ||
80 | +<nav class="bread-crumbs"> | ||
81 | + <?= Breadcrumbs::widget ([ | ||
82 | + 'links' => [ | ||
83 | + ['label' => 'Каталог', 'url' => ['catalog/all']], | ||
84 | + // ['label'=>$catalog->parent->name,'url'=>['catalog/index','translit'=>$catalog->parent->translit]], | ||
85 | + ['label' => $category->name, 'url' => ['catalog/category', 'category' => $category]], | ||
86 | + $product->name, | ||
87 | + ], | ||
88 | + ]) ?> | ||
89 | + <div class="both"></div> | ||
90 | +</nav> | ||
91 | +<?php if ($flash = Yii::$app->session->getFlash ('success')): ?> | ||
92 | + <div class="alert-success"><?= $flash ?></div> | ||
93 | +<?php endif; ?> | ||
94 | +<div class="loyout"> | ||
95 | + | ||
96 | + | ||
97 | + <div class="productLeftBar"> | ||
98 | + <h1><?= $product->name ?></h1> | ||
99 | + <div class="begin">Цветовые решения</div> | ||
100 | + <ul class="product_mod"> | ||
101 | + <?php foreach ($product->variants as $variant): ?> | ||
102 | + <li> | ||
103 | + <a id='m<?= $variant->product_variant_id ?>' href="#" | ||
104 | + data-cost="<?= $variant->price ?>" | ||
105 | + data-old_cost="<?= $variant->price_old ?>" data-id="<?= $variant->product_variant_id ?>" data-art="<?= $variant->sku ?>" | ||
106 | + data-color="<?= $variant->name ?>" | ||
107 | + data-image="<?= $variant->image->imageUrl ?>" | ||
108 | + data-imageoriginal="<?= $variant->image->imageUrl ?>" | ||
109 | + title="<?= $product->name ?>"> | ||
110 | + <?= Yii::$app->imageCache->thumb($variant->image->imageUrl, 'product_variant')?> | ||
111 | + </a> | ||
112 | + </li> | ||
113 | + <?php endforeach; ?> | ||
117 | </ul> | 114 | </ul> |
118 | - <?php endif?> | ||
119 | - | ||
120 | - <!--<div class="tech_links"> | ||
121 | - <a href="#">Описание</a> | ||
122 | - <a href="#">Видео</a> | ||
123 | - <a href="#">Отзывы(12)</a> | ||
124 | - </div>--> | ||
125 | - | ||
126 | - </div><!-- закрытие блока с характеристиками --> | ||
127 | - <hr> | ||
128 | - | ||
129 | - <h1 class="with_this">С этим товаром покупают</h1> | ||
130 | - | ||
131 | - <div class="flex_container"><!-- блок - с этим также покупают --> | ||
132 | - | ||
133 | - <div class="my_custom_card"> | ||
134 | - <div class="new">АКЦИЯ</div> | ||
135 | - <div class="top">Toп</div> | ||
136 | - <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div> | ||
137 | - <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a> | ||
138 | - <div class="brand">Бренд: <span>Knauf</span></div> | ||
139 | - <div class="type">Штукатурки</div> | ||
140 | - <div class="price">102.05 <span>грн.</span></div> | ||
141 | - <button class="basket_add_but">в корзину</button> | ||
142 | - <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a> | ||
143 | - <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt=""> | ||
144 | - </div> | 115 | + <div class="both"></div> |
145 | 116 | ||
146 | - <div class="my_custom_card"> | ||
147 | - <div class="new">АКЦИЯ</div> | ||
148 | - <div class="top">Toп</div> | ||
149 | - <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div> | ||
150 | - <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a> | ||
151 | - <div class="brand">Бренд: <span>Knauf</span></div> | ||
152 | - <div class="type">Штукатурки</div> | ||
153 | - <div class="price">102.05 <span>грн.</span></div> | ||
154 | - <button class="basket_add_but">в корзину</button> | ||
155 | - <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a> | ||
156 | - <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt=""> | 117 | + <div class="cost_box"> |
118 | + <div class='params'>код: <span id='art'></span><br/> цвет: <span id='color'></span></div> | ||
119 | + <div class="w"> | ||
120 | + <strike><span id='old_cost'>0</span> грн.</strike><br/> | ||
121 | + <span class="cost"><span id='cost'>0</span> <span class="valute">грн.</span></span> | ||
122 | + </div> | ||
123 | + <input type='hidden' id='product_id'/> | ||
124 | + <a href="#" rel='product' class="link_buy fl">В Корзину</a> | ||
125 | + <div class="both"></div> | ||
157 | </div> | 126 | </div> |
158 | 127 | ||
159 | - <div class="my_custom_card"> | ||
160 | - <div class="new">АКЦИЯ</div> | ||
161 | - <div class="top">Toп</div> | ||
162 | - <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div> | ||
163 | - <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a> | ||
164 | - <div class="brand">Бренд: <span>Knauf</span></div> | ||
165 | - <div class="type">Штукатурки</div> | ||
166 | - <div class="price">102.05 <span>грн.</span></div> | ||
167 | - <button class="basket_add_but">в корзину</button> | ||
168 | - <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a> | ||
169 | - <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt=""> | 128 | + <div class="product_service"> |
129 | + <ul> | ||
130 | + <li class="item1"><a href="<?= Url::to (['iam/share', 'id' => $product->product_id]) ?>">Добавить в закладки</a> | ||
131 | + </li> | ||
132 | + <li class="item2"><a href="<?= Url::to (['iam/price', 'id' => $product->product_id]) ?>">Узнать о снижение | ||
133 | + цены</a></li> | ||
134 | + <li class="item3"><a href="<?= Url::to (['products/compare', 'id' => $product->product_id]) ?>">Добавить в | ||
135 | + сравнение</a></li> | ||
136 | + </ul> | ||
170 | </div> | 137 | </div> |
171 | 138 | ||
172 | - <div class="my_custom_card"> | ||
173 | - <div class="new">АКЦИЯ</div> | ||
174 | - <div class="top">Toп</div> | ||
175 | - <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div> | ||
176 | - <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a> | ||
177 | - <div class="brand">Бренд: <span>Knauf</span></div> | ||
178 | - <div class="type">Штукатурки</div> | ||
179 | - <div class="price">102.05 <span>грн.</span></div> | ||
180 | - <button class="basket_add_but">в корзину</button> | ||
181 | - <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a> | ||
182 | - <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt=""> | ||
183 | - </div> | 139 | + </div> |
184 | 140 | ||
185 | - </div> <!-- конец блока - с этим также покупают --> | ||
186 | - <div class="tabs_block"> <!-- Табы с описанием видео и отзывами --> | ||
187 | - <div class="ionTabs" id="tabs_1" data-name="Tabs_Group_name"> | ||
188 | - <ul class="ionTabs__head"> | ||
189 | - <?php if (!empty($properties)) :?> | ||
190 | - <li class="ionTabs__tab" data-target="Tab_1_name">Характеристики</li> | ||
191 | - <?php endif?> | ||
192 | - <?php if (TRUE || !empty($product->description)) :?> | ||
193 | - <li class="ionTabs__tab" data-target="Tab_2_name">Описание</li> | ||
194 | - <?php endif?> | ||
195 | - <?php if (TRUE || !empty($product->video)) :?> | ||
196 | - <li class="ionTabs__tab" data-target="Tab_3_name">Видео</li> | ||
197 | - <?php endif?> | ||
198 | -<!-- <li class="ionTabs__tab" data-target="Tab_4_name">Отзывы(12)</li>--> | ||
199 | - </ul> | ||
200 | - <div class="ionTabs__body"> | ||
201 | - <?php if (!empty($properties)) :?> | ||
202 | - <div class="ionTabs__item character_block" data-name="Tab_1_name"> | ||
203 | - <ul> | ||
204 | - <?php foreach($properties as $group) :?> | ||
205 | - <li> | ||
206 | - <div class="each"> | ||
207 | - <div class="title"><?= $group->name?></div> | ||
208 | - <div class="tech"> | ||
209 | - <?php foreach($group->_options as $option) :?> <?= $option->ValueRenderHTML?><?php endforeach?> | ||
210 | - </div> | ||
211 | - </div> | ||
212 | - </li> | ||
213 | - <?php endforeach?> | ||
214 | - </ul> | 141 | + <div class="productRightBar"> |
142 | + <ul id="nav_product"> | ||
143 | + <li><a href="#">Характеристики</a> | ||
144 | + <div class="info"> | ||
145 | + <p>Бренд: <?= $product->brand->name ?></p> | ||
146 | + <?php foreach ($properties as $group): ?> | ||
147 | + <p><?= $group->name ?> <?php foreach($group->_options as $option) :?> <?= $option->ValueRenderHTML?><?php endforeach?></p> | ||
148 | + <?php endforeach; ?> | ||
215 | </div> | 149 | </div> |
216 | - <?php else :?> | ||
217 | - <?php endif?> | ||
218 | - <?php if (!empty($product->description)) :?> | ||
219 | - <div class="ionTabs__item" data-name="Tab_2_name"> | ||
220 | - <?= $product->description?> | ||
221 | - </div> | ||
222 | - <?php endif?> | ||
223 | - <?php if (!empty($product->video)) :?> | ||
224 | - <div class="ionTabs__item" data-name="Tab_3_name"> | ||
225 | - <?= $product->video?> | 150 | + </li> |
151 | + <li><a href="#">Описание</a> | ||
152 | + <div class="info"> | ||
153 | + <?= $product->description ?> | ||
226 | </div> | 154 | </div> |
227 | - <?php endif?> | 155 | + </li> |
228 | 156 | ||
229 | - <div class="ionTabs__preloader"></div> | ||
230 | - </div> | ||
231 | - </div> | 157 | + </ul> |
158 | + </div> | ||
232 | 159 | ||
233 | - </div> <!-- конец табов с описанием видео и отзывами --> | ||
234 | - <div style="clear: both;"></div> | ||
235 | - | ||
236 | - <?php if(!empty($last_products)) :?> | ||
237 | - <hr> | ||
238 | - <div class="watched_block"> | ||
239 | - <h1>Вы недавно просматривали</h1> | ||
240 | - <div class="flex-container"> | ||
241 | - <?php foreach($last_products as $product) :?> | ||
242 | - <?php require(__DIR__ .'/product_smart.php')?> | ||
243 | - <?php endforeach?> | 160 | + <div class="content"> |
161 | + | ||
162 | + | ||
163 | + <div class="pic"> | ||
164 | + <center> | ||
165 | + <a href="#" rel="shadowbox[gal]" id="picoriginal"><?= Yii::$app->imageCache->thumb($product->image->imageUrl, 'product')?></a> | ||
166 | + </center> | ||
244 | </div> | 167 | </div> |
245 | - </div> | ||
246 | - <?php endif?> | 168 | + <ul class="product_colors"> |
169 | + <?php foreach ($product->images as $image): ?> | ||
170 | + <li><a href="<?= $image->imageUrl ?>" | ||
171 | + rel="shadowbox[gal]"> | ||
172 | + <?= Yii::$app->imageCache->thumb($variant->image->imageUrl, 'product_trumb2')?> | ||
173 | + </a></li> | ||
174 | + <?php endforeach; ?> | ||
175 | + </ul> | ||
176 | + | ||
247 | 177 | ||
248 | -</div> <!-- end flex container --> | 178 | + </div> |
179 | + <div class="both"></div> | ||
180 | +</div> | ||
249 | \ No newline at end of file | 181 | \ No newline at end of file |
frontend/views/catalog/product_item.php
1 | <?php | 1 | <?php |
2 | /** @var \common\modules\product\models\Product $product */ | 2 | /** @var \common\modules\product\models\Product $product */ |
3 | - | 3 | +use yii\helpers\Url; |
4 | ?> | 4 | ?> |
5 | -<div class="item" data-id="<?= $product->product_id?>"> | ||
6 | - <!--<div class="new">АКЦИЯ</div> | ||
7 | - <div class="top">Toп</div>--> | ||
8 | - <a href="<?= \yii\helpers\Url::to(['catalog/product', 'product' => $product])?>" class="item_link"> | ||
9 | - <div class="pic"> | ||
10 | - <?php if (empty($product->image)) :?> | ||
11 | - <img src="/images/no_photo.png"> | ||
12 | - <?php else :?> | ||
13 | - <img src="/images/<?= $product->image->image?>" alt="<?= $product->image->alt ? $product->image->alt : $product->name?>"> | ||
14 | - <?php endif?> | 5 | +<li class="item" data-id="<?= $product->product_id?>"<?= (empty($product->variant) ? ' style="opacity: 0.5"' : '')?>> |
6 | + <div class="boxitem"> | ||
7 | + <div class="pixbox"> | ||
8 | + <a href="<?= Url::to([ | ||
9 | + 'catalog/product', | ||
10 | + 'product' => $product]) | ||
11 | + ?>"> | ||
12 | + <?php if (empty($product->image)) :?> | ||
13 | + <img src="/img/no_photo.png"> | ||
14 | + <?php else :?> | ||
15 | + <?= Yii::$app->imageCache->thumb($product->image->imageUrl, 'product_list')?> | ||
16 | + <?php endif?> | ||
17 | + </a> | ||
15 | </div> | 18 | </div> |
16 | - <div class="title_item"><?= $product->name?></div></a> | ||
17 | - <?php if (!empty($product->brand)) :?> | ||
18 | - <div class="brand">Бренд: <span><?= $product->brand->name?></span></div> | ||
19 | - <?php endif?> | ||
20 | - <div class="type"><?= implode(', ', $product->categoriesNames)?></div> | ||
21 | - <?php if($product->variant) :?> | ||
22 | - <div class="price"><?= $product->variant->price?> <span>грн.</span></div> | ||
23 | - <button class="basket_add_but" data-id="<?= $product->variant->product_variant_id?>">в корзину</button> | ||
24 | - <?php endif?> | ||
25 | - <a href="#" class="compare_add_but" data-id="<?= $product->product_id?>"><span>добавить к сравнению</span></a> | ||
26 | - <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt=""> | ||
27 | -</div> | ||
28 | \ No newline at end of file | 19 | \ No newline at end of file |
20 | + <a href="<?= Url::to([ | ||
21 | + 'catalog/product', | ||
22 | + 'product' => $product]) | ||
23 | + ?>" class="name"><?= $product->name ?> | ||
24 | + </a> | ||
25 | + | ||
26 | + <?php | ||
27 | + | ||
28 | + echo '<div class="cost-block">'; | ||
29 | + | ||
30 | + // есть скидка | ||
31 | + if ($product->variant->price_old != 0 && $product->variant->price_old != $product->variant->price) | ||
32 | + { | ||
33 | + echo '<strike><span id=\'old_cost\'>'.$product->variant->price_old.'</span> грн.</strike>'; | ||
34 | + } | ||
35 | + | ||
36 | + echo '<p class="cost">'.$product->variant->price.' грн.</p>'; | ||
37 | + | ||
38 | + echo '</div>'; | ||
39 | + | ||
40 | + ?> | ||
41 | + </div> | ||
42 | + <a href="<?= Url::to([ | ||
43 | + 'catalog/product', | ||
44 | + 'product' => $product]) | ||
45 | + ?>" class="link_buy">Купить</a> | ||
46 | + | ||
47 | + <div class="mycarousel"> | ||
48 | + <ul class="jcarousel jcarousel-skin-tango"> | ||
49 | + <?php foreach ($product->variants as $variant) : ?> | ||
50 | + <?php if (!empty($variant->image)) :?> | ||
51 | + <li> | ||
52 | + <a href="<?= Url::to([ | ||
53 | + 'catalog/product', | ||
54 | + 'product' => $product, | ||
55 | + '#' => 'm' . $variant->product_variant_id]) ?>"> | ||
56 | + <?= Yii::$app->imageCache->thumb($variant->image->imageUrl, 'product_list')?> | ||
57 | + </a> | ||
58 | + </li> | ||
59 | + <?php endif; ?> | ||
60 | + <?php endforeach; ?> | ||
61 | + </ul> | ||
62 | + </div> | ||
63 | +</li> | ||
29 | \ No newline at end of file | 64 | \ No newline at end of file |
frontend/views/catalog/products.php
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | 5 | ||
6 | 6 | ||
7 | use yii\helpers\Url; | 7 | use yii\helpers\Url; |
8 | +use yii\widgets\Breadcrumbs; | ||
8 | use common\modules\product\helpers\ProductHelper; | 9 | use common\modules\product\helpers\ProductHelper; |
9 | 10 | ||
10 | $this->title = $category->categoryName->value; | 11 | $this->title = $category->categoryName->value; |
@@ -46,52 +47,32 @@ $filterWhitoutPrice['prices'] = [ | @@ -46,52 +47,32 @@ $filterWhitoutPrice['prices'] = [ | ||
46 | }); | 47 | }); |
47 | }); | 48 | }); |
48 | <?php endif?> | 49 | <?php endif?> |
49 | -<?php /* | ||
50 | - $(document).ready(function() { | ||
51 | - $('form.filter-catalog-form').each(function() { | ||
52 | - var form = $(this); | ||
53 | - form.submit(function(e) { | ||
54 | - e.preventDefault(); | ||
55 | - var brands = ''; | ||
56 | - // Get brands values | ||
57 | - $('input[type=checkbox].brands-option:checked', form).each(function() { | ||
58 | - var filter_value = $(this).val().replace(',', '~').replace('/', '&s;'); | ||
59 | - if (brands) { | ||
60 | - brands += ','+ filter_value; | ||
61 | - } else { | ||
62 | - brands = filter_value; | ||
63 | - } | ||
64 | - }); | ||
65 | - // Formate query and redirect | ||
66 | - var filter = ''; | ||
67 | - if (brands) { | ||
68 | - filter += 'brands='+ brands; | ||
69 | - } | ||
70 | - filter += ';'; | ||
71 | - | ||
72 | - if (filter) { | ||
73 | - var request = '<?= Url::toRoute(['catalog/category/filter', 'alias' => $category->alias, 'filter' => '+ filter .'])?>'; | ||
74 | - window.location.href = request; | ||
75 | - } | ||
76 | - }); | ||
77 | - }); | ||
78 | - }); | ||
79 | -*/?> | ||
80 | </script> | 50 | </script> |
81 | -<div class="w_960"> | ||
82 | - <!-- side bar with all filters --> | ||
83 | - <div class="cat_p_filter_bar"> | ||
84 | - <div class="title">ФИЛЬТРЫ</div> | ||
85 | - <div class="filter_list"> | ||
86 | - <form action="#" name="filter_catalog_page_form" class="filter-catalog-form"> | ||
87 | - <?php if (!empty($filter)) :?> | 51 | + |
52 | +<nav class="bread-crumbs"> | ||
53 | + <?= Breadcrumbs::widget ([ | ||
54 | + 'links' => $this->params['breadcrumbs'], | ||
55 | + ]) | ||
56 | + ?> | ||
57 | + | ||
58 | + | ||
59 | + <div class="both"></div> | ||
60 | +</nav> | ||
61 | + | ||
62 | +<div class="loyout"> | ||
63 | + <div class="leftbar"> | ||
64 | + <img src="<?= Yii::$app->request->baseUrl ?>/img/new_coll.png" width="112" height="22"/><br/> | ||
65 | + <img src="<?= Yii::$app->request->baseUrl ?>/img/pro.png" width="42" height="22"/> | ||
66 | + | ||
67 | + <form action="#" name="filter_catalog_page_form" class="filter-catalog-form"> | ||
68 | + <?php if (FALSE && !empty($filter)) :?> | ||
88 | <div class="filter_accept_bloc"> | 69 | <div class="filter_accept_bloc"> |
89 | <!-- <button type="submit" class="filter_accept_btn">применить</button>--> | 70 | <!-- <button type="submit" class="filter_accept_btn">применить</button>--> |
90 | <a href="<?= Url::to(['catalog/category', 'category' => $category])?>" class="_form_checkbox_reset">сбросить фильтры</a> | 71 | <a href="<?= Url::to(['catalog/category', 'category' => $category])?>" class="_form_checkbox_reset">сбросить фильтры</a> |
91 | </div> | 72 | </div> |
92 | - <?php endif?> | ||
93 | - <ul> | ||
94 | - <?php if ($priceLimits['min'] < $priceLimits['max']) :?> | 73 | + <?php endif?> |
74 | + | ||
75 | + <?php if (FALSE && $priceLimits['min'] < $priceLimits['max']) :?> | ||
95 | <li>Цена: | 76 | <li>Цена: |
96 | <div class="arrow"><img src="/images/head_up.png" alt=""></i></div> | 77 | <div class="arrow"><img src="/images/head_up.png" alt=""></i></div> |
97 | <div class="price_filter first_price_li"> | 78 | <div class="price_filter first_price_li"> |
@@ -100,142 +81,65 @@ $filterWhitoutPrice['prices'] = [ | @@ -100,142 +81,65 @@ $filterWhitoutPrice['prices'] = [ | ||
100 | </div> | 81 | </div> |
101 | </div> | 82 | </div> |
102 | </li> | 83 | </li> |
103 | - <?php endif?> | ||
104 | - | ||
105 | - <?php if ($brandProvider->totalCount > 0) :?> | ||
106 | - <li>Бренд | ||
107 | - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div> | ||
108 | - <div class="price_filter<?= !empty($filter['brands'])?' active-field':''?>"> | ||
109 | - <?php foreach($brandProvider->models as $brand) : | ||
110 | - $checked = !empty($filter['brands']) && in_array($brand->alias, $filter['brands']); | ||
111 | - $option_url = Url::to(['catalog/category', 'category' => $category, 'filter' => ProductHelper::getFilterForOption($filter, 'brands', $brand->alias, $checked)]); | ||
112 | - ?> | ||
113 | - <div class="checkbox"> | ||
114 | - <label><input type="checkbox" class="brands-option" <?php /*name="brands[]" value="<?= $brand->alias?>"*/?><?= $checked ? ' checked' : ''?> onchange="document.location='<?= $option_url?>'" /></label> | ||
115 | - <a href="<?= $option_url?>"><?= $brand->name?> (<?= $brand->getProducts()->count()?>)</a> | ||
116 | - </div> | ||
117 | - <?php endforeach?> | ||
118 | - </div> | ||
119 | - </li> | ||
120 | - <?php endif?> | ||
121 | - | ||
122 | - <?php if (!empty($groups)) :?> | ||
123 | - <div class="title_2">ПОДБОР ПО ПАРАМЕТРАМ</div> | ||
124 | - | ||
125 | - <?php foreach($groups as $group) :?> | ||
126 | - <li><?= $group->name?> | ||
127 | - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div> | ||
128 | - <div class="price_filter<?= isset($filter['options'][$group->alias])?' active-field':''?>"> | ||
129 | - <?php foreach($group->_options as $option) : | ||
130 | - $checked = (isset($filter['options'][$group->alias]) && in_array($option->alias, $filter['options'][$group->alias])); | ||
131 | - $option_url = Url::to(['catalog/category', 'category' => $category, 'filter' => ProductHelper::getFilterForOption($filter, 'options', [$option->group->alias => [$option->alias]], $checked)]); | ||
132 | - ?> | ||
133 | - <div class="checkbox"> | ||
134 | - <label><input type="checkbox" class="features-option" onchange="document.location='<?= $option_url?>'" <?php /* name="option[<?= $group->alias?>][]"value="<?= $option->alias?>"*/?><?= $checked ? ' checked' : ''?> /></label> | ||
135 | - <a href="<?= $option_url?>"><?= $option->ValueRenderHTML?> (<?= $option->_items_count?>)</a> | ||
136 | - </div> | ||
137 | - <?php endforeach?> | ||
138 | - </div> | ||
139 | - </li> | ||
140 | - <?php endforeach?> | ||
141 | - <?php endif?> | ||
142 | - </ul> | ||
143 | - </form> | ||
144 | - </div> | ||
145 | - </div> | ||
146 | - | ||
147 | - <!-- catalog list with all item cards --> | ||
148 | - <div class="cat_p_catalog_list"> | ||
149 | - <div class="title"><?= $category->categoryName->value?> <span>(<?= $productProvider->totalCount?>)</span></div> | ||
150 | - <?php if (!$productProvider->count) :?> | ||
151 | - <h2>По данному запросу товары не найдены.</h2><br> | ||
152 | - <?php if (!empty($category)) :?> | ||
153 | - <p>Показать <a href="<?= Url::to(['catalog/category', 'category' => $category])?>">все товары из категории "<?= $category->categoryName->value?>"</a></p> | ||
154 | - <?php endif?> | ||
155 | - <?php else :?> | ||
156 | - <!-- sort menu --> | ||
157 | - <div class="sort_menu"> | ||
158 | - | ||
159 | - <div class="sort_price"> | ||
160 | - <span>Сортировка:</span> | ||
161 | - <?= \yii\widgets\LinkSorter::widget([ | ||
162 | - 'sort' => $productProvider->sort, | ||
163 | - 'attributes' => [ | ||
164 | - 'name', | ||
165 | - 'price', | ||
166 | - ] | ||
167 | - ]); | ||
168 | - ?> | ||
169 | - <!-- | ||
170 | - <select name="sort_price" id="" class="sort_price_select"> | ||
171 | - <option value="price">по цене</option> | ||
172 | - <option value="popular">новые</option> | ||
173 | - <option value="sale">по акции</option> | ||
174 | - </select> | ||
175 | - <i class="fa fa-angle-down"></i>--> | ||
176 | - </div> | ||
177 | - | ||
178 | - <div class="show"> | ||
179 | - <!--<span>Показывать по:</span> | ||
180 | - <ul> | ||
181 | - <li><a class="active" href="#">24</a></li> | ||
182 | - <li><a href="#">48</a></li> | ||
183 | - <li><a href="#">96</a></li> | ||
184 | - </ul>--> | ||
185 | - </div> | ||
186 | - | ||
187 | - <?php if ($productProvider->totalCount > $productProvider->pagination->pageSize) :?> | ||
188 | - <div class="show_pages"> | ||
189 | - Страница: | ||
190 | - <?= \yii\widgets\LinkPager::widget([ | ||
191 | - 'pagination' => $productProvider->pagination, | ||
192 | - 'options' => ['class' => 'pagination pull-right'], | ||
193 | - ]); | ||
194 | - ?> | ||
195 | - <!--<i class="fa fa-caret-right"></i>--> | ||
196 | - </div> | ||
197 | <?php endif?> | 84 | <?php endif?> |
198 | - | ||
199 | - </div> | ||
200 | - | ||
201 | - <div class="cat_p_item_card_list"> | ||
202 | - <div class="novelty"> | ||
203 | - <div class="content"> | ||
204 | - <div class="novelty_cont"> | ||
205 | - <?php foreach($productProvider->models as $product) :?> | ||
206 | - <?php require(__DIR__ .'/product_item.php')?> | ||
207 | - <?php endforeach?> | ||
208 | - </div> | ||
209 | - | ||
210 | - <?php if ($productProvider->totalCount > $productProvider->pagination->pageSize) :?> | ||
211 | - <!-- LOAD MORE BUTTON --> | ||
212 | - <!--button class="load_more_btn">Загрузить еще <?= $productProvider->pagination->pageSize?> товара</button--> | ||
213 | - | ||
214 | - <div class="show_pages"> | ||
215 | - Страница: | ||
216 | - <?= \yii\widgets\LinkPager::widget([ | ||
217 | - 'pagination' => $productProvider->pagination, | ||
218 | - 'options' => ['class' => 'pagination pull-right'], | ||
219 | - ]); | 85 | + <?php if ($brandProvider->totalCount > 0) :?> |
86 | + <div class="filters"> | ||
87 | + <div class="begin">Бренды</div> | ||
88 | + <ul> | ||
89 | + <?php foreach($brandProvider->models as $brand) : | ||
90 | + $checked = !empty($filter['brands']) && in_array($brand->alias, $filter['brands']); | ||
91 | + $option_url = Url::to(['catalog/category', 'category' => $category, 'filter' => ProductHelper::getFilterForOption($filter, 'brands', $brand->alias, $checked)]); | ||
220 | ?> | 92 | ?> |
221 | - <!--<i class="fa fa-caret-right"></i>--> | ||
222 | - </div> | ||
223 | - <?php endif ?> | ||
224 | - <hr> | ||
225 | - | ||
226 | - <?php if(!empty($category->description)) :?> | ||
227 | - <div class="description"> | ||
228 | - <?= $category->description?> | 93 | + <li> |
94 | + <input type="checkbox" class="brands-option" <?= $checked ? ' checked' : ''?> onchange="document.location='<?= $option_url?>'" /> | ||
95 | + <a href="<?= $option_url?>"><?= $brand->name?> (<?= $brand->getProducts()->count()?>)</a> | ||
96 | + </li> | ||
97 | + <?php endforeach?> | ||
98 | + </ul> | ||
99 | + </div> | ||
100 | + <?php endif?> | ||
229 | 101 | ||
230 | - <div class="empty_padding_400"></div> | ||
231 | - </div> | ||
232 | - <?php endif?> | 102 | + <?php if (!empty($groups)) :?> |
103 | + <?php foreach($groups as $group) :?> | ||
104 | + <div class="filters"> | ||
105 | + <div class="begin"><?= $group->name?></div> | ||
106 | + <ul> | ||
107 | + <?php foreach($group->_options as $option) : | ||
108 | + $checked = (isset($filter['options'][$group->alias]) && in_array($option->alias, $filter['options'][$group->alias])); | ||
109 | + $option_url = Url::to(['catalog/category', 'category' => $category, 'filter' => ProductHelper::getFilterForOption($filter, 'options', [$option->group->alias => [$option->alias]], $checked)]); | ||
110 | + ?> | ||
111 | + <li> | ||
112 | + <input type="checkbox" class="features-option" onchange="document.location='<?= $option_url?>'" <?php /* name="option[<?= $group->alias?>][]"value="<?= $option->alias?>"*/?><?= $checked ? ' checked' : ''?> /> | ||
113 | + <a href="<?= $option_url?>"><?= $option->ValueRenderHTML?> (<?= $option->_items_count?>)</a> | ||
114 | + </li> | ||
115 | + <?php endforeach?> | ||
116 | + </ul> | ||
233 | </div> | 117 | </div> |
234 | - </div> | ||
235 | - </div> | 118 | + <?php endforeach?> |
119 | + <?php endif?> | ||
120 | + </form> | ||
121 | + </div> | ||
236 | 122 | ||
123 | + <div class="content"> | ||
124 | + <h1><?= $category->name ?></h1> | ||
125 | + <div class="products pn"> | ||
126 | + <ul> | ||
127 | + <?php foreach($productProvider->models as $product) :?> | ||
128 | + <?php require(__DIR__ .'/product_item.php')?> | ||
129 | + <?php endforeach?> | ||
130 | + </ul> | ||
131 | + <div class="both"></div> | ||
132 | + </div> | ||
133 | + <?php if ($productProvider->totalCount > $productProvider->pagination->pageSize) :?> | ||
134 | + <?= \yii\widgets\LinkPager::widget([ | ||
135 | + 'pagination' => $productProvider->pagination, | ||
136 | + 'options' => ['class' => 'pagination pull-right'], | ||
137 | + ]); | ||
138 | + ?> | ||
237 | <?php endif?> | 139 | <?php endif?> |
140 | + <div class="both"></div> | ||
238 | </div> | 141 | </div> |
142 | + <div class="both"></div> | ||
239 | 143 | ||
240 | <?php if(!empty($last_products)) :?> | 144 | <?php if(!empty($last_products)) :?> |
241 | <hr> | 145 | <hr> |
frontend/views/layouts/main.php
1 | <?php | 1 | <?php |
2 | - | ||
3 | - | ||
4 | -use yii\helpers\Html; | ||
5 | -use yii\helpers\Url; | ||
6 | -//TODO подключение товаров | ||
7 | -//use app\models\Menu; | ||
8 | -//use app\models\Catalog; | ||
9 | -//use app\models\Products; | ||
10 | -//use app\models\ViewProduct; | ||
11 | -use frontend\assets\AppAsset; | ||
12 | -use yii\web\View; | ||
13 | -use frontend\components\Text; | ||
14 | -use frontend\components\BgWidget; | ||
15 | -//use frontend\components\CompareWidget; | ||
16 | -use frontend\components\HreflangWidget; | ||
17 | -use common\models\Subscribe; | ||
18 | -use yii\widgets\ActiveForm; | ||
19 | - | ||
20 | -AppAsset::register ($this); | ||
21 | -$this->registerJs (" | 2 | + use yii\helpers\Html; |
3 | + use yii\helpers\Url; | ||
4 | + use frontend\assets\AppAsset; | ||
5 | + use yii\web\View; | ||
6 | + use frontend\components\Text; | ||
7 | + use frontend\components\BgWidget; | ||
8 | +// use frontend\components\CompareWidget; | ||
9 | + use frontend\components\HreflangWidget; | ||
10 | + use common\models\Subscribe; | ||
11 | + use yii\widgets\ActiveForm; | ||
12 | + use common\modules\product\models\Category; | ||
13 | + | ||
14 | + AppAsset::register ($this); | ||
15 | + $this->registerJs (" | ||
22 | $('.phone .more').bind('click',function(){ | 16 | $('.phone .more').bind('click',function(){ |
23 | $('.phone .more_block').toggle(); | 17 | $('.phone .more_block').toggle(); |
24 | }); | 18 | }); |
25 | ", View::POS_READY, 'phone'); | 19 | ", View::POS_READY, 'phone'); |
26 | //$this->registerCssFile(Yii::$app->request->BaseUrl.'/css/style.css'); | 20 | //$this->registerCssFile(Yii::$app->request->BaseUrl.'/css/style.css'); |
27 | -$this->registerJsFile (Yii::$app->request->baseUrl . '/js/basket.js', ['position' => View::POS_HEAD, 'depends' => ['yii\web\JqueryAsset']]); | ||
28 | -$this->registerJs (" | 21 | + $this->registerJsFile (Yii::$app->request->baseUrl . '/js/basket.js', ['position' => View::POS_HEAD, 'depends' => ['yii\web\JqueryAsset']]); |
22 | + $this->registerJs (" | ||
29 | $('#basket').basket(); | 23 | $('#basket').basket(); |
30 | ", View::POS_READY, 'basket'); | 24 | ", View::POS_READY, 'basket'); |
31 | -$this->registerJsFile (Yii::$app->request->baseUrl . '/js/call.js', ['position' => View::POS_HEAD, 'depends' => ['yii\web\JqueryAsset']]); | ||
32 | -$this->registerJs (" | 25 | + $this->registerJsFile (Yii::$app->request->baseUrl . '/js/call.js', ['position' => View::POS_HEAD, 'depends' => ['yii\web\JqueryAsset']]); |
26 | + $this->registerJs (" | ||
33 | $('#call').call({token:'" . Yii::$app->request->getCsrfToken () . "'}); | 27 | $('#call').call({token:'" . Yii::$app->request->getCsrfToken () . "'}); |
34 | ", View::POS_READY, 'call'); | 28 | ", View::POS_READY, 'call'); |
35 | -$this->registerJs (" | 29 | + $this->registerJs (" |
36 | var activeTab = $('.social li:first a').attr('id'); | 30 | var activeTab = $('.social li:first a').attr('id'); |
37 | $('.'+activeTab+'_box').show(); | 31 | $('.'+activeTab+'_box').show(); |
38 | $('.social li').click(function(){ | 32 | $('.social li').click(function(){ |
@@ -46,20 +40,20 @@ $this->registerJs (" | @@ -46,20 +40,20 @@ $this->registerJs (" | ||
46 | 40 | ||
47 | // AssetBundle jcarousel :D | 41 | // AssetBundle jcarousel :D |
48 | 42 | ||
49 | -// jquery-migrate | ||
50 | -$this->registerJsFile('http://code.jquery.com/jquery-migrate-1.3.0.js',[ | ||
51 | - 'position' => View::POS_HEAD, | ||
52 | - 'depends' => ['yii\web\JqueryAsset'] | ||
53 | -]); | 43 | + // jquery-migrate |
44 | + $this->registerJsFile('http://code.jquery.com/jquery-migrate-1.3.0.js',[ | ||
45 | + 'position' => View::POS_HEAD, | ||
46 | + 'depends' => ['yii\web\JqueryAsset'] | ||
47 | + ]); | ||
54 | 48 | ||
55 | -// jcarousel | ||
56 | -$this->registerCssFile(Yii::$app->request->BaseUrl.'/js/jsor-jcarousel-7bb2e0a/skins/tango/skin.css'); | ||
57 | -$this->registerJsFile(Yii::$app->request->baseUrl.'/js/jsor-jcarousel-7bb2e0a/lib/jquery.jcarousel.min.js',[ | ||
58 | - 'position' => View::POS_HEAD, | ||
59 | - 'depends' => ['yii\web\JqueryAsset'] | ||
60 | -]); | 49 | + // jcarousel |
50 | + $this->registerCssFile(Yii::$app->request->BaseUrl.'/js/jsor-jcarousel-7bb2e0a/skins/tango/skin.css'); | ||
51 | + $this->registerJsFile(Yii::$app->request->baseUrl.'/js/jsor-jcarousel-7bb2e0a/lib/jquery.jcarousel.min.js',[ | ||
52 | + 'position' => View::POS_HEAD, | ||
53 | + 'depends' => ['yii\web\JqueryAsset'] | ||
54 | + ]); | ||
61 | 55 | ||
62 | -$this->registerJs(" | 56 | + $this->registerJs(" |
63 | $('.jcarousel').jcarousel({ | 57 | $('.jcarousel').jcarousel({ |
64 | vertical: true, | 58 | vertical: true, |
65 | scroll: 2 | 59 | scroll: 2 |
@@ -81,15 +75,6 @@ $this->registerJs(" | @@ -81,15 +75,6 @@ $this->registerJs(" | ||
81 | <?php $this->head () ?> | 75 | <?php $this->head () ?> |
82 | </head> | 76 | </head> |
83 | <body> | 77 | <body> |
84 | - <!-- Google Tag Manager --> | ||
85 | - <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-5KPBHP" | ||
86 | - height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> | ||
87 | - <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | ||
88 | - new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | ||
89 | - j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | ||
90 | - '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | ||
91 | - })(window,document,'script','dataLayer','GTM-5KPBHP');</script> | ||
92 | - <!-- End Google Tag Manager --> | ||
93 | <?php $this->beginBody () ?> | 78 | <?php $this->beginBody () ?> |
94 | <?= BgWidget::widget () ?> | 79 | <?= BgWidget::widget () ?> |
95 | 80 | ||
@@ -118,13 +103,12 @@ $this->registerJs(" | @@ -118,13 +103,12 @@ $this->registerJs(" | ||
118 | </form> | 103 | </form> |
119 | </div> | 104 | </div> |
120 | <div class="fr"> | 105 | <div class="fr"> |
121 | - <?php if (Yii::$app->user->isGuest): ?> | 106 | + <? if (Yii::$app->user->isGuest): ?> |
122 | <a href="<?= Url::to (['login/index']) ?>" id='login'><span>Личный кабинет</span></a> | 107 | <a href="<?= Url::to (['login/index']) ?>" id='login'><span>Личный кабинет</span></a> |
123 | - <?php else: ?> | ||
124 | - | 108 | + <? else: ?> |
125 | <a href="<?= Url::to (['iam/index']) ?>"><?= Text::getShort (Yii::$app->user->identity->username, 20) ?></a> | 109 | <a href="<?= Url::to (['iam/index']) ?>"><?= Text::getShort (Yii::$app->user->identity->username, 20) ?></a> |
126 | <a href="<?= Url::to (['login/logout']) ?>" class='logout'>Выход</a> | 110 | <a href="<?= Url::to (['login/logout']) ?>" class='logout'>Выход</a> |
127 | - <?php endif; ?> | 111 | + <? endif; ?> |
128 | </div> | 112 | </div> |
129 | <div class="both"></div> | 113 | <div class="both"></div> |
130 | </div> | 114 | </div> |
@@ -149,7 +133,7 @@ $this->registerJs(" | @@ -149,7 +133,7 @@ $this->registerJs(" | ||
149 | <div id="basket" class="info">Корзина <span>0</span></div> | 133 | <div id="basket" class="info">Корзина <span>0</span></div> |
150 | <span class="more"></span> | 134 | <span class="more"></span> |
151 | <div class="both"></div> | 135 | <div class="both"></div> |
152 | - <div class="compare"><?php //TODO сюда подключить сравнение CompareWidget::widget () ?></div> | 136 | + <div class="compare"><?php /*= CompareWidget::widget () */?></div> |
153 | <div class="basket_hovered"> | 137 | <div class="basket_hovered"> |
154 | <div class="basket_hovered_white"></div> | 138 | <div class="basket_hovered_white"></div> |
155 | <div class="basket_items"> | 139 | <div class="basket_items"> |
@@ -170,30 +154,34 @@ $this->registerJs(" | @@ -170,30 +154,34 @@ $this->registerJs(" | ||
170 | 154 | ||
171 | 155 | ||
172 | <div class="menu"> | 156 | <div class="menu"> |
173 | - <?php //TODO генерация меню по каталогу | ||
174 | - // $active_id = 0; | ||
175 | - // if (! empty($this->params['catalog_id'])) | ||
176 | - // { | ||
177 | - // $row = Catalog::findOne ($this->params['catalog_id']); | ||
178 | - // $active_id = ($row->parent_id > 0) ? $row->parent_id : $row->id; | ||
179 | - // } | ||
180 | - // ?> | ||
181 | <ul> | 157 | <ul> |
182 | - <!-- --><?// foreach (Catalog::find ()->where (['parent_id' => 0])->orderBy ('sort')->all () as $key => $item): ?> | ||
183 | - <!-- <li --><?// if ($item->id == $active_id): ?><!--class="active"--><?// endif; ?><!--><a--> | ||
184 | - <!-- href="--><?//= Url::to (['products/index', 'translit' => $item->translit]) ?><!--">--><?//= $item->name ?><!--</a>--> | ||
185 | - <!-- </li>--> | ||
186 | - <!-- --><?// endforeach; ?> | 158 | + <? foreach (Category::find ()->all () as $category): ?> |
159 | + <li><a href="<?= \yii\helpers\Url::to(['catalog/category', 'category' => $category])?>"><?= $category->name ?></a> | ||
160 | + </li> | ||
161 | + <? endforeach; ?> | ||
187 | </ul> | 162 | </ul> |
188 | 163 | ||
189 | <div class="fr"> | 164 | <div class="fr"> |
190 | <ul> | 165 | <ul> |
191 | <li class="akciya"><a href="<?= Url::to (['text/index', 'translit' => 'akcii']) ?>">Акции</a></li> | 166 | <li class="akciya"><a href="<?= Url::to (['text/index', 'translit' => 'akcii']) ?>">Акции</a></li> |
192 | - <li class="brends"><a href="<?= Url::to (['brends/index']) ?>">Бренды</a></li> | 167 | + <li class="brands"><a href="<?= Url::to (['brand/index']) ?>">Бренды</a></li> |
193 | </ul> | 168 | </ul> |
194 | </div> | 169 | </div> |
195 | <div class="both"></div> | 170 | <div class="both"></div> |
196 | </div> | 171 | </div> |
172 | + <? /** | ||
173 | + * <div class="menu_childs"> | ||
174 | + * <ul> | ||
175 | + * <? | ||
176 | + * $items = Catalog::find(); | ||
177 | + * if($row->parent_id>0)$items->where(['parent_id'=>$row->parent_id]); | ||
178 | + * else $items->where(['parent_id'=>$row->id]); | ||
179 | + * foreach($items->orderBy('sort')->all() as $key=>$item):?> | ||
180 | + * <li><a href="<?=Url::to(['products/index','translit'=>$item->translit])?>"><?=$item->name?></a></li> | ||
181 | + * <?endforeach;?> | ||
182 | + * </ul><div class="both"></div> | ||
183 | + * </div> | ||
184 | + **/ ?> | ||
197 | 185 | ||
198 | <?= $content ?> | 186 | <?= $content ?> |
199 | 187 | ||
@@ -280,47 +268,47 @@ $this->registerJs(" | @@ -280,47 +268,47 @@ $this->registerJs(" | ||
280 | 268 | ||
281 | </div> | 269 | </div> |
282 | <?php | 270 | <?php |
283 | - /* | ||
284 | - echo '<p class="txts">'; | ||
285 | - | ||
286 | - $ids = ViewProduct::listView (); | ||
287 | - if (! empty($ids)) | ||
288 | - { | ||
289 | - $products = Products::find ()->where (['id' => ViewProduct::listView ()])->all (); | ||
290 | - echo 'Вы просматривали'; | ||
291 | - } | ||
292 | - else | 271 | + /* |
272 | + echo '<p class="txts">'; | ||
273 | + | ||
274 | + $ids = ViewProduct::listView (); | ||
275 | + if (! empty($ids)) | ||
276 | + { | ||
277 | + $products = Products::find ()->where (['id' => ViewProduct::listView ()])->all (); | ||
278 | + echo 'Вы просматривали'; | ||
279 | + } | ||
280 | + else | ||
281 | + { | ||
282 | + $products = Products::find ()->where (['new' => '1'])->orderBy ('id DESC')->innerJoinWith (['cost'])->groupBy ('id')->limit (4)->all (); | ||
283 | + echo 'Товары со скидкой'; | ||
284 | + } | ||
285 | + echo '</p>'; | ||
286 | + | ||
287 | + echo ' | ||
288 | + <div class="view_carousel"> | ||
289 | + <ul class="view_products jcarousel-skin-tango2">'; | ||
290 | + | ||
291 | + foreach ($products as $item) | ||
293 | { | 292 | { |
294 | - $products = Products::find ()->where (['new' => '1'])->orderBy ('id DESC')->innerJoinWith (['cost'])->groupBy ('id')->limit (4)->all (); | ||
295 | - echo 'Товары со скидкой'; | 293 | + if (! empty ($item->cost)) |
294 | + { | ||
295 | + echo ' | ||
296 | + <li> | ||
297 | + <div class="bg-img-foot-wr"> | ||
298 | + <a class="bg-img-foot" href="'.Url::to (['products/show', 'translit_rubric' => $item->catalog->translit, 'translit' => $item->translit, 'id' => $item->id]) .'"> | ||
299 | + <img src="'.Yii::$app->request->baseUrl . '/upload/products/ico/' . $item->imageAvator.'" border="0"/></a> | ||
300 | + </div> | ||
301 | + <a href="'. Url::to (['products/show', 'translit_rubric' => $item->catalog->translit, 'translit' => $item->translit, 'id' => $item->id]) .'" class="name">'.$item->name.'</a> | ||
302 | + <p class="cost">'.$item->cost->cost.' грн.</p> | ||
303 | + <div class="both"></div> | ||
304 | + </li>'; | ||
305 | + } | ||
296 | } | 306 | } |
297 | - echo '</p>'; | ||
298 | - | ||
299 | - echo ' | ||
300 | - <div class="view_carousel"> | ||
301 | - <ul class="view_products jcarousel-skin-tango2">'; | ||
302 | 307 | ||
303 | - foreach ($products as $item) | ||
304 | - { | ||
305 | - if (! empty ($item->cost)) | ||
306 | - { | ||
307 | - echo ' | ||
308 | - <li> | ||
309 | - <div class="bg-img-foot-wr"> | ||
310 | - <a class="bg-img-foot" href="'.Url::to (['products/show', 'translit_rubric' => $item->catalog->translit, 'translit' => $item->translit, 'id' => $item->id]) .'"> | ||
311 | - <img src="'.Yii::$app->request->baseUrl . '/upload/products/ico/' . $item->imageAvator.'" border="0"/></a> | ||
312 | - </div> | ||
313 | - <a href="'. Url::to (['products/show', 'translit_rubric' => $item->catalog->translit, 'translit' => $item->translit, 'id' => $item->id]) .'" class="name">'.$item->name.'</a> | ||
314 | - <p class="cost">'.$item->cost->cost.' грн.</p> | ||
315 | - <div class="both"></div> | ||
316 | - </li>'; | ||
317 | - } | ||
318 | - } | ||
319 | - | ||
320 | - echo ' | ||
321 | - </ul> | ||
322 | - </div>'; | ||
323 | - */ | 308 | + echo ' |
309 | + </ul> | ||
310 | + </div>'; | ||
311 | + */ | ||
324 | ?> | 312 | ?> |
325 | </div> | 313 | </div> |
326 | 314 | ||
@@ -345,8 +333,8 @@ $this->registerJs(" | @@ -345,8 +333,8 @@ $this->registerJs(" | ||
345 | <div class="content2"> | 333 | <div class="content2"> |
346 | <p class="txts">Подписаться на акции</p> | 334 | <p class="txts">Подписаться на акции</p> |
347 | <?php | 335 | <?php |
348 | - $subscribe = new Subscribe; | ||
349 | - $form = ActiveForm::begin (['action' => '/subscribe']); | 336 | + $subscribe = new Subscribe; |
337 | + $form = ActiveForm::begin (['action' => '/subscribe']); | ||
350 | ?> | 338 | ?> |
351 | <?php echo $form->field ($subscribe, 'email')->textInput (['placeholder' => 'E-mail'])->label (false); ?> | 339 | <?php echo $form->field ($subscribe, 'email')->textInput (['placeholder' => 'E-mail'])->label (false); ?> |
352 | <?= $form->field ($subscribe, 'sale')->dropDownList (['10' => '10%', '20' => '20%'], ['prompt' => 'Скидка'])->label (false); ?> | 340 | <?= $form->field ($subscribe, 'sale')->dropDownList (['10' => '10%', '20' => '20%'], ['prompt' => 'Скидка'])->label (false); ?> |
@@ -364,29 +352,7 @@ $this->registerJs(" | @@ -364,29 +352,7 @@ $this->registerJs(" | ||
364 | </li> | 352 | </li> |
365 | </ul> | 353 | </ul> |
366 | <div class="both"></div> | 354 | <div class="both"></div> |
367 | - <!--bigmir)net TOP 100--> | ||
368 | - <script type="text/javascript" language="javascript"><!-- | ||
369 | - function BM_Draw(oBM_STAT){ | ||
370 | - document.write('<table cellpadding="0" cellspacing="0" border="0" style="display:inline;margin-right:4px;"><tr><td><div style="font-family:Tahoma;font-size:10px;padding:0px;margin:0px;"><div style="width:7px;float:left;background:url(\'//i.bigmir.net/cnt/samples/default/b52_left.gif\');height:17px;padding-top:2px;background-repeat:no-repeat;"></div><div style="float:left;background:url(\'//i.bigmir.net/cnt/samples/default/b52_center.gif\');text-align:left;height:17px;padding-top:2px;background-repeat:repeat-x;"><a href="http://www.bigmir.net/" target="_blank" style="color:#0000ab;text-decoration:none;">bigmir<span style="color:#ff0000;">)</span>net</a> <span style="color:#797979;">хиты</span> <span style="color:#003596;font:10px Tahoma;">'+oBM_STAT.hits+'</span> <span style="color:#797979;">хосты</span> <span style="color:#003596;font:10px Tahoma;">'+oBM_STAT.hosts+'</span></div><div style="width:7px;float: left;background:url(\'//i.bigmir.net/cnt/samples/default/b52_right.gif\');height:17px;padding-top:2px;background-repeat:no-repeat;"></div></div></td></tr></table>'); | ||
371 | - } | ||
372 | - //--> | ||
373 | - </script> | ||
374 | - <script type="text/javascript" language="javascript"><!-- | ||
375 | - bmN=navigator,bmD=document,bmD.cookie='b=b',i=0,bs=[],bm={o:1,v:16945199,s:16945199,t:0,c:bmD.cookie?1:0,n:Math.round((Math.random()* 1000000)),w:0}; | ||
376 | - for(var f=self;f!=f.parent;f=f.parent)bm.w++; | ||
377 | - try{if(bmN.plugins&&bmN.mimeTypes.length&&(x=bmN.plugins['Shockwave Flash']))bm.m=parseInt(x.description.replace(/([a-zA-Z]|\s)+/,'')); | ||
378 | - else for(var f=3;f<20;f++)if(eval('new ActiveXObject("ShockwaveFlash.ShockwaveFlash.'+f+'")'))bm.m=f}catch(e){;} | ||
379 | - try{bm.y=bmN.javaEnabled()?1:0}catch(e){;} | ||
380 | - try{bmS=screen;bm.v^=bm.d=bmS.colorDepth||bmS.pixelDepth;bm.v^=bm.r=bmS.width}catch(e){;} | ||
381 | - r=bmD.referrer.replace(/^w+:\/\//,'');if(r&&r.split('/')[0]!=window.location.host){bm.f=escape(r).slice(0,400);bm.v^=r.length} | ||
382 | - bm.v^=window.location.href.length;for(var x in bm) if(/^[ovstcnwmydrf]$/.test(x)) bs[i++]=x+bm[x]; | ||
383 | - bmD.write('<sc'+'ript type="text/javascript" language="javascript" src="//c.bigmir.net/?'+bs.join('&')+'"></sc'+'ript>'); | ||
384 | - //--> | ||
385 | - </script> | ||
386 | - <noscript> | ||
387 | - <a href="http://www.bigmir.net/" target="_blank"><img src="//c.bigmir.net/?v16945199&s16945199&t2" width="88" height="31" alt="bigmir)net TOP 100" title="bigmir)net TOP 100" border="0" /></a> | ||
388 | - </noscript> | ||
389 | - <!--bigmir)net TOP 100--> | 355 | + |
390 | </div> | 356 | </div> |
391 | 357 | ||
392 | <div class="both"></div> | 358 | <div class="both"></div> |
@@ -407,16 +373,6 @@ $this->registerJs(" | @@ -407,16 +373,6 @@ $this->registerJs(" | ||
407 | </div> | 373 | </div> |
408 | 374 | ||
409 | <?php $this->endBody () ?> | 375 | <?php $this->endBody () ?> |
410 | - <script> | ||
411 | - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
412 | - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
413 | - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
414 | - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | ||
415 | - | ||
416 | - ga('create', 'UA-75674711-1', 'auto'); | ||
417 | - ga('send', 'pageview'); | ||
418 | - | ||
419 | - </script> | ||
420 | </body> | 376 | </body> |
421 | </html> | 377 | </html> |
422 | <?php $this->endPage () ?> | 378 | <?php $this->endPage () ?> |
423 | \ No newline at end of file | 379 | \ No newline at end of file |
23.4 KB
9.21 KB