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:
Miravia Connector Bot
2025-07-21 13:57:16 +02:00
parent 191af6b0f8
commit 552bce9f84
7 changed files with 1224 additions and 39 deletions

View File

@@ -65,6 +65,27 @@ class MIRAVIADB {
PRIMARY KEY (id)
) $charset_collate;";
// Feed Jobs table for managing Feed API submissions
$sql .= "CREATE TABLE {$wpdb->prefix}miravia_feed_jobs (
id mediumint(9) NOT NULL AUTO_INCREMENT,
feed_id VARCHAR(100) DEFAULT NULL,
feed_document_id VARCHAR(255) DEFAULT NULL,
feed_type VARCHAR(50) DEFAULT 'PRODUCT_LISTING',
status VARCHAR(50) DEFAULT 'PENDING',
product_count INT DEFAULT 0,
product_ids TEXT DEFAULT NULL,
processing_start_time datetime DEFAULT NULL,
processing_end_time datetime DEFAULT NULL,
created datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated datetime DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,
error_message TEXT DEFAULT NULL,
result_data LONGTEXT DEFAULT NULL,
PRIMARY KEY (id),
KEY feed_id (feed_id),
KEY status (status),
KEY created (created)
) $charset_collate;";
//Run SQL
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $sql );