This commit is contained in:
sebseb7
2025-07-23 09:46:54 +02:00
parent bd4c0a50f1
commit b5a78b33cb

View File

@@ -259,11 +259,13 @@ class Content extends Component {
fetchCategoryData(categoryId) {
// Check if we have the category tree data in window.productCache
// Simply check if we have any category tree data in window.productCache
const hasCategoryTree = window.productCache &&
window.productCache["categoryTree_209"] &&
window.productCache["categoryTree_209"].categoryTree;
Object.keys(window.productCache).some(key =>
key.startsWith("categoryTree_209") &&
window.productCache[key] &&
window.productCache[key].categoryTree);
// Check for specific category data in cache
const cachedData = getCachedCategoryData(categoryId);
@@ -412,15 +414,27 @@ class Content extends Component {
// Helper function to get category name from tree
getCategoryNameFromTree = (categoryId) => {
if (!window.productCache || !window.productCache["categoryTree_209"] ||
!window.productCache["categoryTree_209"].categoryTree) {
if (!window.productCache) {
return null;
}
// Find the first available category tree
const categoryTreeKey = Object.keys(window.productCache).find(key =>
key.startsWith("categoryTree_209") &&
window.productCache[key] &&
window.productCache[key].categoryTree
);
if (!categoryTreeKey) {
return null;
}
const categoryTree = window.productCache[categoryTreeKey].categoryTree;
// If categoryId is a string (SEO name), find by seoName, otherwise by ID
const category = typeof categoryId === 'string'
? this.findCategoryBySeoName(window.productCache["categoryTree_209"].categoryTree, categoryId)
: this.findCategoryById(window.productCache["categoryTree_209"].categoryTree, categoryId);
? this.findCategoryBySeoName(categoryTree, categoryId)
: this.findCategoryById(categoryTree, categoryId);
return category ? category.name : null;
}