- piuchebuono: possiblità di modificare l'immagine dalla scheda direttamente

- migliorata di poco la grafica dell'immagine.
This commit is contained in:
Surya Paolo
2024-10-02 23:22:44 +02:00
parent 03e5d2ed81
commit f9e0175f9b
20 changed files with 108 additions and 42 deletions

View File

@@ -63,9 +63,9 @@ async function downloadImgIfMissing(productInfo) {
const img = 'upload/products/' + productInfo.image_link.split('/').pop();
const savePath = path.resolve(__dirname, img); // Sostituisci con il percorso dove salvare l'immagine
if (!productInfo.img || !fs.existsSync(savePath)) {
if (!productInfo.imagefile || !fs.existsSync(savePath)) {
// Download image from the URL productInfo.image_link
productInfo.img = img;
productInfo.imagefile = img;
const downloader = new ImageDownloader();
@@ -131,13 +131,13 @@ async function completaSettaggioProduct_AndProductInfo(arrcampi_productInfo, arr
}
if (!rec.hasOwnProperty('img') && product.code) {
productInfo.img = 'upload/products/' + product.code + '.jpg';
productInfo.imagefile = 'upload/products/' + product.code + '.jpg';
} else {
if (rec.hasOwnProperty('img')) {
if (rec['img']) {
productInfo.img = 'upload/products/' + rec['img'];
productInfo.imagefile = 'upload/products/' + rec['img'];
} else {
productInfo.img = '';
productInfo.imagefile = '';
}
}
}
@@ -1042,6 +1042,10 @@ router.post('/import', authenticate, async (req, res) => {
product.active = true;
}
if (productInfo.productTypes.length === 1 && productInfo.productTypes[0] === undefined) {
productInfo.productTypes = [shared_consts.PRODUCTTYPE.PRODUCT];
}
let esisteindb = await ProductInfo.findOne({ code: productInfo.code }).lean();
// Update ProductInfo