feat: add Hersteller page with manufacturer data fetching and SEO support
This commit is contained in:
@@ -140,6 +140,38 @@ const fetchCategoryImage = (socket, categoryId) => {
|
||||
});
|
||||
};
|
||||
|
||||
const fetchManufacturers = (socket) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
reject(new Error("Timeout fetching manufacturers"));
|
||||
}, 10000);
|
||||
|
||||
socket.emit("getHerstellerImages", {}, (response) => {
|
||||
clearTimeout(timeout);
|
||||
if (response?.success && Array.isArray(response.manufacturers)) {
|
||||
// Filter and format manufacturers similar to HerstellerPage.js
|
||||
const manufacturers = response.manufacturers
|
||||
.filter(m => m.imageBuffer)
|
||||
.map(m => ({
|
||||
id: m.id,
|
||||
name: m.name || '',
|
||||
slug: m.slug || '',
|
||||
imageBuffer: m.imageBuffer,
|
||||
}))
|
||||
.sort((a, b) => (a.name || '').localeCompare(b.name || '', undefined, { sensitivity: 'base' }));
|
||||
|
||||
resolve(manufacturers);
|
||||
} else {
|
||||
reject(
|
||||
new Error(
|
||||
`Invalid manufacturers response: ${JSON.stringify(response)}`
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const saveProductImages = async (socket, products, categoryName, outputDir) => {
|
||||
if (!products || products.length === 0) return;
|
||||
|
||||
@@ -383,6 +415,7 @@ module.exports = {
|
||||
fetchProductDetails,
|
||||
fetchProductImage,
|
||||
fetchCategoryImage,
|
||||
fetchManufacturers,
|
||||
saveProductImages,
|
||||
saveCategoryImages,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user