Skip to content

Commit

Permalink
fix: improved media handing
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikZed committed Oct 23, 2023
1 parent 16dfa8e commit e56a89e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/integration-saleor-entities/src/products/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,14 @@ export class SaleorProductSyncService {

let saleorProductId = product.saleorProducts?.[0]?.id;

/**
* Media files from our DB - product videos are not uploaded,
* but just set as youtube URLs. We filter out type PRODUCTVIDEO and MANUAL
*/
const schemabaseMedia = product.media.filter(
(m) => m.type !== "PRODUCTVIDEO" && m.type !== "MANUAL",
);

if (!saleorProductId) {
this.logger.info(
`Creating product ${product.name} in Saleor`,
Expand Down Expand Up @@ -1040,13 +1048,8 @@ export class SaleorProductSyncService {
updatedAt: product.updatedAt,
},
});
/**
* Media files we need to upload - product videos are not uploaded,
* but just set as youtube URLs. We filter out type PRODUCTVIDEO and MANUAL
*/
const mediaToUpload = product.media.filter(
(m) => m.type !== "PRODUCTVIDEO" && m.type !== "MANUAL",
);

const mediaToUpload = schemabaseMedia;

if (mediaToUpload.length > 0) {
await this.uploadMedia(saleorProductId, mediaToUpload);
Expand Down Expand Up @@ -1096,7 +1099,6 @@ export class SaleorProductSyncService {
// our internal media id or null
const saleorMedia =
productUpdateResponse.productUpdate.product.media || [];
const schemabaseMedia = product.media;

const filteredMedia = saleorMedia?.filter(
(m) => m.metafield !== null || undefined,
Expand Down

1 comment on commit e56a89e

@vercel
Copy link

@vercel vercel bot commented on e56a89e Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.