- le categorie visibili solo se ci sono prodotti attivi

This commit is contained in:
Surya Paolo
2024-03-03 14:38:25 +01:00
parent 789e3fde41
commit b5dbaafa91

View File

@@ -580,23 +580,46 @@ module.exports.convertAfterImportALLPROD = async function (idapp, dataObjects) {
module.exports.getArrCatProds = async function (idapp, cosa) {
try {
let addquery = {};
let addquery = [];
let arr = [];
if (cosa === shared_consts.PROD.GAS) {
addquery = { idapp, idGasordine: { $exists: true, $ne: null, $type: 'objectId' } }
addquery = [
{ $match: { idapp, idGasordine: { $exists: true, $ne: null, $type: 'objectId' } } }
];
addquery.push(
{
$lookup: {
from: 'gasordines',
localField: 'idGasordine',
foreignField: '_id',
as: 'gasordine'
}
}
);
addquery.push(
{
$match: {
"gasordine.active": true
}
}
);
} else if (cosa === shared_consts.PROD.BOTTEGA) {
addquery = {
addquery = [{
$match: {
idapp, $or: [
{ idGasordine: { $exists: false } },
{ idGasordine: { $exists: true, $eq: null } }
]
}
}]
} else {
addquery = { idapp };
addquery = [{ $match: { idapp } }];
}
let myquery = [
{ $match: addquery },
let myquery = [...addquery,
{
$lookup: {
from: "productinfos",