ShippingProfileService
internal.internal.ShippingProfileService
Provides layer to manipulate profiles.
Implements
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
EntityManager
EntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
addProduct
addProduct(profileId
, productId
): Promise
<ShippingProfile
>
Parameters
profileId
stringRequiredproductId
string | string[]RequiredReturns
Promise
<ShippingProfile
>
Deprecated
use addProducts instead
addProducts
addProducts(profileId
, productId
): Promise
<ShippingProfile
>
Adds a product or an array of products to the profile.
Parameters
profileId
stringRequiredproductId
string | string[]RequiredReturns
Promise
<ShippingProfile
>
the result of update
addShippingOption
addShippingOption(profileId
, optionId
): Promise
<ShippingProfile
>
Adds a shipping option to the profile. The shipping option can be used to fulfill the products in the products field.
Parameters
profileId
stringRequiredoptionId
string | string[]RequiredReturns
Promise
<ShippingProfile
>
the result of the model update operation
atomicPhase_
Protected
atomicPhase_<TResult
, 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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
<TResult
>
Promise
Promise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
create
create(profile
): Promise
<ShippingProfile
>
Creates a new shipping profile.
Parameters
Returns
Promise
<ShippingProfile
>
the result of the create operation
createDefault
createDefault(): Promise
<ShippingProfile
>
Creates a default shipping profile, if this does not already exist.
Returns
Promise
<ShippingProfile
>
the shipping profile
createGiftCardDefault
createGiftCardDefault(): Promise
<ShippingProfile
>
Creates a default shipping profile, for gift cards if unless it already exists.
Returns
Promise
<ShippingProfile
>
the shipping profile
delete
delete(profileId
): Promise
<void
>
Deletes a profile with a given profile id.
Parameters
profileId
stringRequiredReturns
Promise
<void
>
Promise
Promise<void>RequiredfetchCartOptions
fetchCartOptions(cart
): Promise
<ShippingOption
[]>
Finds all the shipping profiles that cover the products in a cart, and validates all options that are available for the cart.
Parameters
cart
anyRequiredReturns
Promise
<ShippingOption
[]>
a list of the available shipping options
getMapProfileIdsByProductIds
getMapProfileIdsByProductIds(productIds
): Promise
<Map
<string
, string
>>
Parameters
productIds
string[]RequiredReturns
Promise
<Map
<string
, string
>>
Promise
Promise<Map<string, string>>Required
Promise
Promise<Map<string, string>>RequiredgetProfilesInCart
Protected
getProfilesInCart(cart
): Promise
<string
[]>
Returns a list of all the productIds in the cart.
Parameters
Returns
Promise
<string
[]>
Promise
Promise<string[]>Requireda list of product ids
Promise
Promise<string[]>Requiredlist
list(selector?
, config?
): Promise
<ShippingProfile
[]>
Parameters
selector
Selector<ShippingProfile>config
FindConfig<ShippingProfile>Returns
Promise
<ShippingProfile
[]>
the result of the find operation
removeProducts
removeProducts(profileId
, productId
): Promise
<void
| ShippingProfile
>
Removes a product or an array of products from the profile.
Parameters
profileId
null | stringRequiredproductId
string | string[]RequiredReturns
Promise
<void
| ShippingProfile
>
the result of update
retrieve
retrieve(profileId
, options?
): Promise
<ShippingProfile
>
Gets a profile by id. Throws in case of DB Error and if profile was not found.
Parameters
profileId
stringRequiredoptions
FindConfig<ShippingProfile>Returns
Promise
<ShippingProfile
>
the profile document.
retrieveDefault
retrieveDefault(): Promise
<null
| ShippingProfile
>
Returns
Promise
<null
| ShippingProfile
>
retrieveForProducts
retrieveForProducts(productIds
): Promise
<{ [product_id: string]
: ShippingProfile
[]; }>
Parameters
productIds
string | string[]RequiredReturns
Promise
<{ [product_id: string]
: ShippingProfile
[]; }>
retrieveGiftCardDefault
retrieveGiftCardDefault(): Promise
<null
| ShippingProfile
>
Retrieves the default gift card profile
Returns
Promise
<null
| ShippingProfile
>
the shipping profile for gift cards
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanInherited from
TransactionBaseService.shouldRetryTransaction_
update
update(profileId
, update
): Promise
<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
profileId
stringRequiredReturns
Promise
<ShippingProfile
>
resolves to the update result.
withTransaction
withTransaction(transactionManager?
): ShippingProfileService
Parameters
transactionManager
EntityManager