ShippingProfileService
Provides layer to manipulate profiles.
Implements
Constructors
constructor
**new ShippingProfileService**(«destructured»)
Parameters
Properties
__configModule__Record<string, unknown>__container__anyRequired__moduleDeclaration__Record<string, unknown>manager_EntityManagerRequiredproductRepository_Repository<Product> & { _applyCategoriesQuery: Method \_applyCategoriesQuery ; _findWithRelations: Method \_findWithRelations ; bulkAddToCollection: Method bulkAddToCollection ; bulkRemoveFromCollection: Method bulkRemoveFromCollection ; findOneWithRelations: Method findOneWithRelations ; findWithRelations: Method findWithRelations ; findWithRelationsAndCount: Method findWithRelationsAndCount ; getCategoryIdsFromInput: Method getCategoryIdsFromInput ; getCategoryIdsRecursively: Method getCategoryIdsRecursively ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; isProductInSalesChannels: Method isProductInSalesChannels ; queryProducts: Method queryProducts ; queryProductsWithIds: Method queryProductsWithIds }RequiredshippingProfileRepository_Repository<ShippingProfile> & { findByProducts: Method findByProducts }RequiredtransactionManager_undefined | EntityManagerRequiredAccessors
activeManager_
Protected get**activeManager_**(): EntityManager
Returns
EntityManager
EntityManagerEntityManagerRequiredMethods
addProduct
**addProduct**(profileId, productId): Promise<[ShippingProfile](/references/services/classes/ShippingProfile)>
Parameters
profileIdstringRequiredproductIdstring | string[]RequiredReturns
Promise<ShippingProfile>
Deprecated
use addProducts instead
addProducts
**addProducts**(profileId, productId): Promise<[ShippingProfile](/references/services/classes/ShippingProfile)>
Adds a product or an array of products to the profile.
Parameters
profileIdstringRequiredproductIdstring | string[]RequiredReturns
Promise<ShippingProfile>
addShippingOption
**addShippingOption**(profileId, optionId): Promise<[ShippingProfile](/references/services/classes/ShippingProfile)>
Adds a shipping option to the profile. The shipping option can be used to fulfill the products in the products field.
Parameters
profileIdstringRequiredoptionIdstring | string[]RequiredReturns
Promise<ShippingProfile>
atomicPhase_
Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
TResultobjectRequiredTErrorobjectRequiredParameters
work(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
PromisePromise<TResult>Requiredcreate
**create**(profile): Promise<[ShippingProfile](/references/services/classes/ShippingProfile)>
Creates a new shipping profile.
Parameters
Returns
Promise<ShippingProfile>
createDefault
**createDefault**(): Promise<[ShippingProfile](/references/services/classes/ShippingProfile)>
Creates a default shipping profile, if this does not already exist.
Returns
Promise<ShippingProfile>
createGiftCardDefault
**createGiftCardDefault**(): Promise<[ShippingProfile](/references/services/classes/ShippingProfile)>
Creates a default shipping profile, for gift cards if unless it already exists.
Returns
Promise<ShippingProfile>
delete
**delete**(profileId): Promise<void>
Deletes a profile with a given profile id.
Parameters
profileIdstringRequiredReturns
Promise<void>
PromisePromise<void>RequiredfetchCartOptions
**fetchCartOptions**(cart): Promise<[ShippingOption](/references/services/classes/ShippingOption)[]>
Finds all the shipping profiles that cover the products in a cart, and validates all options that are available for the cart.
Parameters
cartanyRequiredReturns
Promise<ShippingOption[]>
getMapProfileIdsByProductIds
**getMapProfileIdsByProductIds**(productIds): Promise<Map<string, string>>
Parameters
productIdsstring[]RequiredReturns
Promise<Map<string, string>>
PromisePromise<Map<string, string>>RequiredgetProfilesInCart
Protected **getProfilesInCart**(cart): Promise<string[]>
Returns a list of all the productIds in the cart.
Parameters
Returns
Promise<string[]>
PromisePromise<string[]>Requiredlist
**list**(selector?, config?): Promise<[ShippingProfile](/references/services/classes/ShippingProfile)[]>
Parameters
Default: {}
Returns
Promise<ShippingProfile[]>
removeProducts
**removeProducts**(profileId, productId): Promise<void \| [ShippingProfile](/references/services/classes/ShippingProfile)>
Removes a product or an array of products from the profile.
Parameters
profileIdnull | stringRequiredproductIdstring | string[]RequiredReturns
Promise<void | ShippingProfile>
retrieve
**retrieve**(profileId, options?): Promise<[ShippingProfile](/references/services/classes/ShippingProfile)>
Gets a profile by id. Throws in case of DB Error and if profile was not found.
Parameters
profileIdstringRequiredDefault: {}
Returns
Promise<ShippingProfile>
retrieveDefault
**retrieveDefault**(): Promise<null \| [ShippingProfile](/references/services/classes/ShippingProfile)>
Returns
Promise<null | ShippingProfile>
retrieveForProducts
**retrieveForProducts**(productIds): Promise<{ [product_id: string]: [ShippingProfile](/references/services/classes/ShippingProfile)[]; }>
Parameters
productIdsstring | string[]RequiredReturns
Promise<{ [product_id: string]: ShippingProfile[]; }>
retrieveGiftCardDefault
**retrieveGiftCardDefault**(): Promise<null \| [ShippingProfile](/references/services/classes/ShippingProfile)>
Retrieves the default gift card profile
Returns
Promise<null | ShippingProfile>
shouldRetryTransaction_
Protected **shouldRetryTransaction_**(err): boolean
Parameters
errRecord<string, unknown> | { code: string }RequiredReturns
boolean
booleanbooleanupdate
**update**(profileId, update): Promise<[ShippingProfile](/references/services/classes/ShippingProfile)>
Updates a profile. Metadata updates and product updates should use
dedicated methods, e.g. setMetadata, addProduct, etc. The function
will throw errors if metadata or product updates are attempted.
Parameters
profileIdstringRequiredReturns
Promise<ShippingProfile>
withTransaction
**withTransaction**(transactionManager?): [ShippingProfileService](/references/services/classes/ShippingProfileService)
Parameters
transactionManagerEntityManager