fix: add .png extension to image URLs — WC rejects extensionless URLs

WooCommerce requires a file extension in image src URLs to determine
file type. Added filename.png to all Odoo image URLs. Also fixed
variable name ordering bugs where img_name was used before defined.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-04-01 21:26:25 -04:00
parent 768731da0f
commit ed426912ce
3 changed files with 9 additions and 9 deletions

View File

@@ -249,9 +249,9 @@ class WooProductMap(models.Model):
# Variant image — pass Odoo's public URL, WC downloads it directly
if variant.image_variant_1920:
odoo_base = inst.env['ir.config_parameter'].sudo().get_param('web.base.url', '')
filename = (variant.default_code or 'variant') + '.jpg'
filename = (variant.default_code or 'variant') + '.png'
if odoo_base:
img_url = f"{odoo_base}/web/image/product.product/{variant.id}/image_1920"
img_url = f"{odoo_base}/web/image/product.product/{variant.id}/image_1920/{filename}"
var_data['image'] = {
'src': img_url,
'name': filename,