From: Vladimir Fomichev Date: Mon, 6 Oct 2025 06:22:01 +0000 (+0300) Subject: логирование сохранения первой картинки X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=748b4f4acd792222c957e0dc6085a5d1300bf900;p=erp24_rep%2Fyii-erp24%2F.git логирование сохранения первой картинки --- diff --git a/erp24/controllers/MarketplaceController.php b/erp24/controllers/MarketplaceController.php index 53a2bd4c..e1c13184 100644 --- a/erp24/controllers/MarketplaceController.php +++ b/erp24/controllers/MarketplaceController.php @@ -39,7 +39,7 @@ class MarketplaceController extends Controller public function actionTestFeed() { - $productsInfo = MarketplaceService::getSomeProductsInfo(3); + $productsInfo = MarketplaceService::getAllProductsInfo(3); $xmlFeed = MarketplaceService::createXMLFeed($productsInfo); diff --git a/erp24/controllers/MatrixErpPropertyController.php b/erp24/controllers/MatrixErpPropertyController.php index 771b4f25..6416705d 100644 --- a/erp24/controllers/MatrixErpPropertyController.php +++ b/erp24/controllers/MatrixErpPropertyController.php @@ -233,7 +233,13 @@ class MatrixErpPropertyController extends Controller if (empty($modelMatrixErpMediaRow->id)) { unset($modelMatrixErpMediaRow->id); } - $modelMatrixErpMediaRow->save(); + if ($modelMatrixErpMediaRow->save()) { + Yii::error("MatrixErpMedia saved: id={$modelMatrixErpMediaRow->id}, foto_order={$modelMatrixErpMediaRow->foto_order}", __METHOD__); + } else { + Yii::error("Failed to save MatrixErpMedia: " . json_encode($modelMatrixErpMediaRow->getErrors()), __METHOD__); + } + } else { + Yii::error("MatrixErpMedia validation failed: " . json_encode($modelMatrixErpMediaRow->getErrors()), __METHOD__); } } @@ -308,10 +314,18 @@ class MatrixErpPropertyController extends Controller if ($firstMedia && $firstMedia->file) { $file = $firstMedia->file; + $fullFilePath = \Yii::getAlias('@yii_app') . FileService::padWithSlash($file->url); + Yii::error("First media file: " . json_encode([ + 'file_id' => $file->id, + 'file_type' => $file->file_type, + 'url' => $file->url, + 'full_path' => $fullFilePath, + 'file_exists' => file_exists($fullFilePath) + ]), __METHOD__); // Проверяем, что файл существует и это изображение - if ($file->file_type === 'image' && file_exists($file->url)) { - Yii::info("Processing main image update for file: {$file->url}", __METHOD__); + if ($file->file_type === 'image' && file_exists($fullFilePath)) { + Yii::error("Processing main image update for file: {$fullFilePath}", __METHOD__); // Сохраняем старую картинку для возможного удаления $oldImageId = $modelEdit->image_id; @@ -328,22 +342,22 @@ class MatrixErpPropertyController extends Controller $displayName = !empty($firstMedia->name) ? $firstMedia->name : pathinfo($originalName, PATHINFO_FILENAME); $image->original_name = $displayName . $ext; $image->filename = $file_name; - $image->type = mime_content_type($file->url) ?: 'image/jpeg'; + $image->type = mime_content_type($fullFilePath) ?: 'image/jpeg'; // Получаем размеры изображения - $imageInfo = getimagesize($file->url); + $imageInfo = getimagesize($fullFilePath); if ($imageInfo) { $image->width = $imageInfo[0]; $image->height = $imageInfo[1]; } - $image->size = filesize($file->url); + $image->size = filesize($fullFilePath); $image->created_at = time(); $image->updated_at = time(); if ($image->save()) { // Копируем файл в директорию images - $sourcePath = $file->url; + $sourcePath = $fullFilePath; $destDir = \Yii::getAlias('@uploads/images/' . substr($image->filename, 0, 2)); $destPath = $destDir . '/' . $image->filename; @@ -375,7 +389,11 @@ class MatrixErpPropertyController extends Controller $image->delete(); } } + } else { + Yii::error("File check failed: file_type='{$file->file_type}', file_exists=" . (file_exists($file->url) ? 'true' : 'false') . ", url='{$file->url}'", __METHOD__); } + } else { + Yii::error("First media has no file or file is null", __METHOD__); } } diff --git a/erp24/web/js/matrix_erp_property/_form.js b/erp24/web/js/matrix_erp_property/_form.js index fa347552..1deafb13 100644 --- a/erp24/web/js/matrix_erp_property/_form.js +++ b/erp24/web/js/matrix_erp_property/_form.js @@ -136,7 +136,9 @@ function updateNumRowValues() { if (fotoOrderInput.length) { // Устанавливаем порядок начиная с 1 - fotoOrderInput.val(index + 1); + const newOrder = index + 1; + fotoOrderInput.val(newOrder); + console.log('Set foto_order to', newOrder, 'for item', index); } });