diff --git a/backend/views/layouts/main-sidebar.php b/backend/views/layouts/main-sidebar.php index a743b36..afd46f4 100755 --- a/backend/views/layouts/main-sidebar.php +++ b/backend/views/layouts/main-sidebar.php @@ -25,14 +25,15 @@ use yii\widgets\Menu; ['label' => 'MAIN NAVIGATION', 'options'=>['class'=>'header']], ['label' => 'Заказы', 'url' => ['/orders/index'], 'template'=>' {label}'], [ - 'label' => 'Products', + 'label' => 'eCommerce', 'template'=>' {label}', 'url' => ['/product/manage'], 'items' => [ ['label' => 'Товары', 'url' => ['/product/manage']], - ['label' => 'Импорт товаров', 'url' => ['/product/manage/import']], ['label' => 'Категории', 'url' => ['/category']], ['label' => 'Бренды', 'url' => ['/brand']], + ['label' => 'Характеристики', 'url' => ['/rubrication/tax-group']], + ['label' => 'Статистика импорта', 'url' => ['/product/manage/import-stat']], ] ], [ @@ -43,15 +44,7 @@ use yii\widgets\Menu; ['label' => 'Банер', 'url' => ['/banner/index']], ] ], - [ - 'label' => 'Характеристики', - 'template'=>' {label}', - 'url' => ['/rubrication/tax-group'], - 'items' => [ - ['label' => 'Характеристики', 'url' => ['/rubrication/tax-group']], - ['label' => 'Зависимости', 'url' => ['/relation/manage']] - ] - ], + ['label' => 'Статические страницы', 'url' => ['/page/index']], ['label' => 'Акции', 'url' => ['/event/index']], ['label' => 'Услуги', 'url' => ['/service/index']], diff --git a/common/modules/product/controllers/ManageController.php b/common/modules/product/controllers/ManageController.php index 940921a..9fb7ab7 100755 --- a/common/modules/product/controllers/ManageController.php +++ b/common/modules/product/controllers/ManageController.php @@ -12,6 +12,9 @@ use common\modules\product\models\ProductSearch; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; +use common\modules\product\models\Brand; +use common\modules\product\models\BrandName; +use common\modules\product\models\RemoteProducts; /** * ManageController implements the CRUD actions for Product model. @@ -173,6 +176,47 @@ class ManageController extends Controller ]); } + public function actionImportStat() { + $all_products = $new_products = $linked_products = $orpahed_products = 0; + $remoteProducts = RemoteProducts::find()->all(); + + $not_linked_cats = []; + + foreach($remoteProducts as $product) { + if (!empty($product->product->product_id)) { + $linked_products++; + } elseif (!empty($product->remoteCategory) && !empty($product->remoteCategory->category) && !empty($product->remoteCategory->category->category_id)) { + $new_products++; + } else { + if (!empty($product->remoteCategory)) { + if (empty($not_linked_cats[$product->remoteCategory->ID])) { + $not_linked_cats[$product->remoteCategory->ID] = $product->remoteCategory->Name ." (". $product->remoteCategory->ID .")"; + } + } + $orpahed_products++; + } + $all_products++; + } + + $op = []; + + $op[] = "Всего $all_products товаров, $new_products новых и $linked_products уже связанных."; + if (!empty($not_linked_cats)) { + $op[] = "$orpahed_products товаров не привязаны к категориям:"; + foreach ($not_linked_cats as $not_linked_cat) { + $op[] = "$not_linked_cat"; + } + } + + return $this->render('import-stat', [ + 'all_products' => $all_products, + 'new_products' => $new_products, + 'linked_products' => $linked_products, + 'orpahed_products' => $orpahed_products, + 'not_linked_cats' => $not_linked_cats, + ]); + } + /** * Finds the Product model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. diff --git a/common/modules/product/views/manage/import-stat.php b/common/modules/product/views/manage/import-stat.php new file mode 100644 index 0000000..bd9d30d --- /dev/null +++ b/common/modules/product/views/manage/import-stat.php @@ -0,0 +1,28 @@ +title = Yii::t('product', 'Import statistics'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
= $orpahed_products?> товаров не привязаны к категориям:
+