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.
This commit is contained in:
@@ -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:",
|
||||
|
||||
Reference in New Issue
Block a user