ProductAttributeService
in package
implements
ProductAttributeServiceInterface
Class ProductAttributeService
Tags
Interfaces, Classes and Traits
- ProductAttributeServiceInterface
- Interface ProductAttributeServiceInterface
Table of Contents
- $productAttributeRepo : ProductAttributeRepositoryInterface
- __construct() : mixed
- Initialize the product attribute service.
- addAttribute() : int
- Adds an product attribute to a product by the given id.
- getAttributeById() : StoredProductAttributeInterface
- Returns a stored product attribute entity by the given product attribute id.
- getAttributesByProductId() : StoredProductAttributeCollection
- Returns a collection with all attribute entities that belongs to a product entity by the given product id.
- removeAttributeById() : ProductAttributeService|$this
- Removes a product attribute entity by the given product attribute id.
- removeAttributesByProductId() : ProductAttributeService|$this
- Removes product attributes by the given product id.
- updateAttribute() : $this|ProductAttributeService
- Updates the passed product attribute entity.
Properties
$productAttributeRepo
protected
ProductAttributeRepositoryInterface
$productAttributeRepo
Methods
__construct()
Initialize the product attribute service.
public
__construct(ProductAttributeRepositoryInterface $productAttributeRepo) : mixed
Parameters
- $productAttributeRepo : ProductAttributeRepositoryInterface
Return values
mixed —addAttribute()
Adds an product attribute to a product by the given id.
public
addAttribute(IdType $productId, ProductAttributeInterface $attribute) : int
Parameters
- $productId : IdType
-
Id of product entity that adds the attribute.
- $attribute : ProductAttributeInterface
-
Product attribute entity to add.
Return values
int —Id of inserted product attribute.
getAttributeById()
Returns a stored product attribute entity by the given product attribute id.
public
getAttributeById(IdType $productAttributeId) : StoredProductAttributeInterface
Parameters
- $productAttributeId : IdType
-
Id of expected product attribute entity.
Return values
StoredProductAttributeInterface —Expected stored product attribute entity.
getAttributesByProductId()
Returns a collection with all attribute entities that belongs to a product entity by the given product id.
public
getAttributesByProductId(IdType $productId) : StoredProductAttributeCollection
Parameters
- $productId : IdType
-
Id of product entity that contain the expected attributes.
Return values
StoredProductAttributeCollection —Collection with all attributes that belongs to the product.
removeAttributeById()
Removes a product attribute entity by the given product attribute id.
public
removeAttributeById(IdType $productAttributeId) : ProductAttributeService|$this
Parameters
- $productAttributeId : IdType
-
Id of product attribute entity that should be deleted.
Return values
ProductAttributeService|$this —Same instance for chained method calls.
removeAttributesByProductId()
Removes product attributes by the given product id.
public
removeAttributesByProductId(IdType $productId) : ProductAttributeService|$this
Parameters
- $productId : IdType
-
Id of product entity of the attributes that should be deleted.
Return values
ProductAttributeService|$this —Same instance for chained method calls.
updateAttribute()
Updates the passed product attribute entity.
public
updateAttribute(StoredProductAttributeInterface $attribute) : $this|ProductAttributeService
Parameters
- $attribute : StoredProductAttributeInterface
-
Product attribute entity to update.
Return values
$this|ProductAttributeService —Same instance for chained method calls.