CollectionService
CollectionService
Contains methods relating to Collection entities.
Signature
class CollectionService implements OnModuleInit {
constructor(connection: TransactionalConnection, channelService: ChannelService, assetService: AssetService, facetValueService: FacetValueService, listQueryBuilder: ListQueryBuilder, translatableSaver: TranslatableSaver, eventBus: EventBus, jobQueueService: JobQueueService, configService: ConfigService, slugValidator: SlugValidator, configArgService: ConfigArgService, customFieldRelationService: CustomFieldRelationService, translator: TranslatorService, roleService: RoleService)
async findAll(ctx: RequestContext, options?: ListQueryOptions<Collection> & { topLevelOnly?: boolean }, relations?: RelationPaths<Collection>) => Promise<PaginatedList<Translated<Collection>>>;
async findOne(ctx: RequestContext, collectionId: ID, relations?: RelationPaths<Collection>) => Promise<Translated<Collection> | undefined>;
async findByIds(ctx: RequestContext, ids: ID[], relations?: RelationPaths<Collection>) => Promise<Array<Translated<Collection>>>;
async findOneBySlug(ctx: RequestContext, slug: string, relations?: RelationPaths<Collection>) => Promise<Translated<Collection> | undefined>;
getAvailableFilters(ctx: RequestContext) => ConfigurableOperationDefinition[];
async getParent(ctx: RequestContext, collectionId: ID) => Promise<Collection | undefined>;
async getChildren(ctx: RequestContext, collectionId: ID) => Promise<Collection[]>;
async getBreadcrumbs(ctx: RequestContext, collection: Collection) => Promise<Array<{ name: string; id: ID }>>;
async getCollectionsByProductId(ctx: RequestContext, productId: ID, publicOnly: boolean) => Promise<Array<Translated<Collection>>>;
async getDescendants(ctx: RequestContext, rootId: ID, maxDepth: number = Number.MAX_SAFE_INTEGER) => Promise<Array<Translated<Collection>>>;
getAncestors(collectionId: ID) => Promise<Collection[]>;
getAncestors(collectionId: ID, ctx: RequestContext) => Promise<Array<Translated<Collection>>>;
async getAncestors(collectionId: ID, ctx?: RequestContext) => Promise<Array<Translated<Collection> | Collection>>;
async previewCollectionVariants(ctx: RequestContext, input: PreviewCollectionVariantsInput, options?: ListQueryOptions<ProductVariant>, relations?: RelationPaths<Collection>) => Promise<PaginatedList<ProductVariant>>;
async create(ctx: RequestContext, input: CreateCollectionInput) => Promise<Translated<Collection>>;
async update(ctx: RequestContext, input: UpdateCollectionInput) => Promise<Translated<Collection>>;
async delete(ctx: RequestContext, id: ID) => Promise<DeletionResponse>;
async move(ctx: RequestContext, input: MoveCollectionInput) => Promise<Translated<Collection>>;
async getCollectionProductVariantIds(collection: Collection, ctx?: RequestContext) => Promise<ID[]>;
async assignCollectionsToChannel(ctx: RequestContext, input: AssignCollectionsToChannelInput) => Promise<Array<Translated<Collection>>>;
async removeCollectionsFromChannel(ctx: RequestContext, input: RemoveCollectionsFromChannelInput) => Promise<Array<Translated<Collection>>>;
}
Implements
- OnModuleInit
Members
constructor
method
type:
(connection: TransactionalConnection, channelService: ChannelService, assetService: AssetService, facetValueService: FacetValueService, listQueryBuilder: ListQueryBuilder, translatableSaver: TranslatableSaver, eventBus: EventBus, jobQueueService: JobQueueService, configService: ConfigService, slugValidator: SlugValidator, configArgService: ConfigArgService, customFieldRelationService: CustomFieldRelationService, translator: TranslatorService, roleService: RoleService) => CollectionService
findAll
method
type:
(ctx: RequestContext, options?: ListQueryOptions<Collection> & { topLevelOnly?: boolean }, relations?: RelationPaths<Collection>) => Promise<PaginatedList<Translated<Collection>>>
findOne
method
type:
(ctx: RequestContext, collectionId: ID, relations?: RelationPaths<Collection>) => Promise<Translated<Collection> | undefined>
findByIds
method
type:
(ctx: RequestContext, ids: ID[], relations?: RelationPaths<Collection>) => Promise<Array<Translated<Collection>>>
findOneBySlug
method
type:
(ctx: RequestContext, slug: string, relations?: RelationPaths<Collection>) => Promise<Translated<Collection> | undefined>
getAvailableFilters
method
type:
(ctx: RequestContext) => ConfigurableOperationDefinition[]
Returns all configured CollectionFilters, as specified by the CatalogOptions.
getParent
method
type:
(ctx: RequestContext, collectionId: ID) => Promise<Collection | undefined>
getChildren
method
type:
(ctx: RequestContext, collectionId: ID) => Promise<Collection[]>
Returns all child Collections of the Collection with the given id.
getBreadcrumbs
method
type:
(ctx: RequestContext, collection: Collection) => Promise<Array<{ name: string; id: ID }>>
Returns an array of name/id pairs representing all ancestor Collections up
to the Root Collection.
getCollectionsByProductId
method
type:
(ctx: RequestContext, productId: ID, publicOnly: boolean) => Promise<Array<Translated<Collection>>>
Returns all Collections which are associated with the given Product ID.
getDescendants
method
type:
(ctx: RequestContext, rootId: ID, maxDepth: number = Number.MAX_SAFE_INTEGER) => Promise<Array<Translated<Collection>>>
Returns the descendants of a Collection as a flat array. The depth of the traversal can be limited
with the maxDepth argument. So to get only the immediate children, set maxDepth = 1.
getAncestors
method
type:
(collectionId: ID) => Promise<Collection[]>
Gets the ancestors of a given collection. Note that since ProductCategories are implemented as an adjacency list, this method
will produce more queries the deeper the collection is in the tree.
getAncestors
method
type:
(collectionId: ID, ctx: RequestContext) => Promise<Array<Translated<Collection>>>
getAncestors
method
type:
(collectionId: ID, ctx?: RequestContext) => Promise<Array<Translated<Collection> | Collection>>
previewCollectionVariants
method
type:
(ctx: RequestContext, input: PreviewCollectionVariantsInput, options?: ListQueryOptions<ProductVariant>, relations?: RelationPaths<Collection>) => Promise<PaginatedList<ProductVariant>>
create
method
type:
(ctx: RequestContext, input: CreateCollectionInput) => Promise<Translated<Collection>>
update
method
type:
(ctx: RequestContext, input: UpdateCollectionInput) => Promise<Translated<Collection>>
delete
method
type:
(ctx: RequestContext, id: ID) => Promise<DeletionResponse>
move
method
type:
(ctx: RequestContext, input: MoveCollectionInput) => Promise<Translated<Collection>>
Moves a Collection by specifying the parent Collection ID, and an index representing the order amongst
its siblings.
getCollectionProductVariantIds
method
type:
(collection: Collection, ctx?: RequestContext) => Promise<ID[]>
assignCollectionsToChannel
method
type:
(ctx: RequestContext, input: AssignCollectionsToChannelInput) => Promise<Array<Translated<Collection>>>
Assigns Collections to the specified Channel
removeCollectionsFromChannel
method
type:
(ctx: RequestContext, input: RemoveCollectionsFromChannelInput) => Promise<Array<Translated<Collection>>>
Remove Collections from the specified Channel