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>
This commit is contained in:
43
connector-miravia/classes/Sdk/AeSdk/Iop/IopLogger.php
Normal file
43
connector-miravia/classes/Sdk/AeSdk/Iop/IopLogger.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Sweeper\PlatformMiddleware\Sdk\AeSdk\Iop;
|
||||
|
||||
class IopLogger
|
||||
{
|
||||
|
||||
public $conf = [
|
||||
"separator" => "\t",
|
||||
"log_file" => ""
|
||||
];
|
||||
|
||||
private $fileHandle;
|
||||
|
||||
protected function getFileHandle()
|
||||
{
|
||||
if (null === $this->fileHandle) {
|
||||
if (empty($this->conf["log_file"])) {
|
||||
trigger_error("no log file spcified.");
|
||||
}
|
||||
$logDir = dirname($this->conf["log_file"]);
|
||||
if (!is_dir($logDir) && !mkdir($logDir, 0777, true) && !is_dir($logDir)) {
|
||||
throw new \RuntimeException(sprintf('Directory "%s" was not created', $logDir));
|
||||
}
|
||||
$this->fileHandle = fopen($this->conf["log_file"], "a");
|
||||
}
|
||||
|
||||
return $this->fileHandle;
|
||||
}
|
||||
|
||||
public function log($logData)
|
||||
{
|
||||
if ("" == $logData || [] == $logData) {
|
||||
return false;
|
||||
}
|
||||
if (is_array($logData)) {
|
||||
$logData = implode($this->conf["separator"], $logData);
|
||||
}
|
||||
$logData .= "\n";
|
||||
fwrite($this->getFileHandle(), $logData);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user