- Sistemato link pdf che ogni volta che si aggiorna prendeva il PDF dalla cache...
- Raccolta Cataloghi, procedura che li AUTO genera in automatico.
This commit is contained in:
@@ -436,7 +436,6 @@ class Macro {
|
||||
console.log('numrec', numrec);
|
||||
}
|
||||
|
||||
|
||||
let rimuoviTabellePerIniziare = false;
|
||||
|
||||
let count = 0;
|
||||
@@ -467,16 +466,16 @@ class Macro {
|
||||
.filter(([isbn, products]) => products.length > 1)
|
||||
.map(([isbn]) => isbn);
|
||||
|
||||
recproducts = recproducts.filter(product => isbnConMultipliRecord.includes(product.Ean13));
|
||||
recproducts = recproducts.filter((product) => isbnConMultipliRecord.includes(product.Ean13));
|
||||
|
||||
console.log(`Trovati ${isbnConMultipliRecord.length} record con ISBN duplicati: ${isbnConMultipliRecord.join(', ')}`);
|
||||
|
||||
console.log(
|
||||
`Trovati ${isbnConMultipliRecord.length} record con ISBN duplicati: ${isbnConMultipliRecord.join(', ')}`
|
||||
);
|
||||
}
|
||||
|
||||
for (const recproduct of recproducts) {
|
||||
await this.elaboraProdotto(recproduct, opt);
|
||||
|
||||
|
||||
const sku = recproduct.IdArticolo;
|
||||
|
||||
if (sku) {
|
||||
@@ -859,44 +858,52 @@ class Macro {
|
||||
* Gestisce le categorie e sottocategorie del prodotto.
|
||||
*/
|
||||
async gestisciCategorie(productInfo, product) {
|
||||
if (product.DescrArgomento) {
|
||||
productInfo.idCatProds = [];
|
||||
const reccateg = await CatProd.findOne({ idapp: this.idapp, name: product.DescrArgomento });
|
||||
let nuovaCategoria = null;
|
||||
if (!reccateg) {
|
||||
nuovaCategoria = new CatProd({ idapp: this.idapp, name: product.DescrArgomento });
|
||||
await nuovaCategoria.save();
|
||||
}
|
||||
|
||||
if (!reccateg.idArgomento) {
|
||||
// Se non c'è l'argomento, allora lo cerco nel DB
|
||||
const recarg = await T_Web_Argomenti.findOne({ Descrizione: product.DescrArgomento }).lean();
|
||||
reccateg.idArgomento = recarg.IdArgomento;
|
||||
await reccateg.save();
|
||||
}
|
||||
|
||||
const myriscat = reccateg?._id || (nuovaCategoria ? nuovaCategoria._id : null);
|
||||
if (myriscat) productInfo.idCatProds.push(myriscat);
|
||||
} else {
|
||||
if (product.categories) {
|
||||
// const arrcat = product.categories.trim().split(',');
|
||||
const arrcat = product.categories.trim().split(',');
|
||||
try {
|
||||
if (product.DescrArgomento) {
|
||||
productInfo.idCatProds = [];
|
||||
const reccateg = await CatProd.findOne({ idapp: this.idapp, name: product.DescrArgomento });
|
||||
let nuovaCategoria = null;
|
||||
if (!reccateg) {
|
||||
nuovaCategoria = new CatProd({ idapp: this.idapp, name: product.DescrArgomento });
|
||||
await nuovaCategoria.save();
|
||||
}
|
||||
|
||||
for (const mycat of arrcat) {
|
||||
const mycatstr = mycat.trim();
|
||||
const reccateg = await CatProd.findOne({ idapp: this.idapp, name: mycatstr }).lean();
|
||||
|
||||
let nuovaCategoria = null;
|
||||
if (!reccateg) {
|
||||
nuovaCategoria = new CatProd({ idapp: this.idapp, name: mycatstr });
|
||||
await nuovaCategoria.save();
|
||||
|
||||
if (!reccateg?.idArgomento && product.DescrArgomento) {
|
||||
// Se non c'è l'argomento, allora lo cerco nel DB
|
||||
const recarg = await T_Web_Argomenti.findOne({ Descrizione: product.DescrArgomento }).lean();
|
||||
if (recarg) {
|
||||
reccateg.idArgomento = recarg.IdArgomento;
|
||||
await reccateg.save();
|
||||
}
|
||||
}
|
||||
|
||||
const myriscat = reccateg?._id || (nuovaCategoria ? nuovaCategoria._id : null);
|
||||
if (myriscat) productInfo.idCatProds.push(myriscat);
|
||||
|
||||
const myriscat = reccateg?._id || (nuovaCategoria ? nuovaCategoria._id : null);
|
||||
if (myriscat) productInfo.idCatProds.push(myriscat);
|
||||
} else {
|
||||
if (product.categories) {
|
||||
// const arrcat = product.categories.trim().split(',');
|
||||
const arrcat = product.categories.trim().split(',');
|
||||
productInfo.idCatProds = [];
|
||||
|
||||
for (const mycat of arrcat) {
|
||||
const mycatstr = mycat.trim();
|
||||
const reccateg = await CatProd.findOne({ idapp: this.idapp, name: mycatstr }).lean();
|
||||
|
||||
let nuovaCategoria = null;
|
||||
if (!reccateg) {
|
||||
nuovaCategoria = new CatProd({ idapp: this.idapp, name: mycatstr });
|
||||
await nuovaCategoria.save();
|
||||
}
|
||||
|
||||
const myriscat = reccateg?._id || (nuovaCategoria ? nuovaCategoria._id : null);
|
||||
if (myriscat) productInfo.idCatProds.push(myriscat);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Errore gestisciCategorie:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user