]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-148] вывод отправляемых на маркет данных 3
authorAlexander Smirnov <fredeom@mail.ru>
Wed, 13 Nov 2024 17:36:57 +0000 (20:36 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Wed, 13 Nov 2024 17:36:57 +0000 (20:36 +0300)
erp24/api2/controllers/YandexMarketController.php

index 75ddb86b11d3434cbcb01f13ed3a787f60343ad5..b7973d830db2c43f2c7969221013c2888f67f19c 100644 (file)
@@ -4,6 +4,7 @@ namespace app\controllers;
 
 use Matrix\Matrix;
 use Yii;
+use yii\grid\GridView;
 use yii\helpers\ArrayHelper;
 use yii\rest\Controller;
 use OpenAPI\Client\Configuration;
@@ -92,6 +93,12 @@ class YandexMarketController extends Controller
             $matrixErpByGuid[$matrix->guid] = $matrix;
         }
         $models = [];
+//        $viewModels = [];
+        if (!$do) {
+            $output .= "<table border='1'><thead><tr><th>offerId</th><th>Категория</th><th>marketCategoryId</th>" .
+                "<th>Название</th><th>Базовая Цена, р</th><th>Бренд</th><th>Длина, см</th><th>Высота, см</th>" .
+                "<th>Ширина, см</th><th>Вес, кг</th><th>Картинка</th><th>Описание</th></tr></thead><tbody>";
+        }
         foreach ($products as $product) {
             /* @var $product Products1c */
             if (($matrixErpByGuid[$product->id]->price->price ?? 0) == 0) {
@@ -110,22 +117,44 @@ class YandexMarketController extends Controller
                     ],
                     'vendor' => 'База Цветов 24',
                     'weightDimensions' => new Model\OfferWeightDimensionsDTO([
-                        'height' => $matrixErpByGuid[$product->id]->matrixProperty->height ?? 40,
                         'length' => $matrixErpByGuid[$product->id]->matrixProperty->length ?? 23,
-                        'weight' => $matrixErpByGuid[$product->id]->matrixProperty->weight ?? 0.15,
+                        'height' => $matrixErpByGuid[$product->id]->matrixProperty->height ?? 40,
                         'width' => $matrixErpByGuid[$product->id]->matrixProperty->width ?? 20,
+                        'weight' => $matrixErpByGuid[$product->id]->matrixProperty->weight ?? 0.15,
                     ]),
-                    'description' => $matrixErpByGuid[$product->id]->matrixProperty->description ?? '-',
                     'pictures' => ['https://media.erp-flowers.ru/media/view-image/' . ($matrixErpByGuid[$product->id]->matrixProperty->image_id ?? null)],
+                    'description' => $matrixErpByGuid[$product->id]->matrixProperty->description ?? '-',
                 ],
             ];
 
             if ($do) {
                 $models [] = new Model\UpdateOfferMappingDTO($model);
             } else {
-                ob_start();
-                echo "<pre>"; var_dump($model); echo "</pre>";
-                $output .= ob_get_clean();
+                $output .= "<tr><td>" . $product->id . "</td><td>Цветы</td><td>91284</td><td>" .
+                    (!empty($matrixErpByGuid[$product->id]->matrixProperty->display_name) ?
+                    $matrixErpByGuid[$product->id]->matrixProperty->display_name : $product->name) . "</td><td>"
+                    . $matrixErpByGuid[$product->id]->price->price . "</td><td>База Цветов 24</td><td>" .
+                    ($matrixErpByGuid[$product->id]->matrixProperty->length ?? 23) . "</td><td>" .
+                    ($matrixErpByGuid[$product->id]->matrixProperty->height ?? 40) . "</td><td>" .
+                    ($matrixErpByGuid[$product->id]->matrixProperty->width ?? 20) . "</td><td>" .
+                    ($matrixErpByGuid[$product->id]->matrixProperty->weight ?? 0.15) . "</td><td>" .
+                    ('https://media.erp-flowers.ru/media/view-image/' . ($matrixErpByGuid[$product->id]->matrixProperty->image_id ?? null)) . "</td><td>" .
+                    ($matrixErpByGuid[$product->id]->matrixProperty->description ?? '-') . "</td></tr>";
+//                $viewModels [] = [
+//                    'offerId' => $product->id,
+//                    'category' => 'Цветы',
+//                    'marketCategoryId' => 91284,
+//                    'name' => (!empty($matrixErpByGuid[$product->id]->matrixProperty->display_name) ?
+//                        $matrixErpByGuid[$product->id]->matrixProperty->display_name : $product->name),
+//                    'price' => $matrixErpByGuid[$product->id]->price->price,
+//                    'vendor' => 'База Цветов 24',
+//                    'length' => ($matrixErpByGuid[$product->id]->matrixProperty->length ?? 23),
+//                    'height' => ($matrixErpByGuid[$product->id]->matrixProperty->height ?? 40),
+//                    'width' => ($matrixErpByGuid[$product->id]->matrixProperty->width ?? 20),
+//                    'weight' => ($matrixErpByGuid[$product->id]->matrixProperty->weight ?? 0.15),
+//                    'picture' => ('https://media.erp-flowers.ru/media/view-image/' . ($matrixErpByGuid[$product->id]->matrixProperty->image_id ?? null)),
+//                    'description' => ($matrixErpByGuid[$product->id]->matrixProperty->description ?? '-'),
+//                ];
             }
         }
 
@@ -137,9 +166,29 @@ class YandexMarketController extends Controller
             ob_start();
             var_dump($apiInstance->updateoffermappings(5330887, $apiModel));
             $output .= ob_get_clean();
-        };
-    
-        return "<a href='/yandex-market/create-cards'>Обновить страницу</a>" . str_repeat("&nbsp", 5) .
-               "<a href='/yandex-market/create-cards?do=1'>Отослать данные</a> $output";
+        } else {
+            $output .= '</tbody></table>';
+//            $output .= GridView::widget([
+//                    'dataProvider' => $viewModels,
+//                    'columns' => [
+//                        ['class' => 'yii\grid\SerialColumn'],
+//                        'offerId',
+//                        'category',
+//                        'marketCategoryId',
+//                        'name',
+//                        'price',
+//                        'vendor',
+//                        'length',
+//                        'height',
+//                        'width',
+//                        'weight',
+//                        'picture',
+//                        'description',
+//                    ],
+//                ]);
+        }
+
+        return "<a href='/yandex-market/create-cards'>Обновить страницу</a>" . str_repeat("&nbsp", 15) .
+               "<a href='/yandex-market/create-cards?do=1'>Отослать данные</a> <br> $output";
     }
 }
\ No newline at end of file