u
This commit is contained in:
@@ -259,19 +259,15 @@ class Content extends Component {
|
|||||||
|
|
||||||
|
|
||||||
fetchCategoryData(categoryId) {
|
fetchCategoryData(categoryId) {
|
||||||
// Simply check if we have any category tree data in window.productCache
|
// Direct check for the specific cache key mentioned in the requirement
|
||||||
const hasCategoryTree = window.productCache &&
|
const hasCategoryTree = window.productCache && window.productCache["categoryTree_209"];
|
||||||
Object.keys(window.productCache).some(key =>
|
|
||||||
key.startsWith("categoryTree_209") &&
|
|
||||||
window.productCache[key] &&
|
|
||||||
window.productCache[key].categoryTree);
|
|
||||||
|
|
||||||
// Check for specific category data in cache
|
// Check for specific category data in cache
|
||||||
const cachedData = getCachedCategoryData(categoryId);
|
const cachedData = getCachedCategoryData(categoryId);
|
||||||
|
|
||||||
// If we have the category tree data, use it and don't query socket.io
|
// If we have the category tree data, use it and don't query socket.io
|
||||||
if (hasCategoryTree) {
|
if (hasCategoryTree) {
|
||||||
console.log("Found category tree in cache");
|
console.log("Found categoryTree_209 in cache");
|
||||||
|
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
console.log("Using cached category data for", categoryId);
|
console.log("Using cached category data for", categoryId);
|
||||||
@@ -414,22 +410,12 @@ class Content extends Component {
|
|||||||
|
|
||||||
// Helper function to get category name from tree
|
// Helper function to get category name from tree
|
||||||
getCategoryNameFromTree = (categoryId) => {
|
getCategoryNameFromTree = (categoryId) => {
|
||||||
if (!window.productCache) {
|
if (!window.productCache || !window.productCache["categoryTree_209"] ||
|
||||||
|
!window.productCache["categoryTree_209"].categoryTree) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the first available category tree
|
const categoryTree = window.productCache["categoryTree_209"].categoryTree;
|
||||||
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
|
// If categoryId is a string (SEO name), find by seoName, otherwise by ID
|
||||||
const category = typeof categoryId === 'string'
|
const category = typeof categoryId === 'string'
|
||||||
|
|||||||
Reference in New Issue
Block a user