]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
логирование сохранения первой картинки
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 6 Oct 2025 06:22:01 +0000 (09:22 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 6 Oct 2025 06:22:01 +0000 (09:22 +0300)
erp24/controllers/MarketplaceController.php
erp24/controllers/MatrixErpPropertyController.php
erp24/web/js/matrix_erp_property/_form.js

index 53a2bd4cdd649aa7c1d3af895035e95dbcc2f2a8..e1c13184bd074063f91a378123d72d0b8aa989e5 100644 (file)
@@ -39,7 +39,7 @@ class MarketplaceController extends Controller
     public function actionTestFeed()
     {
 
-        $productsInfo = MarketplaceService::getSomeProductsInfo(3);
+        $productsInfo = MarketplaceService::getAllProductsInfo(3);
 
 
         $xmlFeed = MarketplaceService::createXMLFeed($productsInfo);
index 771b4f258cb0671d258ac6f14f484665689863fd..6416705dbbbaa6e4621bdfb307814616657412ef 100644 (file)
@@ -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__);
         }
     }
 
index fa347552d3e44430fd36bc8e197710b25da9b9b4..1deafb131589add370549a2b5ab35c986d0b572b 100644 (file)
@@ -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);
         }
     });