Skip to content

Commit

Permalink
feat: we also look for variant with updates
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikZed committed Oct 16, 2024
1 parent 1e1d5c8 commit b88a328
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/integration-saleor-entities/src/products/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1340,11 +1340,40 @@ export class SaleorProductSyncService {
`Received ${updatedItemsDatabase.length} items to update`,
);

/**
* get all products with variants that need to be updated
*/
const updatedVariants = await this.db.product.findMany({
where: {
id: {
notIn: [
...itemsToCreate.map((x) => x.id),
...itemsWithMissingVariants.map((x) => x.id),
...itemsWithMissingMedia.map((x) => x.id),
...updatedItemsDatabase.map((x) => x.id),
],
},
variants: {
some: {
updatedAt: {
gte: gteDate,
},
},
},
},
include: productInclude,
});

this.logger.debug(
`Received ${updatedVariants.length} items with variants to update`,
);

const unsortedProductsToCreateOrUpdate = [
...itemsToCreate,
...updatedItemsDatabase,
...itemsWithMissingVariants,
...itemsWithMissingMedia,
...updatedVariants,
];

const productsToCreate = unsortedProductsToCreateOrUpdate.filter(
Expand Down

0 comments on commit b88a328

Please sign in to comment.