From 766fef27967401824dce9332e243d97b06c5d6be Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Sat, 22 Nov 2025 12:48:40 +0100 Subject: [PATCH] feat(ProductDetail): enhance attribute handling with translation support - Updated ProductDetailPage to utilize translated attributes if available, improving localization. - Cached both product and attribute data for better performance. - Adjusted state management to reflect the use of translated attributes in the component. --- src/components/ProductDetailPage.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/ProductDetailPage.js b/src/components/ProductDetailPage.js index 37a042d..8e06aee 100644 --- a/src/components/ProductDetailPage.js +++ b/src/components/ProductDetailPage.js @@ -599,13 +599,16 @@ class ProductDetailPage extends Component { const productData = res.translatedProduct || res.product; productData.seoName = this.props.seoName; + // Use translated attributes if available + const attributesData = res.translatedAttributes || res.attributes; + // Initialize cache if it doesn't exist if (!window.productDetailCache) { window.productDetailCache = {}; } // Cache the complete response data (product + attributes) - cache the response with translated product - const cacheData = { ...res, product: productData }; + const cacheData = { ...res, product: productData, attributes: attributesData }; window.productDetailCache[cacheKey] = cacheData; // Clean up prerender fallback since we now have real data @@ -628,7 +631,7 @@ class ProductDetailPage extends Component { upgrading: false, // Clear upgrading state since we now have complete data error: null, imageDialogOpen: false, - attributes: res.attributes, + attributes: attributesData, komponenten: komponenten, komponentenLoaded: komponenten.length === 0, // If no komponenten, mark as loaded similarProducts: res.similarProducts || [] @@ -653,7 +656,7 @@ class ProductDetailPage extends Component { console.log("getProductView", res); // Load attribute images - this.loadAttributeImages(res.attributes); + this.loadAttributeImages(attributesData); } else { console.error( "Error loading product:",