From: Alexander Smirnov Date: Thu, 14 Nov 2024 07:16:41 +0000 (+0300) Subject: [ERP-148] вывод отправляемых на маркет данных в отдельном url X-Git-Tag: 1.6~3^2~2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ece35bebb0831d0e2fd2b43cfa91c6c76cc460b5;p=erp24_rep%2Fyii-erp24%2F.git [ERP-148] вывод отправляемых на маркет данных в отдельном url --- diff --git a/erp24/api2/controllers/YandexMarketController.php b/erp24/api2/controllers/YandexMarketController.php index b7973d83..c9024a60 100644 --- a/erp24/api2/controllers/YandexMarketController.php +++ b/erp24/api2/controllers/YandexMarketController.php @@ -93,12 +93,11 @@ class YandexMarketController extends Controller $matrixErpByGuid[$matrix->guid] = $matrix; } $models = []; -// $viewModels = []; - if (!$do) { - $output .= "" . - "" . - ""; - } +// if (!$do) { +// $output .= "
offerIdКатегорияmarketCategoryIdНазваниеБазовая Цена, рБрендДлина, смВысота, смШирина, смВес, кгКартинкаОписание
" . +// "" . +// ""; +// } foreach ($products as $product) { /* @var $product Products1c */ if (($matrixErpByGuid[$product->id]->price->price ?? 0) == 0) { @@ -130,31 +129,16 @@ class YandexMarketController extends Controller if ($do) { $models [] = new Model\UpdateOfferMappingDTO($model); } else { - $output .= ""; -// $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 ?? '-'), -// ]; +// $output .= ""; } } @@ -167,28 +151,10 @@ class YandexMarketController extends Controller var_dump($apiInstance->updateoffermappings(5330887, $apiModel)); $output .= ob_get_clean(); } else { - $output .= '
offerIdКатегорияmarketCategoryIdНазваниеБазовая Цена, рБрендДлина, смВысота, смШирина, смВес, кгКартинкаОписание
" . $product->id . "Цветы91284" . - (!empty($matrixErpByGuid[$product->id]->matrixProperty->display_name) ? - $matrixErpByGuid[$product->id]->matrixProperty->display_name : $product->name) . "" - . $matrixErpByGuid[$product->id]->price->price . "База Цветов 24" . - ($matrixErpByGuid[$product->id]->matrixProperty->length ?? 23) . "" . - ($matrixErpByGuid[$product->id]->matrixProperty->height ?? 40) . "" . - ($matrixErpByGuid[$product->id]->matrixProperty->width ?? 20) . "" . - ($matrixErpByGuid[$product->id]->matrixProperty->weight ?? 0.15) . "" . - ('https://media.erp-flowers.ru/media/view-image/' . ($matrixErpByGuid[$product->id]->matrixProperty->image_id ?? null)) . "" . - ($matrixErpByGuid[$product->id]->matrixProperty->description ?? '-') . "
" . $product->id . "Цветы91284" . +// (!empty($matrixErpByGuid[$product->id]->matrixProperty->display_name) ? +// $matrixErpByGuid[$product->id]->matrixProperty->display_name : $product->name) . "" +// . $matrixErpByGuid[$product->id]->price->price . "База Цветов 24" . +// ($matrixErpByGuid[$product->id]->matrixProperty->length ?? 23) . "" . +// ($matrixErpByGuid[$product->id]->matrixProperty->height ?? 40) . "" . +// ($matrixErpByGuid[$product->id]->matrixProperty->width ?? 20) . "" . +// ($matrixErpByGuid[$product->id]->matrixProperty->weight ?? 0.15) . "" . +// ('https://media.erp-flowers.ru/media/view-image/' . ($matrixErpByGuid[$product->id]->matrixProperty->image_id ?? null)) . "" . +// ($matrixErpByGuid[$product->id]->matrixProperty->description ?? '-') . "
'; -// $output .= GridView::widget([ -// 'dataProvider' => $viewModels, -// 'columns' => [ -// ['class' => 'yii\grid\SerialColumn'], -// 'offerId', -// 'category', -// 'marketCategoryId', -// 'name', -// 'price', -// 'vendor', -// 'length', -// 'height', -// 'width', -// 'weight', -// 'picture', -// 'description', -// ], -// ]); +// $output .= ''; } - return "Обновить страницу" . str_repeat(" ", 15) . + return "Обновить страницу" . str_repeat(" ", 15) . "Отослать данные
$output"; } } \ No newline at end of file diff --git a/erp24/controllers/YandexMarketController.php b/erp24/controllers/YandexMarketController.php new file mode 100644 index 00000000..11b931ed --- /dev/null +++ b/erp24/controllers/YandexMarketController.php @@ -0,0 +1,129 @@ +alias('p')->leftJoin('products_class pc', 'p.parent_id = pc.category_id') + ->where(['pc.tip' => [ProductsClass::MARKETPLACE, ProductsClass::MARKETPLACE_ADDITIONAL]])->all(); + $matrixErp = MatrixErp::find()->where(['guid' => ArrayHelper::getColumn($products, 'id')])->all(); + $matrixErpByGuid = []; + foreach ($matrixErp as $matrix) { + /* @var $matrix MatrixErp */ + $matrixErpByGuid[$matrix->guid] = $matrix; + } + + $viewModels = []; + foreach ($products as $product) { + /* @var $product Products1c */ + if (($matrixErpByGuid[$product->id]->price->price ?? 0) == 0) { + continue; + } + $model = [ + 'offer' => [ + 'offerId' => $product->id, + 'category' => 'Цветы', + 'marketCategoryId' => '91284', + 'name' => !empty($matrixErpByGuid[$product->id]->matrixProperty->display_name) ? + $matrixErpByGuid[$product->id]->matrixProperty->display_name : $product->name, + 'basicPrice' => [ + 'currencyId' => Model\CurrencyType::RUR, + 'value' => $matrixErpByGuid[$product->id]->price->price, + ], + 'vendor' => 'База Цветов 24', + 'weightDimensions' => new Model\OfferWeightDimensionsDTO([ + '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, + ]), + 'pictures' => ['https://media.erp-flowers.ru/media/view-image/' . ($matrixErpByGuid[$product->id]->matrixProperty->image_id ?? null)], + 'description' => $matrixErpByGuid[$product->id]->matrixProperty->description ?? '-', + ], + ]; + + $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 ?? '-'), + ]; + } + $output = GridView::widget([ + 'dataProvider' => new ArrayDataProvider(['allModels' => $viewModels]), + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + 'offerId', + [ + 'attribute' => 'category', + 'label' => 'Категория', + ], + 'marketCategoryId', + [ + 'attribute' => 'name', + 'label' => 'Название', + ], + [ + 'attribute' => 'price', + 'label' => 'Цена', + ], + [ + 'attribute' => 'vendor', + 'label' => 'Бренд', + ], + [ + 'attribute' => 'length', + 'label' => 'Длина, см', + ], + [ + 'attribute' => 'height', + 'label' => 'Высота, см', + ], + [ + 'attribute' => 'width', + 'label' => 'Ширина, см', + ], + [ + 'attribute' => 'weight', + 'label' => 'Вес, кг', + ], + [ + 'attribute' => 'picture', + 'label' => 'Изображение', + 'format' => 'raw', + 'value' => function ($model) { + ob_start(); + ImageHelper::drawImage($model['picture']); + return ob_get_clean(); + } + ], + [ + 'attribute' => 'description', + 'label' => 'Описание', + ], + ], + ]); + return $this->render('view-cards', compact('output')); + } +} \ No newline at end of file diff --git a/erp24/helpers/ImageHelper.php b/erp24/helpers/ImageHelper.php index afd3c754..0dac85fd 100644 --- a/erp24/helpers/ImageHelper.php +++ b/erp24/helpers/ImageHelper.php @@ -25,7 +25,7 @@ class ImageHelper public static function drawImage($url, $width = 200) { - ?> src='' alt="img" onclick="window.open(this.src, '_blank');" /> src='' alt="img" onclick="window.open(this.src, '_blank');" />params['breadcrumbs'][] = $this->title;
'btn btn-primary', 'target' => '_blank'] ) ?>
diff --git a/erp24/views/yandex-market/view-cards.php b/erp24/views/yandex-market/view-cards.php new file mode 100644 index 00000000..14368fb2 --- /dev/null +++ b/erp24/views/yandex-market/view-cards.php @@ -0,0 +1,11 @@ + + +Обновить страницу +Отослать данные
+ + +