CollectionService
CollectionService
Contains methods relating to Collection entities.
class CollectionService implements OnModuleInit {
constructor(connection: TransactionalConnection, channelService: ChannelService, assetService: AssetService, listQueryBuilder: ListQueryBuilder, translatableSaver: TranslatableSaver, eventBus: EventBus, jobQueueService: JobQueueService, configService: ConfigService, slugValidator: SlugValidator, configArgService: ConfigArgService, customFieldRelationService: CustomFieldRelationService, translator: TranslatorService, roleService: RoleService)
findAll(ctx: RequestContext, options?: ListQueryOptions<Collection> & { topLevelOnly?: boolean }, relations?: RelationPaths<Collection>) => Promise<PaginatedList<Translated<Collection>>>;
findOne(ctx: RequestContext, collectionId: ID, relations?: RelationPaths<Collection>) => Promise<Translated<Collection> | undefined>;
findByIds(ctx: RequestContext, ids: ID[], relations?: RelationPaths<Collection>) => Promise<Array<Translated<Collection>>>;
findOneBySlug(ctx: RequestContext, slug: string, relations?: RelationPaths<Collection>) => Promise<Translated<Collection> | undefined>;
getAvailableFilters(ctx: RequestContext) => ConfigurableOperationDefinition[];
getParent(ctx: RequestContext, collectionId: ID) => Promise<Collection | undefined>;
getChildren(ctx: RequestContext, collectionId: ID) => Promise<Collection[]>;
getBreadcrumbs(ctx: RequestContext, collection: Collection) => Promise<Array<{ name: string; id: ID, slug: string }>>;
getCollectionsByProductId(ctx: RequestContext, productId: ID, publicOnly: boolean) => Promise<Array<Translated<Collection>>>;
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>>>;
getAncestors(collectionId: ID, ctx?: RequestContext) => Promise<Array<Translated<Collection> | Collection>>;
previewCollectionVariants(ctx: RequestContext, input: PreviewCollectionVariantsInput, options?: ListQueryOptions<ProductVariant>, relations?: RelationPaths<Collection>) => Promise<PaginatedList<ProductVariant>>;
create(ctx: RequestContext, input: CreateCollectionInput) => Promise<Translated<Collection>>;
update(ctx: RequestContext, input: UpdateCollectionInput) => Promise<Translated<Collection>>;
delete(ctx: RequestContext, id: ID) => Promise<DeletionResponse>;
move(ctx: RequestContext, input: MoveCollectionInput) => Promise<Translated<Collection>>;
getCollectionProductVariantIds(collection: Collection, ctx?: RequestContext) => Promise<ID[]>;
assignCollectionsToChannel(ctx: RequestContext, input: AssignCollectionsToChannelInput) => Promise<Array<Translated<Collection>>>;
removeCollectionsFromChannel(ctx: RequestContext, input: RemoveCollectionsFromChannelInput) => Promise<Array<Translated<Collection>>>;
}
- Implements:
OnModuleInit
constructor
(connection: TransactionalConnection, channelService: ChannelService, assetService: AssetService, listQueryBuilder: ListQueryBuilder, translatableSaver: TranslatableSaver, eventBus: EventBus, jobQueueService: JobQueueService, configService: ConfigService, slugValidator: SlugValidator, configArgService: ConfigArgService, customFieldRelationService: CustomFieldRelationService, translator: TranslatorService, roleService: RoleService) => CollectionService
findAll
(ctx: RequestContext, options?: ListQueryOptions<Collection> & { topLevelOnly?: boolean }, relations?: RelationPaths<Collection>) => Promise<PaginatedList<Translated<Collection>>>
findOne
(ctx: RequestContext, collectionId: ID, relations?: RelationPaths<Collection>) => Promise<Translated<Collection> | undefined>
findByIds
(ctx: RequestContext, ids: ID[], relations?: RelationPaths<Collection>) => Promise<Array<Translated<Collection>>>
findOneBySlug
(ctx: RequestContext, slug: string, relations?: RelationPaths<Collection>) => Promise<Translated<Collection> | undefined>
getAvailableFilters
(ctx: RequestContext) => ConfigurableOperationDefinition[]
Returns all configured CollectionFilters, as specified by the CatalogOptions.
getParent
(ctx: RequestContext, collectionId: ID) => Promise<Collection | undefined>
getChildren
(ctx: RequestContext, collectionId: ID) => Promise<Collection[]>
Returns all child Collections of the Collection with the given id.
getBreadcrumbs
(ctx: RequestContext, collection: Collection) => Promise<Array<{ name: string; id: ID, slug: string }>>
Returns an array of name/id pairs representing all ancestor Collections up to the Root Collection.
getCollectionsByProductId
(ctx: RequestContext, productId: ID, publicOnly: boolean) => Promise<Array<Translated<Collection>>>
Returns all Collections which are associated with the given Product ID.
getDescendants
(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
(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
(collectionId: ID, ctx: RequestContext) => Promise<Array<Translated<Collection>>>
getAncestors
(collectionId: ID, ctx?: RequestContext) => Promise<Array<Translated<Collection> | Collection>>
previewCollectionVariants
(ctx: RequestContext, input: PreviewCollectionVariantsInput, options?: ListQueryOptions<ProductVariant>, relations?: RelationPaths<Collection>) => Promise<PaginatedList<ProductVariant>>
create
(ctx: RequestContext, input: CreateCollectionInput) => Promise<Translated<Collection>>
update
(ctx: RequestContext, input: UpdateCollectionInput) => Promise<Translated<Collection>>
delete
(ctx: RequestContext, id: ID) => Promise<DeletionResponse>
move
(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
(collection: Collection, ctx?: RequestContext) => Promise<ID[]>
assignCollectionsToChannel
(ctx: RequestContext, input: AssignCollectionsToChannelInput) => Promise<Array<Translated<Collection>>>
Assigns Collections to the specified Channel
removeCollectionsFromChannel
(ctx: RequestContext, input: RemoveCollectionsFromChannelInput) => Promise<Array<Translated<Collection>>>
Remove Collections from the specified Channel