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:
@@ -55,16 +55,37 @@ class SimpleIopClient
|
||||
$apiPath = $request->getApiName();
|
||||
$apiParams = $request->getApiParams();
|
||||
|
||||
// For Miravia API, we use direct HTTP calls with token authentication
|
||||
$requestUrl = $this->gatewayUrl . $apiPath;
|
||||
|
||||
if(class_exists('LOG')) {
|
||||
LOG::add("DEBUG SimpleSDK: Making Miravia API request to: " . $requestUrl);
|
||||
LOG::add("DEBUG SimpleSDK: Params: " . json_encode($apiParams));
|
||||
// For Miravia Feed API, we need to use the AliExpress-style authentication but with path endpoints
|
||||
$sysParams = [
|
||||
"app_key" => $this->appKey,
|
||||
"sign_method" => $this->signMethod,
|
||||
"timestamp" => time() * 1000,
|
||||
"partner_id" => $this->sdkVersion,
|
||||
"v" => "1.0",
|
||||
"format" => "json"
|
||||
];
|
||||
|
||||
if ($accessToken) {
|
||||
$sysParams["access_token"] = $accessToken;
|
||||
}
|
||||
|
||||
// Use direct POST with JSON for Miravia API
|
||||
$response = $this->curlMiravia($requestUrl, $apiParams, $accessToken);
|
||||
// Merge API params with system params
|
||||
$allParams = array_merge($apiParams, $sysParams);
|
||||
|
||||
// Generate signature using the API path
|
||||
$sign = $this->generateSign($apiPath, $allParams);
|
||||
$allParams["sign"] = $sign;
|
||||
|
||||
$requestUrl = $this->gatewayUrl;
|
||||
|
||||
if(class_exists('LOG')) {
|
||||
LOG::add("DEBUG SimpleSDK: Making Miravia Feed API request to: " . $requestUrl);
|
||||
LOG::add("DEBUG SimpleSDK: API Path: " . $apiPath);
|
||||
LOG::add("DEBUG SimpleSDK: Params: " . json_encode($allParams));
|
||||
}
|
||||
|
||||
// Use form POST for Miravia Feed API
|
||||
$response = $this->curl($requestUrl, $allParams);
|
||||
|
||||
if(class_exists('LOG')) {
|
||||
LOG::add("DEBUG SimpleSDK: Miravia Response: " . $response);
|
||||
|
||||
Reference in New Issue
Block a user