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;
|
const productData = res.translatedProduct || res.product;
|
||||||
productData.seoName = this.props.seoName;
|
productData.seoName = this.props.seoName;
|
||||||
|
|
||||||
|
// Use translated attributes if available
|
||||||
|
const attributesData = res.translatedAttributes || res.attributes;
|
||||||
|
|
||||||
// Initialize cache if it doesn't exist
|
// Initialize cache if it doesn't exist
|
||||||
if (!window.productDetailCache) {
|
if (!window.productDetailCache) {
|
||||||
window.productDetailCache = {};
|
window.productDetailCache = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache the complete response data (product + attributes) - cache the response with translated product
|
// 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;
|
window.productDetailCache[cacheKey] = cacheData;
|
||||||
|
|
||||||
// Clean up prerender fallback since we now have real data
|
// 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
|
upgrading: false, // Clear upgrading state since we now have complete data
|
||||||
error: null,
|
error: null,
|
||||||
imageDialogOpen: false,
|
imageDialogOpen: false,
|
||||||
attributes: res.attributes,
|
attributes: attributesData,
|
||||||
komponenten: komponenten,
|
komponenten: komponenten,
|
||||||
komponentenLoaded: komponenten.length === 0, // If no komponenten, mark as loaded
|
komponentenLoaded: komponenten.length === 0, // If no komponenten, mark as loaded
|
||||||
similarProducts: res.similarProducts || []
|
similarProducts: res.similarProducts || []
|
||||||
@@ -653,7 +656,7 @@ class ProductDetailPage extends Component {
|
|||||||
console.log("getProductView", res);
|
console.log("getProductView", res);
|
||||||
|
|
||||||
// Load attribute images
|
// Load attribute images
|
||||||
this.loadAttributeImages(res.attributes);
|
this.loadAttributeImages(attributesData);
|
||||||
} else {
|
} else {
|
||||||
console.error(
|
console.error(
|
||||||
"Error loading product:",
|
"Error loading product:",
|
||||||
|
|||||||
Reference in New Issue
Block a user