ProductService
extends Service
in package
Uses
ServiceTrait, RelatedItemsTrait
This is the product service class.
This class will retrieve the products from LogiCommerce API and transform them to objects. All the needed product operations previous to Framework must be done here.
Tags
Table of Contents
DELETE | = \SDK\Core\Enums\MethodType::DELETE | |
---|---|---|
GET | = \SDK\Core\Enums\MethodType::GET | |
ITEMS | = 'items' | |
POST | = \SDK\Core\Enums\MethodType::POST | |
PUT | = \SDK\Core\Enums\MethodType::PUT | |
addComment() | Add a new comment into the product that matches the given id | : Comment|null |
addGetBundleDefinitions() | Add the request to get product bundle definitions filtered with the given parameters | : void |
addGetBundleDefinitionsGroupings() | Add the request to get product bundle definitions groupings filtered with the given parameters | : void |
addGetComments() | Add the request to get product comments filtered with the given parameters | : void |
addGetLinkedProducts() | Add the request to get products linked to the product specified | : void |
addGetProduct() | Add the request to get the product identified by the given id | : void |
addGetProductComparison() | Add the request to get the information for each product contained in the product comparison. | : void |
addGetProductDiscounts() | Add the request to get the discounts for the product identified by the given id | : ElementCollection|null |
addGetProductRewardPoints() | Add the request to get the product reward points by the given id | : void |
addGetProductRichSnippets() | Add the request to get the rich snippets for the product identified by the given id | : void |
addGetProducts() | Add the request to get the products filtered with the given parameters | : void |
addGetProductsDiscounts() | Add the request to get the discounts for the products filtered with the given parameters | : ElementCollection|null |
addGetRelatedItems() | Add the request to get the related items assigned to the given item id | : void |
addGetTopSellers() | Add the request to get the top sellers products filtered with the given parameters | : void |
addProductComparison() | Adds the specified product to the product comparison. | : Status|null |
deleteProductComparison() | Returns the discounts for the product identified by the given id | : Status|null |
getBundleDefinitions() | Returns the product bundle definitions filtered with the given parameters | : ElementCollection|null |
getBundleDefinitionsGroupings() | Returns the product bundle definitions groupings filtered with the given parameters | : ElementCollection|null |
getBundleDefinitionsGroupingsCombinationData() | Get current data bundle definition for the given params | : BundleCombinationData|null |
getCombinationData() | Get current data product for the given params | : ProductCombinationData|null |
getComments() | Returns the product comments filtered with the given parameters | : ElementCollection|null |
getInstance() | Returns the requested model instance. | : Service |
getLinkedProducts() | Returns the product linked to the product specified | : ElementCollection|null |
getProduct() | Returns the product identified by the given id | : Product|null |
getProductComparison() | Returns the information for each product contained in the product comparison. | : ProductComparison|null |
getProductDiscounts() | Returns the discounts for the product identified by the given id | : ElementCollection|null |
getProductRewardPoints() | Returns the product reward points by the given id | : ElementCollection|null |
getProductRichSnippets() | Returns the rich snippets for the product identified by the given id | : ProductRichSnippets|null |
getProducts() | Returns the products filtered with the given parameters | : ElementCollection|null |
getProductsDiscounts() | Returns the discounts for the products filtered with the given parameters | : ElementCollection|null |
getRelatedItems() | Returns the related items assigned to the given item id | : ElementCollection|null |
getTopSellers() | Returns the top sellers products filtered with the given parameters | : ElementCollection|null |
query() | Send an email with a query related to the product that matches the given id | : Status|null |
rate() | Add a rate into the product that matches the given id | : Status|null |
recommend() | Recommend the product that matches the given id | : Status|null |
stockSubscription() | Subscribe the given email into the combination that matches the given id | : Status|null |
__construct() | : mixed | |
call() | : array<string|int, mixed> | |
extractParameters() | : array<string|int, mixed> | |
getCollection() | : mixed | |
getConnection() | : Connection | |
getElement() | : Element|null | |
getElements() | : ElementCollection|null | |
getResourceElement() | : Element|null | |
getResponse() | : ElementCollection|null | |
prepareElement() | : Element|null | |
prepareElements() | : array<string|int, mixed> | |
replaceWildcards() | : string |
Constants
DELETE
protected
mixed
DELETE
= \SDK\Core\Enums\MethodType::DELETE
GET
protected
mixed
GET
= \SDK\Core\Enums\MethodType::GET
ITEMS
protected
mixed
ITEMS
= 'items'
POST
protected
mixed
POST
= \SDK\Core\Enums\MethodType::POST
PUT
protected
mixed
PUT
= \SDK\Core\Enums\MethodType::PUT
Methods
addComment()
Add a new comment into the product that matches the given id
public
addComment(int $id[, AddCommentParametersGroup $comment = null ]) : Comment|null
Parameters
- $id : int
- $comment : AddCommentParametersGroup = null
-
object with the needed data to add a new comment
Return values
Comment|null —addGetBundleDefinitions()
Add the request to get product bundle definitions filtered with the given parameters
public
addGetBundleDefinitions(BatchRequests $batchRequests, string $batchName, int $id[, BundleDefinitionsParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
- $params : BundleDefinitionsParametersGroup = null
-
object with the needed filters to send to the API /products/{id}/bundleDefinitions resource
Return values
void —addGetBundleDefinitionsGroupings()
Add the request to get product bundle definitions groupings filtered with the given parameters
public
addGetBundleDefinitionsGroupings(BatchRequests $batchRequests, string $batchName, int $id, int $bundleDefinitionId[, BundleDefinitionsGroupingsParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
- $bundleDefinitionId : int
- $params : BundleDefinitionsGroupingsParametersGroup = null
-
object with the needed filters to send to the API /products/{id}/bundleDefinitions/{bundleDefinitionId}/groupings resource
Return values
void —addGetComments()
Add the request to get product comments filtered with the given parameters
public
addGetComments(BatchRequests $batchRequests, string $batchName, int $id[, CommentsParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
- $params : CommentsParametersGroup = null
-
object with the needed filters to send to the API products/comments resource
Return values
void —addGetLinkedProducts()
Add the request to get products linked to the product specified
public
addGetLinkedProducts(BatchRequests $batchRequests, string $batchName, int $id[, LinkedParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
- $id : int
- $params : LinkedParametersGroup = null
-
object with the needed filters to send to the API /products/{id}/linked resource
Return values
void —addGetProduct()
Add the request to get the product identified by the given id
public
addGetProduct(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 —addGetProductComparison()
Add the request to get the information for each product contained in the product comparison.
public
addGetProductComparison(BatchRequests $batchRequests, string $batchName) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
Return values
void —addGetProductDiscounts()
Add the request to get the discounts for the product identified by the given id
public
addGetProductDiscounts(BatchRequests $batchRequests, string $batchName, int $id) : ElementCollection|null
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
Return values
ElementCollection|null —addGetProductRewardPoints()
Add the request to get the product reward points by the given id
public
addGetProductRewardPoints(BatchRequests $batchRequests, string $batchName, int $id) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
Return values
void —addGetProductRichSnippets()
Add the request to get the rich snippets for the product identified by the given id
public
addGetProductRichSnippets(BatchRequests $batchRequests, string $batchName, int $id) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
Return values
void —addGetProducts()
Add the request to get the products filtered with the given parameters
public
addGetProducts(BatchRequests $batchRequests, string $batchName[, ProductsParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : ProductsParametersGroup = null
-
object with the needed filters to send to the API products resource
Return values
void —addGetProductsDiscounts()
Add the request to get the discounts for the products filtered with the given parameters
public
addGetProductsDiscounts(BatchRequests $batchRequests, string $batchName[, ProductsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : ProductsParametersGroup = null
-
object with the needed filters to send to the API products discounts resource
Return values
ElementCollection|null —addGetRelatedItems()
Add the request to get the related items assigned to the given item id
public
addGetRelatedItems(BatchRequests $batchRequests, string $batchName, int $id[, string $type = '' ][, RelatedItemsParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
- $type : string = ''
-
Optional. This param will set the kind of related we want to retrieve. Valid values are inside RelatedItemsType class. If not given all the related items will be returned inside the RelatedItems object.
- $params : RelatedItemsParametersGroup = null
-
object with the needed filters to send to the API resource
Tags
Return values
void —addGetTopSellers()
Add the request to get the top sellers products filtered with the given parameters
public
addGetTopSellers(BatchRequests $batchRequests, string $batchName[, TopSellersParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : TopSellersParametersGroup = null
-
object with the needed filters to send to the API products/topSellers resource
Return values
void —addProductComparison()
Adds the specified product to the product comparison.
public
addProductComparison([AddComparisonProductParametersGroup $addComparisonProduct = null ]) : Status|null
Parameters
- $addComparisonProduct : AddComparisonProductParametersGroup = null
-
object with the needed data to add a new comparison product
Return values
Status|null —deleteProductComparison()
Returns the discounts for the product identified by the given id
public
deleteProductComparison(int $id) : Status|null
Parameters
- $id : int
Return values
Status|null —getBundleDefinitions()
Returns the product bundle definitions filtered with the given parameters
public
getBundleDefinitions(int $id[, BundleDefinitionsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $id : int
- $params : BundleDefinitionsParametersGroup = null
-
object with the needed filters to send to the API /products/{id}/bundleDefinitions resource
Return values
ElementCollection|null —getBundleDefinitionsGroupings()
Returns the product bundle definitions groupings filtered with the given parameters
public
getBundleDefinitionsGroupings(int $id, int $bundleDefinitionId[, BundleDefinitionsGroupingsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $id : int
- $bundleDefinitionId : int
- $params : BundleDefinitionsGroupingsParametersGroup = null
-
object with the needed filters to send to the API /products/{id}/bundleDefinitions/{bundleDefinitionId}/groupings resource
Return values
ElementCollection|null —getBundleDefinitionsGroupingsCombinationData()
Get current data bundle definition for the given params
public
getBundleDefinitionsGroupingsCombinationData([GetBundleDefinitionsGroupingsCombinationDataParametersGroup $params = null ]) : BundleCombinationData|null
Parameters
- $params : GetBundleDefinitionsGroupingsCombinationDataParametersGroup = null
Return values
BundleCombinationData|null —getCombinationData()
Get current data product for the given params
public
getCombinationData(int $id[, GetCombinationDataParametersGroup $params = null ]) : ProductCombinationData|null
Parameters
- $id : int
- $params : GetCombinationDataParametersGroup = null
Return values
ProductCombinationData|null —getComments()
Returns the product comments filtered with the given parameters
public
getComments(int $id[, CommentsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $id : int
- $params : CommentsParametersGroup = null
-
object with the needed filters to send to the API products/comments resource
Return values
ElementCollection|null —getInstance()
Returns the requested model instance.
public
static getInstance() : Service
If is not setted, this method will set it.
Return values
Service —getLinkedProducts()
Returns the product linked to the product specified
public
getLinkedProducts(int $id[, LinkedParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $id : int
- $params : LinkedParametersGroup = null
-
object with the needed filters to send to the API /products/{id}/linked resource
Return values
ElementCollection|null —getProduct()
Returns the product identified by the given id
public
getProduct(int $id[, ProductParametersGroup $params = null ]) : Product|null
Parameters
- $id : int
- $params : ProductParametersGroup = null
Return values
Product|null —getProductComparison()
Returns the information for each product contained in the product comparison.
public
getProductComparison() : ProductComparison|null
Return values
ProductComparison|null —getProductDiscounts()
Returns the discounts for the product identified by the given id
public
getProductDiscounts(int $id) : ElementCollection|null
Parameters
- $id : int
Return values
ElementCollection|null —getProductRewardPoints()
Returns the product reward points by the given id
public
getProductRewardPoints(int $id) : ElementCollection|null
Parameters
- $id : int
Return values
ElementCollection|null —getProductRichSnippets()
Returns the rich snippets for the product identified by the given id
public
getProductRichSnippets(int $id) : ProductRichSnippets|null
Parameters
- $id : int
Return values
ProductRichSnippets|null —getProducts()
Returns the products filtered with the given parameters
public
getProducts([ProductsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : ProductsParametersGroup = null
-
object with the needed filters to send to the API products resource
Return values
ElementCollection|null —getProductsDiscounts()
Returns the discounts for the products filtered with the given parameters
public
getProductsDiscounts([ProductsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : ProductsParametersGroup = null
-
object with the needed filters to send to the API products discounts resource
Return values
ElementCollection|null —getRelatedItems()
Returns the related items assigned to the given item id
public
getRelatedItems(int $id[, string $type = '' ][, RelatedItemsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $id : int
- $type : string = ''
-
Optional. This param will set the kind of related we want to retrieve. Valid values are inside RelatedItemsType class. If not given all the related items will be returned inside the RelatedItems object.
- $params : RelatedItemsParametersGroup = null
-
object with the needed filters to send to the API resource
Tags
Return values
ElementCollection|null —getTopSellers()
Returns the top sellers products filtered with the given parameters
public
getTopSellers([TopSellersParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : TopSellersParametersGroup = null
-
object with the needed filters to send to the API products/topSellers resource
Return values
ElementCollection|null —query()
Send an email with a query related to the product that matches the given id
public
query(int $id[, QueryParametersGroup $data = null ][, string $dataValidatior = '' ]) : Status|null
Parameters
- $id : int
- $data : QueryParametersGroup = null
-
object with the needed data to send the query
- $dataValidatior : string = ''
-
Data validatior PId to apply
Return values
Status|null —rate()
Add a rate into the product that matches the given id
public
rate(int $id, int $rating) : Status|null
Parameters
- $id : int
- $rating : int
-
(must be into the 0-5 range)
Return values
Status|null —recommend()
Recommend the product that matches the given id
public
recommend(int $id[, RecommendParametersGroup $data = null ]) : Status|null
Parameters
- $id : int
- $data : RecommendParametersGroup = null
-
object with the needed data to recommend the product
Return values
Status|null —stockSubscription()
Subscribe the given email into the combination that matches the given id
public
stockSubscription(int $id[, string $email = '' ]) : Status|null
Parameters
- $id : int
-
Combination internal identifier
- $email : string = ''
Return values
Status|null —__construct()
protected
__construct() : mixed
Return values
mixed —call()
protected
call(Request $request[, string $apiUrl = null ]) : array<string|int, mixed>
Parameters
- $request : Request
- $apiUrl : string = null
Return values
array<string|int, mixed> —extractParameters()
protected
extractParameters([ParametersGroup|null $parametersGroup = null ]) : array<string|int, mixed>
Parameters
- $parametersGroup : ParametersGroup|null = null
Return values
array<string|int, mixed> —getCollection()
protected
getCollection(array<string|int, mixed> $data, string $class) : mixed
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
mixed —getConnection()
protected
getConnection() : Connection
Return values
Connection —getElement()
protected
getElement(string $class, string $resource[, int $id = null ][, mixed $params = null ]) : Element|null
Parameters
- $class : string
- $resource : string
- $id : int = null
- $params : mixed = null
Return values
Element|null —getElements()
protected
getElements(string $class, string $resource[, ParametersGroup $parameters = null ]) : ElementCollection|null
Parameters
- $class : string
- $resource : string
- $parameters : ParametersGroup = null
Return values
ElementCollection|null —getResourceElement()
protected
getResourceElement(string $class, string $resource[, mixed $params = [] ]) : Element|null
Parameters
- $class : string
- $resource : string
- $params : mixed = []
Return values
Element|null —getResponse()
protected
getResponse(array<string|int, mixed> $data, string $class) : ElementCollection|null
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
ElementCollection|null —prepareElement()
protected
prepareElement(array<string|int, mixed> $data, string $class) : Element|null
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
Element|null —prepareElements()
protected
prepareElements(array<string|int, mixed> $data, string $class) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
array<string|int, mixed> —replaceWildcards()
protected
replaceWildcards(string $resource, array<string|int, mixed> $wildcards) : string
Parameters
- $resource : string
- $wildcards : array<string|int, mixed>