CategoryService
This service class contains methods related to Category models.
All public functions are available in the Twig template renderer.
Namespace
IO\Services
Type | Name | Description |
---|---|---|
|
This repository is used to manipulate Category models. |
|
|
This repository is used to read the webstore configuration. |
|
|
This repository is used to manipulate Contact models. |
|
|
The current Category model. |
|
|
The full branch of the category with parents, e.g. Plants → Edible → Tomatoes. |
|
|
Guard class to check for login status. |
|
|
An item. |
|
|
The current webstore id. |
|
|
Methods
public __construct($categoryRepository, $webstoreConfigurationRepository, $authGuard, $contactRepository)
CategoryService constructor.
Type |
Name |
Description |
|
This repository is used to manipulate Category models. |
|
|
This repository is used to read the webstore configuration. |
|
|
Guard class to check for login status. |
|
|
This repository is used to manipulate Contact models. |
public setCurrentCategoryID($catID)
Set the current category by id.
Type |
Name |
Description |
|
The id of the current category |
public setCurrentCategory($cat)
Set the current category by id.
Type |
Name |
Description |
|
The current category |
public getCurrentCategory():Category
Gets the current category or null if not set
public get($catID, $lang = null):Category
Get a category by id
Type |
Name |
Description |
|
The category id |
|
|
The language to get the category (ISO-639-1) |
public getForPlentyId($catID, $lang = null, $plentyId = null):Category
Gets a category by id and plentyId
Type |
Name |
Description |
|
The category id |
|
|
The language to get the category (ISO-639-1) |
|
|
The plentyId to which the category has to be linked |
public getChildren($categoryId, $lang = null):array
Deprecated!
This method will not be supported in the future. Please refrain from using it as soon as possible. |
Get child categories of a given category referenced by id
Type |
Name |
Description |
|
The category id, which children should be fetched |
|
|
The language in ISO-639-1 format |
public getCurrentCategoryChildren($categoryId = null):mixed
Gets the children of the given categoryId or the current category if no categoryId is given.
Type |
Name |
Description |
|
public findInCategoryTree($categoryTree, $branch = [], $level = 1):mixed
Recursively iterate through category tree and return the category with the given id.
Type |
Name |
Description |
|
A tree containing all categories |
|
|
The current branch of the categoryTree |
|
|
The current depth of the recursion |
public getURL($category, $lang = null, $webstoreId = null):string
Return the URL for a given category.
Type |
Name |
Description |
|
The category to get the URL for |
|
|
The language to get the URL for (ISO-639-1) |
|
|
public getURLById($categoryId, $lang = null):string
Return the url for a given category id.
Type |
Name |
Description |
|
Id of category to fetch |
|
|
Language in format ISO-639-1 |
public getDetails($category, $lang):CategoryDetails
Get CategoryDetails of the given category for a given language
Type |
Name |
Description |
|
The category model |
|
|
The language in format ISO-639-1 |
public isCurrent($category):bool
Check whether a category is referenced by the current route
Type |
Name |
Description |
|
The category to check |
public isOpen($category):bool
Check whether any child of a category is referenced by the current route
Type |
Name |
Description |
|
The category to check |
public isActive($category = null):bool
Check whether a category or any of its children is referenced by the current route
Type |
Name |
Description |
|
The category to check |
public getItems($category = null, $params = [], $page = 1):array
Get items for the given or current category
Type |
Name |
Description |
|
The category of which you want items of (null means currentCategory) |
|
|
The parameters for the repository |
|
|
The desired page, always >0 |
Return the sitemap tree as an array
Type |
Name |
Description |
|
Only return categories of given types |
|
|
The language to get sitemap tree for |
|
|
The deepest category level to load |
|
|
The customer class id to get tree |
public getPartialTree($categoryId, $type = \IO\Constants\CategoryType::ALL):array
Builds a partial tree of starting from the given category id
Type |
Name |
Description |
|
The category id |
|
|
The type of category, see /IO/Constants/CategoryType |
Return the sitemap list as an array
Type |
Name |
Description |
|
Only return categories of given type, see /IO/Constants/CategoryType |
|
|
The language to get sitemap list for (ISO-639-1) |
public getHierarchy($catID, $bottomUp = false, $filterCategories = false):array
Returns a list of all parent categories including given category.
Type |
Name |
Description |
|
The category id to get the parents for or 0 to use current category |
|
|
Set true to order result from bottom (deepest category) to top (= level 1) |
|
|
Filter categories |
public isVisibleForWebstore($category, $webstoreId = null, $lang = null):bool
Check if a category is visible for a webstore.
Type |
Name |
Description |
|
Category model to check |
|
|
WebstoreId for filtering result (not plentyId) |
|
|
Language for filtering result (ISO-639-1) |
public setCurrentItem($item)
Setter for current item array.
Type |
Name |
Description |
|
An item. |
public getCurrentItem():array
Getter for current item array.
Check wether a category is hidden or not
Type |
Name |
Description |
|
The id of the category to check |
public fromMemoryCache()
public resetMemoryCache($key = null)
Type |
Name |
Description |
|