ProductRepository
in package
implements
ProductRepositoryInterface
Class ProductRepository
Tags
Interfaces, Classes and Traits
- ProductRepositoryInterface
- Interface ProductRepositoryInterface
Table of Contents
- $addonValueService : AddonValueServiceInterface
- $deleter : ProductRepositoryDeleterInterface
- $imageContainerRepo : ProductImageContainerRepositoryInterface
- $reader : ProductRepositoryReaderInterface
- $settingsRepo : ProductSettingsRepositoryInterface
- $urlRewriteStorage : UrlRewriteStorage
- $writer : ProductRepositoryWriterInterface
- __construct() : mixed
- Initialize the product repository.
- add() : int
- Adds a new product in the database.
- countImageUsage() : int
- deleteProductById() : ProductRepositoryInterface|$this
- Removes a product from the database by the given id.
- getProductById() : StoredProductInterface
- Gets a stored product by the given id.
- getProductsCount() : int
- Returns the count of all product entries.
- store() : ProductRepositoryInterface|$this
- Updates an existing product in the database.
Properties
$addonValueService
protected
AddonValueServiceInterface
$addonValueService
$deleter
protected
ProductRepositoryDeleterInterface
$deleter
$imageContainerRepo
protected
ProductImageContainerRepositoryInterface
$imageContainerRepo
$reader
protected
ProductRepositoryReaderInterface
$reader
$settingsRepo
protected
ProductSettingsRepositoryInterface
$settingsRepo
$urlRewriteStorage
protected
UrlRewriteStorage
$urlRewriteStorage
$writer
protected
ProductRepositoryWriterInterface
$writer
Methods
__construct()
Initialize the product repository.
public
__construct(ProductRepositoryReaderInterface $reader, ProductRepositoryWriterInterface $writer, ProductRepositoryDeleterInterface $deleter, ProductSettingsRepositoryInterface $settingsRepo, AddonValueServiceInterface $addonValueService, ProductImageContainerRepositoryInterface $imageContainerRepo, UrlRewriteStorage $urlRewriteStorage) : mixed
Parameters
- $reader : ProductRepositoryReaderInterface
-
Instance to perform db read actions.
- $writer : ProductRepositoryWriterInterface
-
Instance to perform db write actions.
- $deleter : ProductRepositoryDeleterInterface
-
Instance to perform db delete actions.
- $settingsRepo : ProductSettingsRepositoryInterface
-
Repository instance to read/write/delete product settings.
- $addonValueService : AddonValueServiceInterface
-
Service to handle product addon values.
- $imageContainerRepo : ProductImageContainerRepositoryInterface
-
Image container of the product.
- $urlRewriteStorage : UrlRewriteStorage
-
Url rewrite storage.
Return values
mixed —add()
Adds a new product in the database.
public
add(ProductInterface $product) : int
Parameters
- $product : ProductInterface
-
Product entity which holds the values for the database columns.
Tags
Return values
int —Id of inserted product.
countImageUsage()
public
countImageUsage(ProductImageInterface $productImage) : int
Parameters
- $productImage : ProductImageInterface
Tags
Return values
int —deleteProductById()
Removes a product from the database by the given id.
public
deleteProductById(IdType $productId) : ProductRepositoryInterface|$this
Parameters
- $productId : IdType
-
Id of expected product entity.
Return values
ProductRepositoryInterface|$this —Same instance for chained method calls.
getProductById()
Gets a stored product by the given id.
public
getProductById(IdType $productId) : StoredProductInterface
Parameters
- $productId : IdType
-
Id of expected product entity.
Return values
StoredProductInterface —Product entity with the expected product id.
getProductsCount()
Returns the count of all product entries.
public
getProductsCount() : int
Return values
int —store()
Updates an existing product in the database.
public
store(StoredProductInterface $product) : ProductRepositoryInterface|$this
Parameters
- $product : StoredProductInterface
-
Product entity to update.
Tags
Return values
ProductRepositoryInterface|$this —Same instance for chained method calls.