From b5a78b33cb5e9ca5f5db198ef66d78dea3b8724f Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Wed, 23 Jul 2025 09:46:54 +0200 Subject: [PATCH] u --- src/components/Content.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/components/Content.js b/src/components/Content.js index 61b94d2..d0e3090 100644 --- a/src/components/Content.js +++ b/src/components/Content.js @@ -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; }