Files
Miravia Connector Bot a7d7dbb164 Fix image upload structure for Miravia API compliance
🔧 Bug Fixes:
- Fixed product image structure to match Miravia API requirements
- Updated MiraviaProduct.php getData() method to wrap images in {"Image": [...]} format
- Updated MiraviaCombination.php getData() method to wrap SKU images properly
- Resolved error "[4224] The Main image of the product is required"

📋 Changes:
- Modified getData() methods to transform flat image arrays to nested structure
- Product images: images[] → Images: {"Image": [...]}
- SKU images: images[] → Images: {"Image": [...]}
- Maintains backward compatibility for empty image arrays

🎯 Impact:
- Product uploads will now pass Miravia's image validation
- Both product-level and SKU-level images properly formatted
- Complies with official Miravia API documentation structure

🤖 Generated with Claude Code (https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-17 08:11:23 +02:00

60 lines
1.9 KiB
PHP

<?php
if(!class_exists('LOG')) {
class LOG {
/**
* add message to file
*
* @param string $msg String to register
* @param int|string $element Any ID or String
* @param string $type Default: user
* @return int|boolean
*/
static function add($msg, $element = false, $type = false ) {
if(!$type) {
$type = defined('LOG_DEFAULT_FILE') ? LOG_DEFAULT_FILE : 'user';
}
$root = defined('LOG_FOLDER') ? LOG_FOLDER : '/';
//If an element is defined and provided, it will be separated into files by element
$divide = defined('LOG_DIVIDE_ELEMENT');
$y = date('Y');
$m = date('m');
//Create htaccess file if no exist
if(!file_exists($root . "logs/.htaccess")) {
file_put_contents($root . "logs/.htaccess", 'Deny from all');
}
$fileDest = $root . "logs/{$y}/{$m}/";
if(!file_exists($fileDest)) {
$dir = mkdir($fileDest, 0775, true);
}
if($element && $divide) {
return file_put_contents($fileDest.$type."_{$element}.log", self::data($msg, $element, $type),FILE_APPEND);
}
return file_put_contents($fileDest.$type.".log", self::data($msg, $element, $type),FILE_APPEND);
}
/**
* Structure data
*
* @param string $msg
* @param int|string $element
* @param string $type
* @return string
*/
private static function data($msg, $element = '0', $type) {
if(is_array($msg) || is_object($msg)) {
return "[".date('Y-m-d H:i:s') . "] ". json_encode($msg, JSON_PRETTY_PRINT) . " \r\n";
}
return "[".date('Y-m-d H:i:s') . "] $msg \r\n";
}
}
}