ItemService

This service class contains functions related to common item tasks.
All public functions are available in the Twig template renderer.

Namespace

IO\Services

Properties
Type Name Description

Application

$app

ItemDataLayerRepositoryContract

$itemRepository

``

$sessionStorageRepository

SessionStorageRepositoryContract

array

$additionalItemSortingMap

``

$cache

Methods
public __construct($app, $itemRepository, $sessionStorageRepository)

ItemService constructor.

Parameters

Type

Name

Description

Application

$app

ItemDataLayerRepositoryContract

$itemRepository

SessionStorageRepositoryContract

$sessionStorageRepository

public getItem($itemId):array

Get an item by ID

Parameters

Type

Name

Description

int

$itemId

An item id

public getItems($itemIds):array

Get a list of items with the specified item ids

Parameters

Type

Name

Description

array

$itemIds

List of item ids

public getItemImage($itemId):string
Parameters

Type

Name

Description

int

$itemId

An item id

public getVariation($variationId):array

Get an item variation by id

Parameters

Type

Name

Description

int

$variationId

An variation id

public getVariations($variationIds):array

Get a list of item variations with the specified variation ids

Parameters

Type

Name

Description

array

$variationIds

A list of variation idss

public getVariationIds($itemId):array

Get a list of active and salable variation ids associated with an item

Parameters

Type

Name

Description

int

$itemId

An item id

public getVariationList($itemId, $withPrimary = false):array

Get a list of variation ids associated with a specific item

Parameters

Type

Name

Description

int

$itemId

An item id

bool

$withPrimary

Optional: If true, load base variation too (Default: false)

public getVariationImage($variationId, $imageAccessor = "urlPreview"):string
Deprecated!

This method will not be supported in the future. Please refrain from using it as soon as possible.

Get image url of a variation

Parameters

Type

Name

Description

int

$variationId

An variation id

string

$imageAccessor

Optional: Key to image (Default: 'urlPreview')

public getItemForCategory($catID, $params = [], $page = 1):array

Get all items for a specific category

Parameters

Type

Name

Description

int

$catID

A category id

array

$params

Optional: Parameters for Elastic Search, only itemsPerPage is used

int

$page

Optional: What page to get (Default: 1)

public getVariationAttributeMap($itemId):array

List the attributes of an item variation

Parameters

Type

Name

Description

int

$itemId

Optional: An item id

public getVariationIsSalable($variationId):bool

Check, if variation is salable, meaning it has stock, has a price etc.

Parameters

Type

Name

Description

int

$variationId

Optional: A variation id

public getAttributeNameMap($itemId):array

Get a list containing attributes and units related to an item

Parameters

Type

Name

Description

int

$itemId

Optional: An item id

public getItemURL($itemId):Record
Deprecated!

Use UrlService instead

Get the item URL

Parameters

Type

Name

Description

int

$itemId

An item id

public getAttributeName($attributeId):string

Get the name of an attribute by id

Parameters

Type

Name

Description

int

$attributeId

Optional: An attribute id

public getAttributeValueName($attributeValueId):string

Get the name of an attribute value by id

Parameters

Type

Name

Description

int

$attributeValueId

Optional: An attribute value’s id

public getItemCrossSellingList($itemId, $crossSellingType = "similar"):array

Get a list of cross-selling items for the specified item id

Parameters

Type

Name

Description

int

$itemId

Optional: An item’s id

string

$crossSellingType

Optional: The cross selling type (Default: 'similar')

public getItemConditionText($conditionId):string

Get the text for a specific item condition

Parameters

Type

Name

Description

int

$conditionId

An item condition’s id

public getLatestItems($limit = 5, $categoryId):RecordList

Get a list of the latest items

Parameters

Type

Name

Description

int

$limit

Optional: Maximum number of returned items (Default: 5)

int

$categoryId

Optional: From which category should items be returned?

public searchItems($searchString, $params = [], $page = 1):array

Search for items using a search string and return a result

Parameters

Type

Name

Description

string

$searchString

A user inputted search string

array

$params

Optional: Parameters for elastic search query, only itemsPerPage is used

int

$page

Optional: Page number for pagination

public getAdditionalItemSorting():array

Get additional sortings

public addAdditionalItemSorting($key, $translationKey)

Add an additional sorting

Parameters

Type

Name

Description

string

$key

A sorting key

string

$translationKey

The translation key for the sorting

public fromMemoryCache()
public resetMemoryCache($key = null)
Parameters

Type

Name

Description

``

$key