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 | 55 | |
56 | 56 | RewriteRule ^img/(.*)$ frontend/web/img/$1 [L] |
57 | 57 | |
58 | + RewriteRule ^files/(.*)$ frontend/web/files/$1 [L] | |
59 | + | |
58 | 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 | 65 | RewriteCond %{REQUEST_URI} !index.php |
64 | 66 | ... | ... |
backend/config/bootstrap.php
... | ... | @@ -2,4 +2,4 @@ |
2 | 2 | Yii::setAlias('@uploadDir', dirname(dirname(__DIR__)) . '/storage/sync'); |
3 | 3 | Yii::setAlias('@uploadFileProducts', 'products.csv'); |
4 | 4 | |
5 | -Yii::setAlias('@productsDir', dirname(dirname(__DIR__)) . '/storage/products'); | |
6 | 5 | \ No newline at end of file |
6 | +Yii::setAlias('@productsDir', 'images/products'); | |
7 | 7 | \ No newline at end of file | ... | ... |
backend/views/category/_form.php
... | ... | @@ -68,19 +68,6 @@ use kartik\select2\Select2; |
68 | 68 | |
69 | 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 | 71 | <?php if (!empty($model) && $model->depth == 2) :?> |
85 | 72 | <?= $form->field($model, 'populary')->checkbox() ?> |
86 | 73 | <?php endif?> | ... | ... |
backend/views/layouts/main-sidebar.php
... | ... | @@ -25,14 +25,16 @@ use yii\widgets\Menu; |
25 | 25 | ['label' => 'MAIN NAVIGATION', 'options'=>['class'=>'header']], |
26 | 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 | 29 | 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-barcode"></i> <span>{label}</span></a>', |
30 | 30 | 'url' => ['/product/manage'], |
31 | 31 | 'items' => [ |
32 | 32 | ['label' => 'Товары', 'url' => ['/product/manage']], |
33 | - ['label' => 'Импорт товаров', 'url' => ['/product/manage/import']], | |
34 | 33 | ['label' => 'Категории', 'url' => ['/category']], |
35 | 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 | 111 | $params['word'] = [$params['word']]; |
112 | 112 | } |
113 | 113 | $url .= 'word:'. implode(';', $params['word']); |
114 | + unset($params['word']); | |
114 | 115 | } |
115 | 116 | |
116 | 117 | $filter = []; |
... | ... | @@ -147,6 +148,10 @@ class CatalogUrlManager implements UrlRuleInterface { |
147 | 148 | $url .= 'filter:'. implode(';', $filter); |
148 | 149 | } |
149 | 150 | |
151 | + if (!empty($params) && ($query = http_build_query($params)) !== '') { | |
152 | + $url .= '?' . $query; | |
153 | + } | |
154 | + | |
150 | 155 | return $url; |
151 | 156 | break; |
152 | 157 | |
... | ... | @@ -155,6 +160,11 @@ class CatalogUrlManager implements UrlRuleInterface { |
155 | 160 | $product_alias = is_object($params['product']) ? $params['product']->alias : strtolower($params['product']); |
156 | 161 | } |
157 | 162 | $url = 'product/'. $product_alias; |
163 | + | |
164 | + if (!empty($params) && ($query = http_build_query($params)) !== '') { | |
165 | + $url .= '?' . $query; | |
166 | + } | |
167 | + | |
158 | 168 | return $url; |
159 | 169 | break; |
160 | 170 | } | ... | ... |
common/modules/product/controllers/ManageController.php
... | ... | @@ -4,6 +4,7 @@ namespace common\modules\product\controllers; |
4 | 4 | |
5 | 5 | use common\modules\product\helpers\ProductHelper; |
6 | 6 | use common\modules\product\models\Category; |
7 | +use common\modules\product\models\ProductImage; | |
7 | 8 | use common\modules\product\models\ProductVariant; |
8 | 9 | use common\modules\product\models\RemoteProductsSearch; |
9 | 10 | use Yii; |
... | ... | @@ -12,6 +13,10 @@ use common\modules\product\models\ProductSearch; |
12 | 13 | use yii\web\Controller; |
13 | 14 | use yii\web\NotFoundHttpException; |
14 | 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 | 22 | * ManageController implements the CRUD actions for Product model. |
... | ... | @@ -119,8 +124,25 @@ class ManageController extends Controller |
119 | 124 | { |
120 | 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 | 146 | } else { |
125 | 147 | return $this->render('create', [ |
126 | 148 | 'model' => $model, |
... | ... | @@ -138,8 +160,25 @@ class ManageController extends Controller |
138 | 160 | { |
139 | 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 | 182 | } else { |
144 | 183 | $groups = $model->category->getTaxGroups(); |
145 | 184 | |
... | ... | @@ -163,6 +202,18 @@ class ManageController extends Controller |
163 | 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 | 217 | public function actionImport() { |
167 | 218 | $searchModel = new RemoteProductsSearch(); |
168 | 219 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); |
... | ... | @@ -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 | 269 | * Finds the Product model based on its primary key value. |
178 | 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 | 10 | * This is the model class for table "brand". |
11 | 11 | * |
12 | 12 | * @property integer $brand_id |
13 | + * @property string $remote_id | |
13 | 14 | * @property integer $brand_name_id |
14 | 15 | * @property string $alias |
15 | 16 | * @property string $image |
... | ... | @@ -24,6 +25,8 @@ use Yii; |
24 | 25 | */ |
25 | 26 | class Brand extends \yii\db\ActiveRecord |
26 | 27 | { |
28 | + public $imageUpload; | |
29 | + | |
27 | 30 | public function behaviors() |
28 | 31 | { |
29 | 32 | return [ |
... | ... | @@ -39,7 +42,7 @@ class Brand extends \yii\db\ActiveRecord |
39 | 42 | 'valueKeyName' => 'value', |
40 | 43 | 'slugKeyName' => 'alias', |
41 | 44 | 'translit' => true |
42 | - ] | |
45 | + ], | |
43 | 46 | ], |
44 | 47 | ]; |
45 | 48 | } |
... | ... | @@ -64,6 +67,9 @@ class Brand extends \yii\db\ActiveRecord |
64 | 67 | [['alias', 'name'], 'string', 'max' => 250], |
65 | 68 | [['image', 'meta_title'], 'string', 'max' => 255], |
66 | 69 | [['meta_robots'], 'string', 'max' => 50], |
70 | + [['remote_id'], 'string', 'max' => 25], | |
71 | + [['imageUpload'], 'safe'], | |
72 | + [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], | |
67 | 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 | 85 | 'brand_name_id' => Yii::t('product', 'Brand Name ID'), |
80 | 86 | 'alias' => Yii::t('product', 'Alias'), |
81 | 87 | 'image' => Yii::t('product', 'Image'), |
88 | + 'imageUrl' => Yii::t('product', 'Image'), | |
82 | 89 | 'meta_title' => Yii::t('product', 'Meta Title'), |
83 | 90 | 'meta_desc' => Yii::t('product', 'Meta Desc'), |
84 | 91 | 'meta_robots' => Yii::t('product', 'Meta Robots'), |
85 | 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 | 121 | public function getName() { |
114 | 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 | 12 | */ |
13 | 13 | class BrandSearch extends Brand |
14 | 14 | { |
15 | + public $brand_name; | |
15 | 16 | /** |
16 | 17 | * @inheritdoc |
17 | 18 | */ |
... | ... | @@ -19,7 +20,7 @@ class BrandSearch extends Brand |
19 | 20 | { |
20 | 21 | return [ |
21 | 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 | 58 | return $dataProvider; |
58 | 59 | }*/ |
59 | 60 | |
61 | + $dataProvider->setSort([ | |
62 | + 'attributes' => [ | |
63 | + 'brand_name', | |
64 | + 'alias' | |
65 | + ] | |
66 | + ]); | |
67 | + | |
60 | 68 | // grid filtering conditions |
61 | 69 | $query->andFilterWhere([ |
62 | 70 | 'brand_id' => $this->brand_id, |
63 | 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 | 84 | return $dataProvider; |
74 | 85 | } | ... | ... |
common/modules/product/models/Category.php
... | ... | @@ -34,6 +34,8 @@ use Yii; |
34 | 34 | */ |
35 | 35 | class Category extends \yii\db\ActiveRecord |
36 | 36 | { |
37 | + public $imageUpload; | |
38 | + | |
37 | 39 | public function behaviors() |
38 | 40 | { |
39 | 41 | return [ |
... | ... | @@ -89,7 +91,8 @@ class Category extends \yii\db\ActiveRecord |
89 | 91 | [['populary'], 'boolean'], |
90 | 92 | [['group_to_category', 'remote_category'], 'safe'], |
91 | 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 | 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 | 108 | 'path' => Yii::t('product', 'Path'), |
106 | 109 | 'depth' => Yii::t('product', 'Depth'), |
107 | 110 | 'image' => Yii::t('product', 'Image'), |
111 | + 'imageUrl' => Yii::t('product', 'Image'), | |
108 | 112 | 'meta_title' => Yii::t('product', 'Meta Title'), |
109 | 113 | 'meta_desc' => Yii::t('product', 'Meta Desc'), |
110 | 114 | 'meta_robots' => Yii::t('product', 'Meta Robots'), |
... | ... | @@ -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 | 126 | return new CategoryQuery(get_called_class()); |
122 | 127 | } |
123 | 128 | |
... | ... | @@ -145,28 +150,38 @@ class Category extends \yii\db\ActiveRecord |
145 | 150 | return $this->hasMany(ProductCategory::className(), ['category_id' => 'category_id']); |
146 | 151 | } |
147 | 152 | |
148 | - public function getTaxGroups() { | |
153 | + public function getTaxGroups() | |
154 | + { | |
149 | 155 | return $this->getRelations('tax_group_to_category'); |
150 | 156 | } |
151 | 157 | |
152 | - public function getRemote_category() { | |
158 | + public function getRemote_category() | |
159 | + { | |
153 | 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 | 165 | if (!empty($value) && is_array($value)) { |
158 | 166 | $this->remote_id = ArtboxTreeHelper::setArrayField($value, false); |
159 | 167 | } |
160 | 168 | } |
161 | 169 | |
162 | - public function getCategoryName() { | |
170 | + public function getCategoryName() | |
171 | + { | |
163 | 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 | 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 | 185 | public function beforeSave($insert) |
171 | 186 | { |
172 | 187 | if (parent::beforeSave($insert)) { | ... | ... |
common/modules/product/models/Product.php
... | ... | @@ -7,23 +7,23 @@ use common\modules\rubrication\models\TaxOption; |
7 | 7 | use Yii; |
8 | 8 | use common\modules\relation\relationBehavior; |
9 | 9 | use yii\db\ActiveQuery; |
10 | +use yii\helpers\Html; | |
11 | +use yii\web\UploadedFile; | |
10 | 12 | |
11 | 13 | /** |
12 | 14 | * This is the model class for table "{{%product}}". |
13 | 15 | * |
14 | - * @property integer $product_id | |
15 | 16 | * @property string $name |
16 | - * @property string $alias | |
17 | - * @property string $video | |
18 | - * @property string $description | |
19 | 17 | * @property integer $brand_id |
20 | - * @property Brand $brand | |
18 | + * @property integer $product_id | |
21 | 19 | * @property Category $category |
22 | 20 | * @property array $categories |
21 | + * @property array of ProductVariant $variants | |
23 | 22 | * @property ProductVariant $variant |
24 | - * @property array $variants | |
25 | 23 | * @property ProductImage $image |
26 | 24 | * @property array $images |
25 | + * @property boolean $is_top | |
26 | + * @property boolean $is_new | |
27 | 27 | */ |
28 | 28 | class Product extends \yii\db\ActiveRecord |
29 | 29 | { |
... | ... | @@ -71,9 +71,10 @@ class Product extends \yii\db\ActiveRecord |
71 | 71 | [['brand_id'], 'integer'], |
72 | 72 | [['name'], 'string', 'max' => 150], |
73 | 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 | 76 | [['description', 'video'], 'safe'], |
77 | + [['is_top', 'is_new'], 'boolean'], | |
77 | 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 | 92 | 'category' => Yii::t('product', 'Category'), // relation behavior field |
92 | 93 | 'image' => Yii::t('product', 'Image'), |
93 | 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 | 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 | 128 | * @return \yii\db\ActiveQuery |
127 | 129 | */ |
... | ... | @@ -151,7 +153,8 @@ class Product extends \yii\db\ActiveRecord |
151 | 153 | } |
152 | 154 | |
153 | 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 | 160 | public function getCategoriesNames() { |
... | ... | @@ -163,12 +166,7 @@ class Product extends \yii\db\ActiveRecord |
163 | 166 | } |
164 | 167 | |
165 | 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 | 172 | public function getOptions() { |
... | ... | @@ -188,8 +186,18 @@ class Product extends \yii\db\ActiveRecord |
188 | 186 | { |
189 | 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 | 203 | $todel = []; |
... | ... | @@ -214,4 +222,53 @@ class Product extends \yii\db\ActiveRecord |
214 | 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 | 9 | * This is the model class for table "product_image". |
10 | 10 | * |
11 | 11 | * @property integer $product_image_id |
12 | + * @property integer $product_id | |
12 | 13 | * @property integer $product_variant_id |
13 | 14 | * @property string $image |
14 | 15 | * @property string $alt |
15 | 16 | * @property string $title |
16 | - * | |
17 | 17 | * @property Product $product |
18 | + * @property ProductVariant $productVariant | |
18 | 19 | */ |
19 | 20 | class ProductImage extends \yii\db\ActiveRecord |
20 | 21 | { |
21 | - public $image; | |
22 | + public $imageUpload; | |
22 | 23 | /** |
23 | 24 | * @inheritdoc |
24 | 25 | */ |
... | ... | @@ -33,12 +34,13 @@ class ProductImage extends \yii\db\ActiveRecord |
33 | 34 | public function rules() |
34 | 35 | { |
35 | 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 | 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 | 51 | { |
50 | 52 | return [ |
51 | 53 | 'product_image_id' => Yii::t('product', 'Product Image ID'), |
54 | + 'product_id' => Yii::t('product', 'Product ID'), | |
52 | 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 | 59 | 'image' => Yii::t('product', 'Image'), |
54 | 60 | 'alt' => Yii::t('product', 'Alt'), |
55 | 61 | 'title' => Yii::t('product', 'Title'), |
... | ... | @@ -59,9 +65,21 @@ class ProductImage extends \yii\db\ActiveRecord |
59 | 65 | /** |
60 | 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 | 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 | 97 | */ |
80 | 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 | 107 | public function getImageUrl() |
90 | 108 | { |
91 | 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 | 119 | // get the uploaded file instance. for multiple file uploads |
103 | 120 | // the following data will return an array (you may need to use |
104 | 121 | // getInstances method) |
105 | - $image = UploadedFile::getInstance($this, 'image'); | |
122 | + $image = UploadedFile::getInstance($this, 'imageUpload'); | |
106 | 123 | |
107 | 124 | // if no image was uploaded abort the upload |
108 | 125 | if (empty($image)) { |
... | ... | @@ -111,8 +128,7 @@ class ProductImage extends \yii\db\ActiveRecord |
111 | 128 | |
112 | 129 | // store the source file name |
113 | 130 | $this->filename = $image->name; |
114 | - $exploded = explode(".", $image->name); | |
115 | - $ext = end($exploded); | |
131 | + $ext = end((explode(".", $image->name))); | |
116 | 132 | |
117 | 133 | // generate a unique file name |
118 | 134 | $this->image = Yii::$app->security->generateRandomString().".{$ext}"; | ... | ... |
common/modules/product/models/ProductSearch.php
... | ... | @@ -13,14 +13,18 @@ use yii\web\NotFoundHttpException; |
13 | 13 | */ |
14 | 14 | class ProductSearch extends Product |
15 | 15 | { |
16 | + public $brand_name; | |
17 | + public $category_name; | |
18 | + | |
16 | 19 | /** |
17 | 20 | * @inheritdoc |
18 | 21 | */ |
19 | 22 | public function rules() |
20 | 23 | { |
21 | 24 | return [ |
22 | - [['name'], 'safe'], | |
25 | + [['name', 'brand_name', 'category_name'], 'safe'], | |
23 | 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 | 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 | 75 | // grid filtering conditions |
62 | 76 | $query->andFilterWhere([ |
63 | 77 | 'tax_brand_id' => $this->tax_brand_id, |
64 | 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 | 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 | 5 | use Yii; |
6 | 6 | use yii\base\Model; |
7 | 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 | 16 | * @inheritdoc |
... | ... | @@ -18,8 +18,9 @@ class RemoteCategoriesSearch extends RemoteCategories |
18 | 18 | public function rules() |
19 | 19 | { |
20 | 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 | 42 | */ |
42 | 43 | public function search($params) |
43 | 44 | { |
44 | - $query = RemoteCategories::find(); | |
45 | + $query = ProductUnit::find(); | |
45 | 46 | |
46 | 47 | // add conditions that should always apply here |
47 | 48 | |
... | ... | @@ -59,12 +60,12 @@ class RemoteCategoriesSearch extends RemoteCategories |
59 | 60 | |
60 | 61 | // grid filtering conditions |
61 | 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 | 70 | return $dataProvider; |
70 | 71 | } | ... | ... |
common/modules/product/models/ProductVariant.php
... | ... | @@ -16,12 +16,16 @@ use Yii; |
16 | 16 | * @property double $price_old |
17 | 17 | * @property double $stock |
18 | 18 | * @property integer $product_unit_id |
19 | - * @property ProductUnit $productUnit | |
20 | 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 | 25 | class ProductVariant extends \yii\db\ActiveRecord |
24 | 26 | { |
27 | + /** @var array $_images */ | |
28 | + public $imagesUpload = []; | |
25 | 29 | /** |
26 | 30 | * @inheritdoc |
27 | 31 | */ |
... | ... | @@ -41,8 +45,9 @@ class ProductVariant extends \yii\db\ActiveRecord |
41 | 45 | [['price', 'price_old', 'stock'], 'number'], |
42 | 46 | [['name', 'sku'], 'string', 'max' => 255], |
43 | 47 | [['remote_id'], 'string', 'max' => 20], |
48 | + [['imagesUpload'], 'safe'], | |
49 | + [['imagesUpload'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif', 'maxFiles' => 50], | |
44 | 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 | 64 | 'price' => Yii::t('product', 'Price'), |
60 | 65 | 'price_old' => Yii::t('product', 'Price Old'), |
61 | 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 | 83 | /** |
76 | 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 | 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 | 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 | 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 | 17 | |
18 | 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 | 24 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> |
23 | 25 | |
24 | 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 | 29 | <?= $form->field($model, 'brand_id')->dropDownList( |
28 | 30 | ArrayHelper::map(ProductHelper::getBrands()->all(), 'brand_id', 'name'), |
... | ... | @@ -35,7 +37,7 @@ use kartik\select2\Select2; |
35 | 37 | 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'), |
36 | 38 | 'language' => 'ru', |
37 | 39 | 'options' => [ |
38 | - 'placeholder' => 'Select a state ...', | |
40 | + 'placeholder' => Yii::t('product', 'Select categories'), | |
39 | 41 | 'multiple' => true, |
40 | 42 | ], |
41 | 43 | 'pluginOptions' => [ |
... | ... | @@ -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 | 51 | 'options' => [ |
51 | 52 | 'accept' => 'image/*', |
52 | 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 | 68 | <?= $form->field($model, 'variants')->widget(MultipleInput::className(), [ |
57 | 69 | 'columns' => [ |
... | ... | @@ -62,33 +74,33 @@ use kartik\select2\Select2; |
62 | 74 | [ |
63 | 75 | 'name' => 'name', |
64 | 76 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, |
65 | - 'title' => 'Name', | |
77 | + 'title' => Yii::t('product', 'Name'), | |
66 | 78 | ], |
67 | 79 | [ |
68 | 80 | 'name' => 'sku', |
69 | 81 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, |
70 | - 'title' => 'SKU', | |
82 | + 'title' => Yii::t('product', 'SKU'), | |
71 | 83 | ], |
72 | 84 | [ |
73 | 85 | 'name' => 'price', |
74 | 86 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, |
75 | - 'title' => 'Price', | |
87 | + 'title' => Yii::t('product', 'Price'), | |
76 | 88 | ], |
77 | 89 | [ |
78 | 90 | 'name' => 'price_old', |
79 | 91 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, |
80 | - 'title' => 'Old Price', | |
92 | + 'title' => Yii::t('product', 'Old Price'), | |
81 | 93 | ], |
82 | 94 | [ |
83 | 95 | 'name' => 'product_unit_id', |
84 | 96 | 'type' => MultipleInputColumn::TYPE_DROPDOWN, |
85 | - 'title' => 'Unit', | |
97 | + 'title' => Yii::t('product', 'Unit'), | |
86 | 98 | 'items' => ArrayHelper::map(\common\modules\product\models\ProductUnit::find()->all(), 'product_unit_id', 'name'), |
87 | 99 | ], |
88 | 100 | [ |
89 | 101 | 'name' => 'stock', |
90 | 102 | 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, |
91 | - 'title' => 'Stock', | |
103 | + 'title' => Yii::t('product', 'Stock'), | |
92 | 104 | 'options' => [ |
93 | 105 | 'placeholder' => '∞' |
94 | 106 | ], | ... | ... |
common/modules/product/views/manage/index.php
... | ... | @@ -22,12 +22,57 @@ $this->params['breadcrumbs'][] = $this->title; |
22 | 22 | 'filterModel' => $searchModel, |
23 | 23 | 'columns' => [ |
24 | 24 | ['class' => 'yii\grid\SerialColumn'], |
25 | - 'product_id', | |
25 | +// 'product_id', | |
26 | 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 | 78 | </div> | ... | ... |
common/modules/product/views/manage/view.php
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 | 3 | <div class="prods_carousel"> |
4 | 4 | <ul> |
5 | 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 | 7 | <?php endforeach?> |
8 | 8 | </ul> |
9 | 9 | </div> | ... | ... |
common/modules/product/widgets/views/submenu.php
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 | <?php if (empty($_item->image)) :?> |
13 | 13 | <img valign="top" src="/images/no_photo.png"> |
14 | 14 | <?php else :?> |
15 | - <img valign="top" src="<?= $_item->image?>"> | |
15 | + <?= $_item->imageUrl ? Yii::$app->imageCache->thumb($_item->imageUrl, 'mainmenu') : ''?> | |
16 | 16 | <?php endif?> |
17 | 17 | </div> |
18 | 18 | <div class="title"><?= $_item->categoryName->value?></div> |
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | <?php if (empty($_item['item']->image)) :?> |
35 | 35 | <img valign="top" src="/images/no_photo.png"> |
36 | 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 | 38 | <?php endif?> |
39 | 39 | </div> |
40 | 40 | <div class="title"><?= $_item['item']->categoryName->value?></div> | ... | ... |
common/modules/rubrication/behaviors/ArtboxSynonymBehavior.php
... | ... | @@ -114,7 +114,7 @@ class ArtboxSynonymBehavior extends Behavior { |
114 | 114 | $valueModel->setAttribute($field, $this->$key); |
115 | 115 | } |
116 | 116 | if ($isave) { |
117 | - $valueModel->setAttribute($this->valueOptionId, $this->owner->{$this->keyNameId}); | |
117 | + $valueModel->setAttribute($this->valueOptionId, $this->owner->getAttribute($this->keyNameId)); | |
118 | 118 | $valueModel->save(); |
119 | 119 | if (!empty($this->slug) && empty($this->owner->{$this->slug['slugKeyName']})) { |
120 | 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 | 15 | * @property string $module |
16 | 16 | * @property boolean $hierarchical |
17 | 17 | * @property string $settings |
18 | - * @property boolean $is_filter | |
18 | + * @property boolean is_filter | |
19 | 19 | * |
20 | 20 | * @property TaxGroupToGroup[] $taxGroupToGroups |
21 | 21 | * @property TaxGroupToGroup[] $taxGroupToGroups0 |
... | ... | @@ -62,7 +62,7 @@ class TaxGroup extends \yii\db\ActiveRecord |
62 | 62 | return [ |
63 | 63 | [['name', 'module'], 'required'], |
64 | 64 | [['description', 'settings'], 'string'], |
65 | - [['hierarchical', 'is_filter'], 'boolean'], | |
65 | + [['hierarchical'], 'boolean'], | |
66 | 66 | [['alias', 'module'], 'string', 'max' => 50], |
67 | 67 | [['name'], 'string', 'max' => 255], |
68 | 68 | [['group_to_category'], 'safe'] | ... | ... |
common/modules/rubrication/models/TaxValueString.php
... | ... | @@ -53,6 +53,6 @@ class TaxValueString extends \yii\db\ActiveRecord |
53 | 53 | */ |
54 | 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 | 15 | |
16 | 16 | <?php $form = ActiveForm::begin(); ?> |
17 | 17 | |
18 | - <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?> | |
19 | - | |
20 | 18 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> |
21 | 19 | |
20 | + <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?> | |
21 | + | |
22 | 22 | <?= $form->field($model, 'description')->textarea(['rows' => 6]) ?> |
23 | 23 | |
24 | 24 | <?= $form->field($model, 'module')->dropDownList(RubricationHelper::OptionTypes(), [ | ... | ... |
common/translation/ru/product.php
console/config/bootstrap.php
... | ... | @@ -2,4 +2,4 @@ |
2 | 2 | Yii::setAlias('@uploadDir', dirname(dirname(__DIR__)) . '/storage/sync'); |
3 | 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 | 4 | |
5 | 5 | use common\modules\product\models\Category; |
6 | 6 | use common\modules\product\models\CategoryName; |
7 | +use common\modules\product\models\ProductImage; | |
7 | 8 | use common\modules\product\models\ProductVariantType; |
8 | 9 | use common\modules\rubrication\models\TaxOption; |
9 | 10 | use common\modules\rubrication\models\TaxValueString; |
... | ... | @@ -100,7 +101,7 @@ class ImportController extends Controller { |
100 | 101 | $product_cost_old = $data[9]; |
101 | 102 | |
102 | 103 | // 11 Цена |
103 | - $produc_cost = $data[10]; | |
104 | + $product_cost = $data[10]; | |
104 | 105 | |
105 | 106 | // 12 Акция |
106 | 107 | $product_akciya = (bool)$data[11]; |
... | ... | @@ -133,6 +134,8 @@ class ImportController extends Controller { |
133 | 134 | $_product = new Product(); |
134 | 135 | } |
135 | 136 | |
137 | + $is_new_product = empty($_product->product_id); | |
138 | + | |
136 | 139 | // ==== Set category ==== |
137 | 140 | if ( ($category = CategoryName::find()->filterWhere(['ilike', 'value', trim($catalog_name)])->one()) !== null ) { |
138 | 141 | $_product->categories = [$category->category_id]; |
... | ... | @@ -160,9 +163,9 @@ class ImportController extends Controller { |
160 | 163 | $_product->name = $product_name; |
161 | 164 | $_product->video = $product_video; |
162 | 165 | $_product->description = $product_body_ru; |
163 | - $_product->top = $product_top; | |
166 | + $_product->is_top = $product_top; | |
164 | 167 | $_product->akciya = $product_akciya; |
165 | - $_product->new = $product_new; | |
168 | + $_product->is_new = $product_new; | |
166 | 169 | |
167 | 170 | |
168 | 171 | $_product->save(); |
... | ... | @@ -195,52 +198,61 @@ class ImportController extends Controller { |
195 | 198 | $mod_size = $mod_arr[1]; |
196 | 199 | $mod_color = $mod_arr[2]; |
197 | 200 | $mod_image = $mod_arr[3]; |
198 | - $mod_cost = $produc_cost; | |
201 | + $mod_cost = $product_cost; | |
199 | 202 | $mod_old_cost = $product_cost_old; |
200 | 203 | |
201 | 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 | 206 | $_productVariant = new ProductVariant(); |
204 | 207 | $_productVariant->product_id = $_product->product_id; |
205 | 208 | } |
209 | + $_productVariant->product_unit_id = 1; | |
206 | 210 | |
207 | 211 | $_productVariant->sku = $mod_art; |
208 | 212 | $_productVariant->price = $mod_cost; |
209 | 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 | 216 | $product_variant_type_name = ''; |
227 | - if (! empty ($mod_color)) | |
217 | + if (! empty ($mod_color)) { | |
228 | 218 | $product_variant_type_name = 'Цвет'; |
229 | - elseif (! empty ($mod_size)) | |
219 | + $_productVariant->name = $mod_color; | |
220 | + } | |
221 | + elseif (! empty ($mod_size)) { | |
230 | 222 | $product_variant_type_name = 'Размер'; |
223 | + $_productVariant->name = $mod_size; | |
224 | + } | |
231 | 225 | |
232 | 226 | // ===== Set variant type ==== |
233 | 227 | if ( $product_variant_type_name ) { |
234 | 228 | if ( ($product_variant_type = ProductVariantType::find()->filterWhere(['ilike', 'name', $product_variant_type_name])->one()) !== null ) { |
235 | 229 | $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id; |
236 | 230 | } else { |
237 | - // Create brand | |
238 | 231 | $product_variant_type = new ProductVariantType(); |
239 | 232 | $product_variant_type->name = $product_variant_type_name; |
240 | 233 | $product_variant_type->save(); |
241 | 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 | 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 | 297 | $options = []; |
633 | 298 | |
634 | 299 | if (! empty ($filters)) { | ... | ... |
frontend/config/main.php
... | ... | @@ -38,7 +38,22 @@ return [ |
38 | 38 | 'errorHandler' => [ |
39 | 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 | 57 | 'urlManager' => [ |
43 | 58 | 'enablePrettyUrl' => true, |
44 | 59 | 'showScriptName' => false, |
... | ... | @@ -48,12 +63,20 @@ return [ |
48 | 63 | 'iam' => 'iam/index', |
49 | 64 | 'text/<translit:\w+>' => 'text/index', |
50 | 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 | 80 | 'news/<translit:\w+>-<id:\d+>' => 'news/show', |
58 | 81 | 'brends/<translit:[\w\-]+>' => 'brends/show', |
59 | 82 | 'brends' => 'brends/index', | ... | ... |
frontend/controllers/CatalogController.php
... | ... | @@ -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 | 81 | } else { |
90 | 82 | $params = []; |
91 | 83 | |
... | ... | @@ -161,6 +153,7 @@ class CatalogController extends \yii\web\Controller |
161 | 153 | |
162 | 154 | public function actionProduct() |
163 | 155 | { |
156 | + /** @var Product $product */ | |
164 | 157 | $product = Yii::$app->request->get('product'); |
165 | 158 | |
166 | 159 | $groups = []; |
... | ... | @@ -174,12 +167,14 @@ class CatalogController extends \yii\web\Controller |
174 | 167 | if (empty($group->_options)) |
175 | 168 | unset($groups[$i]); |
176 | 169 | } |
170 | + $category = $product->category; | |
177 | 171 | |
178 | 172 | $last_products = ProductHelper::getLastProducts(true); |
179 | 173 | ProductHelper::addLastProsucts($product->product_id); |
180 | 174 | |
181 | 175 | return $this->render('product', [ |
182 | 176 | 'product' => $product, |
177 | + 'category' => $category, | |
183 | 178 | 'properties' => $groups, |
184 | 179 | 'last_products' => $last_products |
185 | 180 | ]); | ... | ... |
frontend/controllers/SiteController.php
... | ... | @@ -11,7 +11,15 @@ use common\models\Products; |
11 | 11 | |
12 | 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 | 24 | public function actionIndex() |
17 | 25 | { |
... | ... | @@ -43,4 +51,6 @@ class SiteController extends Controller |
43 | 51 | ]); |
44 | 52 | } |
45 | 53 | |
54 | + | |
55 | + | |
46 | 56 | } |
47 | 57 | \ No newline at end of file | ... | ... |
frontend/models/ProductFrontendSearch.php
... | ... | @@ -51,7 +51,7 @@ class ProductFrontendSearch extends Product { |
51 | 51 | } else { |
52 | 52 | $query = Product::find(); |
53 | 53 | } |
54 | - $query->joinWith('variant'); | |
54 | +// $query->joinWith('variant'); | |
55 | 55 | $query->joinWith('brand'); |
56 | 56 | $query->joinWith('image'); |
57 | 57 | $query->joinWith('categories'); |
... | ... | @@ -59,7 +59,7 @@ class ProductFrontendSearch extends Product { |
59 | 59 | $dataProvider = new ActiveDataProvider([ |
60 | 60 | 'query' => $query, |
61 | 61 | 'pagination' => [ |
62 | - 'pageSize' => 24, | |
62 | + 'pageSize' => 15, | |
63 | 63 | ], |
64 | 64 | 'sort' => [ |
65 | 65 | 'attributes' => [ | ... | ... |
frontend/views/catalog/product.php
1 | 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 | 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 | 11 | foreach($product->category->getParents()->all() as $parent) { |
6 | 12 | $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; |
7 | 13 | } |
8 | 14 | $this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]]; |
9 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 181 | \ No newline at end of file | ... | ... |
frontend/views/catalog/product_item.php
1 | 1 | <?php |
2 | 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 | 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 | 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 | 64 | \ No newline at end of file | ... | ... |
frontend/views/catalog/products.php
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 | |
6 | 6 | |
7 | 7 | use yii\helpers\Url; |
8 | +use yii\widgets\Breadcrumbs; | |
8 | 9 | use common\modules\product\helpers\ProductHelper; |
9 | 10 | |
10 | 11 | $this->title = $category->categoryName->value; |
... | ... | @@ -46,52 +47,32 @@ $filterWhitoutPrice['prices'] = [ |
46 | 47 | }); |
47 | 48 | }); |
48 | 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 | 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 | 69 | <div class="filter_accept_bloc"> |
89 | 70 | <!-- <button type="submit" class="filter_accept_btn">применить</button>--> |
90 | 71 | <a href="<?= Url::to(['catalog/category', 'category' => $category])?>" class="_form_checkbox_reset">сбросить фильтры</a> |
91 | 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 | 76 | <li>Цена: |
96 | 77 | <div class="arrow"><img src="/images/head_up.png" alt=""></i></div> |
97 | 78 | <div class="price_filter first_price_li"> |
... | ... | @@ -100,142 +81,65 @@ $filterWhitoutPrice['prices'] = [ |
100 | 81 | </div> |
101 | 82 | </div> |
102 | 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 | 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 | 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 | 139 | <?php endif?> |
140 | + <div class="both"></div> | |
238 | 141 | </div> |
142 | + <div class="both"></div> | |
239 | 143 | |
240 | 144 | <?php if(!empty($last_products)) :?> |
241 | 145 | <hr> | ... | ... |
frontend/views/layouts/main.php
1 | 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 | 16 | $('.phone .more').bind('click',function(){ |
23 | 17 | $('.phone .more_block').toggle(); |
24 | 18 | }); |
25 | 19 | ", View::POS_READY, 'phone'); |
26 | 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 | 23 | $('#basket').basket(); |
30 | 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 | 27 | $('#call').call({token:'" . Yii::$app->request->getCsrfToken () . "'}); |
34 | 28 | ", View::POS_READY, 'call'); |
35 | -$this->registerJs (" | |
29 | + $this->registerJs (" | |
36 | 30 | var activeTab = $('.social li:first a').attr('id'); |
37 | 31 | $('.'+activeTab+'_box').show(); |
38 | 32 | $('.social li').click(function(){ |
... | ... | @@ -46,20 +40,20 @@ $this->registerJs (" |
46 | 40 | |
47 | 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 | 57 | $('.jcarousel').jcarousel({ |
64 | 58 | vertical: true, |
65 | 59 | scroll: 2 |
... | ... | @@ -81,15 +75,6 @@ $this->registerJs(" |
81 | 75 | <?php $this->head () ?> |
82 | 76 | </head> |
83 | 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 | 78 | <?php $this->beginBody () ?> |
94 | 79 | <?= BgWidget::widget () ?> |
95 | 80 | |
... | ... | @@ -118,13 +103,12 @@ $this->registerJs(" |
118 | 103 | </form> |
119 | 104 | </div> |
120 | 105 | <div class="fr"> |
121 | - <?php if (Yii::$app->user->isGuest): ?> | |
106 | + <? if (Yii::$app->user->isGuest): ?> | |
122 | 107 | <a href="<?= Url::to (['login/index']) ?>" id='login'><span>Личный кабинет</span></a> |
123 | - <?php else: ?> | |
124 | - | |
108 | + <? else: ?> | |
125 | 109 | <a href="<?= Url::to (['iam/index']) ?>"><?= Text::getShort (Yii::$app->user->identity->username, 20) ?></a> |
126 | 110 | <a href="<?= Url::to (['login/logout']) ?>" class='logout'>Выход</a> |
127 | - <?php endif; ?> | |
111 | + <? endif; ?> | |
128 | 112 | </div> |
129 | 113 | <div class="both"></div> |
130 | 114 | </div> |
... | ... | @@ -149,7 +133,7 @@ $this->registerJs(" |
149 | 133 | <div id="basket" class="info">Корзина <span>0</span></div> |
150 | 134 | <span class="more"></span> |
151 | 135 | <div class="both"></div> |
152 | - <div class="compare"><?php //TODO сюда подключить сравнение CompareWidget::widget () ?></div> | |
136 | + <div class="compare"><?php /*= CompareWidget::widget () */?></div> | |
153 | 137 | <div class="basket_hovered"> |
154 | 138 | <div class="basket_hovered_white"></div> |
155 | 139 | <div class="basket_items"> |
... | ... | @@ -170,30 +154,34 @@ $this->registerJs(" |
170 | 154 | |
171 | 155 | |
172 | 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 | 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 | 162 | </ul> |
188 | 163 | |
189 | 164 | <div class="fr"> |
190 | 165 | <ul> |
191 | 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 | 168 | </ul> |
194 | 169 | </div> |
195 | 170 | <div class="both"></div> |
196 | 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 | 186 | <?= $content ?> |
199 | 187 | |
... | ... | @@ -280,47 +268,47 @@ $this->registerJs(" |
280 | 268 | |
281 | 269 | </div> |
282 | 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 | 313 | </div> |
326 | 314 | |
... | ... | @@ -345,8 +333,8 @@ $this->registerJs(" |
345 | 333 | <div class="content2"> |
346 | 334 | <p class="txts">Подписаться на акции</p> |
347 | 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 | 339 | <?php echo $form->field ($subscribe, 'email')->textInput (['placeholder' => 'E-mail'])->label (false); ?> |
352 | 340 | <?= $form->field ($subscribe, 'sale')->dropDownList (['10' => '10%', '20' => '20%'], ['prompt' => 'Скидка'])->label (false); ?> |
... | ... | @@ -364,29 +352,7 @@ $this->registerJs(" |
364 | 352 | </li> |
365 | 353 | </ul> |
366 | 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 | 356 | </div> |
391 | 357 | |
392 | 358 | <div class="both"></div> |
... | ... | @@ -407,16 +373,6 @@ $this->registerJs(" |
407 | 373 | </div> |
408 | 374 | |
409 | 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 | 376 | </body> |
421 | 377 | </html> |
422 | 378 | <?php $this->endPage () ?> |
423 | 379 | \ No newline at end of file | ... | ... |
23.4 KB
9.21 KB