Product service

Constructors

Methods

  • Run a series of updates on multiple products. Updates will be performed using the bulkWrite method.

    Parameters

    • bulkUpdateList: {
          data: Partial<Partial<Omit<CreateProductDto, "variants"> & {
              variants: Partial<Partial<ProductVariantBasicInfo & WithPartialPriceField & {
                  imageIds?: string[];
              }> & {
                  id: string;
              }>[];
          }>>;
          ids: string[];
      }[]

      TODO: Add transaction support in the future

    Returns Promise<number>

  • Check that all products are belonging to the org

    Parameters

    • productIds: string[]
    • orgId: string

    Returns Promise<boolean>

    true if all products belongs to the org

  • Get product from database. Optionally, you can pass forOrganizationId to filter products by organizationId.

    Parameters

    • id: string
    • Optional forOrganizationId: string

    Returns Promise<null | ProductEntity>

    Promise<Product | undefined> Product data if fetched successfully, or null if data not found by id

  • Type guard to check if the products have been processed by the $apply param

    TODO: This method is a workaround for the current implementation of the $apply param, and isn't ideal. I think we should just not support $expand on $apply, but we need to provide backwards compatibility for existing clients on the list products endpoints. In future, let's remove this method and encourage customers to either use two queries or make their own custom endpoint.

    Parameters

    • products: unknown[]
    • Optional applyExpression: ApplyExpression

    Returns products is {
        _id: string;
        top?: ProductResponse[];
    }[]

  • List paginated products. This also supports extra filters:

    • mustBePublishedToday: only return products that are published at the current date
    • searchKeyword: search keyword to filter products

    Parameters

    • opts: ParsedPaginatedListQuery

      paginated list query options

    • Optional extraFilters: {
          mustBePublishedToday?: boolean;
          organizationId?: string;
          productIds?: string[];
          searchKeyword?: string;
      }

      additional filters for certain endpoints

      • Optional mustBePublishedToday?: boolean
      • Optional organizationId?: string
      • Optional productIds?: string[]
      • Optional searchKeyword?: string
    • Optional logger: Logger

    Returns Promise<PaginatedFindResult<ProductEntity>>

    paginated product list query result

Properties

attachmentService: AttachmentDefaultService
db: Db
expandPipelineService: ProductExpandPipelineDataService
organizationAPI: OrganizationDefaultAdapterAPI
organizationEndpoint: string
productRepository: MongoRepository<ProductEntity>
COLLECTION_PRODUCT: "products" = 'products'
DEFAULT_PUBLICATION_STATUS: "DRAFT" = CATALOG_PUBLICATION_STATUS_DRAFT

Generated using TypeDoc