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:
@@ -128,11 +128,17 @@ if( !class_exists('MiraviaCore') ) {
|
||||
static function check_product_onjob($product) {
|
||||
global $wpdb;
|
||||
$check = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}miravia_products WHERE id_woocommerce = {$product}");
|
||||
LOG::add("Comprobando si el producto {$product} esta en job {$check->status_text}");
|
||||
if($check->status_text == 'IN_QUEUE') {
|
||||
return true;
|
||||
|
||||
if($check) {
|
||||
LOG::add("DEBUG: Product {$product} found in DB - Status: {$check->status_text}, Job ID: {$check->job_id}, Last Error: {$check->lastError}");
|
||||
if($check->status_text == 'IN_QUEUE') {
|
||||
LOG::add("DEBUG: Product {$product} is IN_QUEUE - blocking new submission");
|
||||
return true;
|
||||
}
|
||||
LOG::add("DEBUG: Product {$product} not in queue (status: {$check->status_text}) - allowing submission");
|
||||
} else {
|
||||
LOG::add("DEBUG: Product {$product} not found in miravia_products table - allowing submission");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -382,16 +388,26 @@ if( !class_exists('MiraviaCore') ) {
|
||||
|
||||
static function set_job_product($id, $profile, $job = 0) {
|
||||
global $wpdb;
|
||||
|
||||
if(is_array($id)) {
|
||||
$where = "id_woocommerce IN(".implode(',', $id).")";
|
||||
LOG::add("DEBUG: Setting job for multiple products: " . implode(',', $id));
|
||||
}else{
|
||||
$where = "id_woocommerce = '$id'";
|
||||
LOG::add("DEBUG: Setting job for single product: {$id}");
|
||||
}
|
||||
|
||||
LOG::add("DEBUG: Setting job ID {$job} for profile {$profile}");
|
||||
$query = "UPDATE {$wpdb->prefix}miravia_products SET job_id='{$job}', status_text='IN_QUEUE' WHERE profile_id = {$profile} AND ". $where;
|
||||
$result = $wpdb->query($query);
|
||||
LOG::add("SET JOB ON PRODUCTS -> " . $query);
|
||||
LOG::add($result);
|
||||
LOG::add("DEBUG: Set job query executed: " . $query);
|
||||
LOG::add("DEBUG: Set job query affected {$result} rows");
|
||||
|
||||
if($result === false) {
|
||||
LOG::add("DEBUG: Set job query FAILED - SQL Error: " . $wpdb->last_error);
|
||||
} elseif($result == 0) {
|
||||
LOG::add("DEBUG: Set job query affected 0 rows - products may not exist or already have this status");
|
||||
}
|
||||
}
|
||||
|
||||
static function set_job_product_error($id, $profile, $job = 0, $errorText = 'Generic Error') {
|
||||
|
||||
Reference in New Issue
Block a user