feat: full variable product support — create WC products with variants from Odoo

Detects Odoo product variants (product.template.attribute_line) and creates
WC variable products with attributes and variations. Each variation gets
its own price, SKU, image, stock, and tax class. Variant lines shown in
wizard with include/exclude toggle. WC attributes and terms auto-created.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-04-01 17:22:40 -04:00
parent 05c84d077d
commit 9d483fb474
4 changed files with 314 additions and 26 deletions

View File

@@ -85,6 +85,35 @@ class WooApiClient:
def create_product(self, data):
return self.post('products', data)
# Attribute endpoints
def get_product_attributes(self):
return self.get('products/attributes', params={'per_page': 100})
def create_product_attribute(self, data):
return self.post('products/attributes', data)
def get_attribute_terms(self, attribute_id, page=1, per_page=100):
return self.get(f'products/attributes/{attribute_id}/terms', params={'page': page, 'per_page': per_page})
def create_attribute_term(self, attribute_id, data):
return self.post(f'products/attributes/{attribute_id}/terms', data)
# Variation endpoints
def create_product_variation(self, product_id, data):
return self.post(f'products/{product_id}/variations', data)
def update_product_variation(self, product_id, variation_id, data):
return self.put(f'products/{product_id}/variations/{variation_id}', data)
def delete_product_variation(self, product_id, variation_id):
return self.delete(f'products/{product_id}/variations/{variation_id}')
def batch_create_variations(self, product_id, variations_data):
"""Create multiple variations at once using WC batch endpoint."""
return self.post(f'products/{product_id}/variations/batch', {'create': variations_data})
# Order endpoints
def get_orders(self, page=1, per_page=100, **kwargs):