ProductService
extends ProductService
in package
Uses
ServiceTrait, SetRelatedItemsTrait
This is the ProductService class.
Remember that a service is an extension of a SDK model that allows to add additional actions to a model request or create new methods to simplify some common requests. In this case, the ProductService extends the SDK\Services\ProductService.
Tags
Table of Contents
PRICE | = 'price' | |
---|---|---|
PRICE_BASE | = 'priceBase' | |
PRICE_RETAIL | = 'priceRetail' | |
addGetFeatured() | This method adds the batch request to get all the featured products. | : void |
addGetOffers() | This method adds the batch request to get all the products on offer. | : void |
addGetProductById() | This method adds the batch request to get the product whose id matches the given one. | : void |
addGetProductsByBrandId() | This method adds the batch request to get those products whose brandId matches the given one. | : void |
addGetProductsByCategoryId() | This method adds the batch request to get those products whose categoryId matches the given one. | : void |
addGetProductsByIdList() | This method adds the batch request to get those products whose id matches any of the given idList. | : void |
addGetProductsByPId() | This method adds the batch request to get the products whose pId matches the given one. | : void |
addGetProductsBySearchCriteria() | This method adds the batch request to get those products that match the given search criteria. | : void |
addProductComparison() | {@inheritdoc} | : Status|null |
buildElementCollection() | This method returns and ElementCollection from the given data and class | : bool |
deleteProductComparison() | {@inheritdoc} | : Status|null |
generateParametersGroupFromArray() | This method sets a parametersGroup object with the filters indicated in params (array key=>value). | : array<string|int, mixed> |
getFeatured() | This method returns the Dtos of all the featured products. | : ElementCollection|null |
getOffers() | This method returns the Dtos of all the products on offer. | : ElementCollection|null |
getParametersByBrandId() | : ProductsParametersGroup | |
getParametersByCategoryId() | : ProductsParametersGroup | |
getParametersByIdList() | : ProductsParametersGroup | |
getParametersBySearchCriteria() | : ProductsParametersGroup | |
getParametersOnlyFeatured() | : ProductsParametersGroup | |
getParametersOnlyOffers() | : ProductsParametersGroup | |
getProductById() | This method returns the Dto of the product whose id matches the given one. | : Product|null |
getProductByPId() | This method returns the Dto of the products whose pId matches the given one. | : Product|null |
getProductsByBrandId() | This method returns the Dtos of those products whose brandId matches the given one. | : ElementCollection|null |
getProductsByCategoryId() | This method returns the Dtos of those products whose categoryId matches the given one. | : ElementCollection|null |
getProductsByIdList() | This method returns the Dtos of those products whose id matches any of the given list. | : ElementCollection|null |
getProductsBySearchCriteria() | This method returns the Dtos of those products that match the given searchCriteria. | : ElementCollection|null |
validateParameterGroup() | This method validates the given parametersGroup. Returns true if valid, false otherwise. | : bool |
getAllElementCollectionItems() | Returns all available items filtered with the given parameters | : ElementCollection|null |
getConfiguration() | : Configuration |
Constants
PRICE
public
mixed
PRICE
= 'price'
PRICE_BASE
public
mixed
PRICE_BASE
= 'priceBase'
PRICE_RETAIL
public
mixed
PRICE_RETAIL
= 'priceRetail'
Methods
addGetFeatured()
This method adds the batch request to get all the featured products.
public
addGetFeatured(BatchRequests $batchRequests, string $batchName) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
Return values
void —addGetOffers()
This method adds the batch request to get all the products on offer.
public
addGetOffers(BatchRequests $batchRequests, string $batchName) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
Return values
void —addGetProductById()
This method adds the batch request to get the product whose id matches the given one.
public
addGetProductById(BatchRequests $batchRequests, string $batchName, int $id[, ProductParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
- $params : ProductParametersGroup = null
Return values
void —addGetProductsByBrandId()
This method adds the batch request to get those products whose brandId matches the given one.
public
addGetProductsByBrandId(BatchRequests $batchRequests, string $batchName, int $brandId) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $brandId : int
Return values
void —addGetProductsByCategoryId()
This method adds the batch request to get those products whose categoryId matches the given one.
public
addGetProductsByCategoryId(BatchRequests $batchRequests, string $batchName, int $categoryId) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $categoryId : int
Return values
void —addGetProductsByIdList()
This method adds the batch request to get those products whose id matches any of the given idList.
public
addGetProductsByIdList(BatchRequests $batchRequests, string $batchName, string $idList) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $idList : string
Return values
void —addGetProductsByPId()
This method adds the batch request to get the products whose pId matches the given one.
public
addGetProductsByPId(BatchRequests $batchRequests, string $batchName, string $pId) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $pId : string
Return values
void —addGetProductsBySearchCriteria()
This method adds the batch request to get those products that match the given search criteria.
public
addGetProductsBySearchCriteria(BatchRequests $batchRequests, string $batchName, string $searchCriteria) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $searchCriteria : string
Return values
void —addProductComparison()
{@inheritdoc}
public
addProductComparison([AddComparisonProductParametersGroup $addComparisonProduct = null ]) : Status|null
Parameters
- $addComparisonProduct : AddComparisonProductParametersGroup = null
Tags
Return values
Status|null —buildElementCollection()
This method returns and ElementCollection from the given data and class
public
buildElementCollection(array<string|int, mixed> $data, string $class) : bool
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
bool —deleteProductComparison()
{@inheritdoc}
public
deleteProductComparison(int $id) : Status|null
Parameters
- $id : int
Tags
Return values
Status|null —generateParametersGroupFromArray()
This method sets a parametersGroup object with the filters indicated in params (array key=>value).
public
generateParametersGroupFromArray(ParametersGroup &$parametersGroup, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $parametersGroup : ParametersGroup
- $params : array<string|int, mixed>
Return values
array<string|int, mixed> —with the applied filters
getFeatured()
This method returns the Dtos of all the featured products.
public
getFeatured() : ElementCollection|null
Return values
ElementCollection|null —getOffers()
This method returns the Dtos of all the products on offer.
public
getOffers() : ElementCollection|null
Return values
ElementCollection|null —getParametersByBrandId()
public
getParametersByBrandId(int $brandId) : ProductsParametersGroup
Parameters
- $brandId : int
Return values
ProductsParametersGroup —getParametersByCategoryId()
public
getParametersByCategoryId(int $categoryId) : ProductsParametersGroup
Parameters
- $categoryId : int
Return values
ProductsParametersGroup —getParametersByIdList()
public
getParametersByIdList(string $idList) : ProductsParametersGroup
Parameters
- $idList : string
Return values
ProductsParametersGroup —getParametersBySearchCriteria()
public
getParametersBySearchCriteria(string $searchCriteria) : ProductsParametersGroup
Parameters
- $searchCriteria : string
Return values
ProductsParametersGroup —getParametersOnlyFeatured()
public
getParametersOnlyFeatured() : ProductsParametersGroup
Return values
ProductsParametersGroup —getParametersOnlyOffers()
public
getParametersOnlyOffers() : ProductsParametersGroup
Return values
ProductsParametersGroup —getProductById()
This method returns the Dto of the product whose id matches the given one.
public
getProductById(int $id[, ProductsParametersGroup $params = null ]) : Product|null
Parameters
- $id : int
- $params : ProductsParametersGroup = null
Return values
Product|null —getProductByPId()
This method returns the Dto of the products whose pId matches the given one.
public
getProductByPId(string $pId) : Product|null
Parameters
- $pId : string
Return values
Product|null —getProductsByBrandId()
This method returns the Dtos of those products whose brandId matches the given one.
public
getProductsByBrandId(int $brandId) : ElementCollection|null
Parameters
- $brandId : int
Return values
ElementCollection|null —getProductsByCategoryId()
This method returns the Dtos of those products whose categoryId matches the given one.
public
getProductsByCategoryId(int $categoryId) : ElementCollection|null
Parameters
- $categoryId : int
Return values
ElementCollection|null —getProductsByIdList()
This method returns the Dtos of those products whose id matches any of the given list.
public
getProductsByIdList(string $idList) : ElementCollection|null
Parameters
- $idList : string
Return values
ElementCollection|null —getProductsBySearchCriteria()
This method returns the Dtos of those products that match the given searchCriteria.
public
getProductsBySearchCriteria(string $searchCriteria) : ElementCollection|null
Parameters
- $searchCriteria : string
Return values
ElementCollection|null —validateParameterGroup()
This method validates the given parametersGroup. Returns true if valid, false otherwise.
public
validateParameterGroup(ParametersGroup $parametersGroup) : bool
Parameters
- $parametersGroup : ParametersGroup
Return values
bool —getAllElementCollectionItems()
Returns all available items filtered with the given parameters
protected
getAllElementCollectionItems(string $elementClass, string $resource, ParametersGroup $params) : ElementCollection|null
Parameters
- $elementClass : string
- $resource : string
- $params : ParametersGroup
-
object with the needed filters to send to the API resource
Return values
ElementCollection|null —getConfiguration()
protected
static getConfiguration() : Configuration