File

projects/congarevenuecloud/ecommerce/src/lib/modules/catalog/services/category.service.ts

Description

Category allows in organizing products in a way that makes it easy for visitors to find out what they're looking for

Usage

Example :
import { CategoryService, AObjectService} from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
constructor( private categoryService: CategoryService)
}
// or
export class MyService extends AObjectService {
private categoryService: CategoryService = this.injector.get(CategoryService);
}

Extends

AObjectService

Index

Properties
Methods

Methods

getCategories
getCategories()

The primary method to get all the categories based on pricelist. This is a hot observable that will be updated when the state of the category changes.

Example:

Example :
import { CategoryService } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
categories: Array<Category>;
categories$: Observable<Category>; // can be used in the template with {{(categories$ | async) as categories}}

constructor(private categoryService: CategoryService){}

ngOnInit(){
this.categoryService.getCategories().subscribe(result => this.categories = category);
// or
this.cart$ = this.categoryService.getCategories();
}
}

A hot observable containing the list of categories

getCategoryBranchChildren
getCategoryBranchChildren(categoryIdList: Array)

This method fetches all the children categories recursively for the category identifiers.

Example:

Example :
import { CategoryService, Category } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
category: Array<Category>;
category$: Observable<Array<Category>>;

constructor(private categoryService: CategoryService){}

getCategoryBranchChildren(categoryIdList: Array<string>){
this.categoryService.getCategoryBranchChildren(categoryIdList).subscribe(category => this.category = category);
// or
this.cart$ = this.categoryService.getCategoryBranchChildren(categoryIdList);
}
}
Parameters :
Name Type Optional Description
categoryIdList Array<string> No

is a list of string identifiers representing the categories.

an observable containing the array of categories.

getCategoryByName
getCategoryByName(categoryName: string)

This method fetches a category by name. It returns a hot observable of the category matching the name.

Example:

Example :
import { CategoryService } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
category: Category;
category$: Observable<Category>; // can be used in the template with {{(category$ | async)?.Label}}

constructor(private categoryService: CategoryService){}

ngOnInit(){
this.categoryService.getCategoryByName('Electronics').subscribe(category => this.category = category);
// or
this.cart$ = this.categoryService.getCategoryByName();
}
}
Parameters :
Name Type Optional Description
categoryName string No

the name of the category to be passed as string.

A hot observable containing the single category instance.

Properties

Protected plService
Default value : this.injector.get(PriceListService, 'priceListService')
Protected productCategoryService
Default value : this.injector.get(ProductCategoryService, 'productCategoryService')
Protected translatorService
Default value : this.injector.get(TranslatorLoaderService, 'translatorService')
type
Default value : Category

results matching ""

    No results matching ""