Commit c790ef0991bb344cedd89cb9a969bb078c4e0313
1 parent
0b8441f2
Karnovsky-04052016-1200
Showing
4 changed files
with
78 additions
and
13 deletions
Show diff stats
backend/views/layouts/main-sidebar.php
... | ... | @@ -25,14 +25,15 @@ 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/manage/import-stat']], | |
36 | 37 | ] |
37 | 38 | ], |
38 | 39 | [ |
... | ... | @@ -43,15 +44,7 @@ use yii\widgets\Menu; |
43 | 44 | ['label' => 'Банер', 'url' => ['/banner/index']], |
44 | 45 | ] |
45 | 46 | ], |
46 | - [ | |
47 | - 'label' => 'Характеристики', | |
48 | - 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-search"></i> <span>{label}</span></a>', | |
49 | - 'url' => ['/rubrication/tax-group'], | |
50 | - 'items' => [ | |
51 | - ['label' => 'Характеристики', 'url' => ['/rubrication/tax-group']], | |
52 | - ['label' => 'Зависимости', 'url' => ['/relation/manage']] | |
53 | - ] | |
54 | - ], | |
47 | + | |
55 | 48 | ['label' => 'Статические страницы', 'url' => ['/page/index']], |
56 | 49 | ['label' => 'Акции', 'url' => ['/event/index']], |
57 | 50 | ['label' => 'Услуги', 'url' => ['/service/index']], | ... | ... |
common/modules/product/controllers/ManageController.php
... | ... | @@ -12,6 +12,9 @@ use common\modules\product\models\ProductSearch; |
12 | 12 | use yii\web\Controller; |
13 | 13 | use yii\web\NotFoundHttpException; |
14 | 14 | use yii\filters\VerbFilter; |
15 | +use common\modules\product\models\Brand; | |
16 | +use common\modules\product\models\BrandName; | |
17 | +use common\modules\product\models\RemoteProducts; | |
15 | 18 | |
16 | 19 | /** |
17 | 20 | * ManageController implements the CRUD actions for Product model. |
... | ... | @@ -173,6 +176,47 @@ class ManageController extends Controller |
173 | 176 | ]); |
174 | 177 | } |
175 | 178 | |
179 | + public function actionImportStat() { | |
180 | + $all_products = $new_products = $linked_products = $orpahed_products = 0; | |
181 | + $remoteProducts = RemoteProducts::find()->all(); | |
182 | + | |
183 | + $not_linked_cats = []; | |
184 | + | |
185 | + foreach($remoteProducts as $product) { | |
186 | + if (!empty($product->product->product_id)) { | |
187 | + $linked_products++; | |
188 | + } elseif (!empty($product->remoteCategory) && !empty($product->remoteCategory->category) && !empty($product->remoteCategory->category->category_id)) { | |
189 | + $new_products++; | |
190 | + } else { | |
191 | + if (!empty($product->remoteCategory)) { | |
192 | + if (empty($not_linked_cats[$product->remoteCategory->ID])) { | |
193 | + $not_linked_cats[$product->remoteCategory->ID] = $product->remoteCategory->Name ." (". $product->remoteCategory->ID .")"; | |
194 | + } | |
195 | + } | |
196 | + $orpahed_products++; | |
197 | + } | |
198 | + $all_products++; | |
199 | + } | |
200 | + | |
201 | + $op = []; | |
202 | + | |
203 | + $op[] = "Всего $all_products товаров, $new_products новых и $linked_products уже связанных."; | |
204 | + if (!empty($not_linked_cats)) { | |
205 | + $op[] = "$orpahed_products товаров не привязаны к категориям:"; | |
206 | + foreach ($not_linked_cats as $not_linked_cat) { | |
207 | + $op[] = "$not_linked_cat"; | |
208 | + } | |
209 | + } | |
210 | + | |
211 | + return $this->render('import-stat', [ | |
212 | + 'all_products' => $all_products, | |
213 | + 'new_products' => $new_products, | |
214 | + 'linked_products' => $linked_products, | |
215 | + 'orpahed_products' => $orpahed_products, | |
216 | + 'not_linked_cats' => $not_linked_cats, | |
217 | + ]); | |
218 | + } | |
219 | + | |
176 | 220 | /** |
177 | 221 | * Finds the Product model based on its primary key value. |
178 | 222 | * If the model is not found, a 404 HTTP exception will be thrown. | ... | ... |
common/modules/product/views/manage/import-stat.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\Product */ | |
8 | + | |
9 | +$this->title = Yii::t('product', 'Import statistics'); | |
10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['index']]; | |
11 | +$this->params['breadcrumbs'][] = $this->title; | |
12 | +?> | |
13 | +<div class="product-create"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + | |
17 | + <h2>Всего <?= $all_products?> товаров, <?= $new_products?> новых и <?= $linked_products?> уже связанных.</h2> | |
18 | + <?php if (!empty($not_linked_cats)) :?> | |
19 | + <p><?= $orpahed_products?> товаров не привязаны к категориям:</p> | |
20 | + <ul > | |
21 | + <?php foreach ($not_linked_cats as $not_linked_cat) :?> | |
22 | + <li><?= $not_linked_cat?></li> | |
23 | + <?php endforeach?> | |
24 | + </ul> | |
25 | + | |
26 | + <?php endif?> | |
27 | + | |
28 | +</div> | |
0 | 29 | \ No newline at end of file | ... | ... |
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(), [ | ... | ... |