ProductWriteService

Implements \ProductWriteServiceInterface

Class ProductWriteService

category

System

package

Product

Methods

ProductWriteService constructor.

__construct(\ProductRepositoryInterface $productRepo, \AbstractFileStorage $productImageStorage, \ProductCategoryLinkerInterface $productLinker, \ProductImagePathsSettingsInterface $envProductImagePathsSettings, \LanguageProviderInterface $languageProvider, \UrlKeywordsRepairerInterface $urlKeywordsRepairer, \DeleteHistoryWriteService $deleteHistoryService) 

Arguments

$productImageStorage

\AbstractFileStorage

$envProductImagePathsSettings

\ProductImagePathsSettingsInterface

$languageProvider

\LanguageProviderInterface

$urlKeywordsRepairer

\UrlKeywordsRepairerInterface

$deleteHistoryService

\DeleteHistoryWriteService

Create Product

createProduct(\ProductInterface $product) : integer

Creates a new product and returns the ID of it.

Throws
\InvalidArgumentException

Through "linkProduct" method.

Arguments

$product

\ProductInterface

The product to create.

Response

integer

The ID of the created product.

Delete Product

deleteProductById(\IdType $productId) : \ProductWriteServiceInterface

Deletes a specific product, depending on the provided product ID.

Arguments

$productId

\IdType

The product ID of the product to delete.

Response

\ProductWriteServiceInterface

Same instance for chained method calls.

Delete Product Image

deleteProductImage(\FilenameStringType $filename) : \ProductWriteService

Deletes a product image.

Arguments

$filename

\FilenameStringType

The filename of the product image to delete.

Response

\ProductWriteService

Same instance for chained method calls.

Duplicate Product

duplicateProduct(\IdType $productId, \IdType $targetCategoryId, \BoolType $duplicateAttributes = null, \BoolType $duplicateSpecials = null, \BoolType $duplicateCrossSelling = null) : integer

Duplicates a product to a category.

todo

Implement the last three arguments when finished in UML.

Throws
\InvalidArgumentException

If "$newProductId" is not an integer.

Arguments

$productId

\IdType

The product ID of the product to duplicate.

$targetCategoryId

\IdType

The target category ID of the product to be duplicated to.s

$duplicateAttributes

\BoolType

Should the attributes be duplicated also?

$duplicateSpecials

\BoolType

Should the specials be duplicated also?

$duplicateCrossSelling

\BoolType

Should cross selling be duplicated also?

Response

integer

Returns the ID of the new product.

Duplicates a given Product Image and set the properties accordingly to the provided Source Product Image

duplicateProductImage(\ProductImageInterface $sourceProductImage) : \ProductImageInterface

Arguments

$sourceProductImage

\ProductImageInterface

The Product Image to duplicate.

Response

\ProductImageInterface

The duplicated Product Image.

Import Product Image File

importProductImageFile(\ExistingFile $sourceFile, \FilenameStringType $preferredFilename) : string

Imports an image for the product.

Throws
\InvalidArgumentException

If the provided source file or the preferred filename is not valid.

Arguments

$sourceFile

\ExistingFile

The existing file to import.

$preferredFilename

\FilenameStringType

The preferred filename.

Response

string

The new filename.

Link Product

linkProduct(\IdType $productId, \IdType $targetCategoryId) : \ProductWriteService

Links a product to a category.

Arguments

$productId

\IdType

The product ID of the product to link.

$targetCategoryId

\IdType

The target category ID, of the category to be linked to.

Response

\ProductWriteService

Same instance for chained method calls.

Processes an image for the front end.

processProductImage(\FilenameStringType $productImage) : \ProductWriteService

Arguments

$productImage

\FilenameStringType

Response

\ProductWriteService

Same instance for chained method calls.

Rename Product Image File

renameProductImage(\FilenameStringType $oldName, \FilenameStringType $newName) : \ProductWriteService

Renames a product image file.

Throws
\InvalidArgumentException

If the provided old name or new name is not valid.

Arguments

$oldName

\FilenameStringType

The old name of the product image file.

$newName

\FilenameStringType

The new name of the product image file.

Response

\ProductWriteService

Same instance for chained method calls.

Unlink a product.

unlinkProduct(\IdType $productId, \IdCollection $categoryIds) : \ProductWriteServiceInterface|$this

Deletes the product if all category links are removed.

Arguments

$productId

\IdType

Id of product to be unlinked.

$categoryIds

\IdCollection

Ids of categories to be unlinked.

Response

\ProductWriteServiceInterface|$this

Same instance for chained method calls.

Update Product

updateProduct(\StoredProductInterface $product) : \ProductWriteServiceInterface

Updates a stored product.

Arguments

$product

\StoredProductInterface

The product to update.

Response

\ProductWriteServiceInterface

Same instance for chained method calls.

Properties

The product repository.

productRepo : \ProductRepositoryInterface

The product image storage.

productImageStorage : \AbstractFileStorage
var

Type(s)

\AbstractFileStorage

The product category linker.

productLinker : \ProductCategoryLinkerInterface

EnvProductImagePathsSettings.

envProductImagePathsSettings : \ProductImagePathsSettingsInterface

Used for fetching the language data.

languageProvider : \LanguageProviderInterface

Used for writing and repairing product's url keywords

urlKeywordsRepairer : \UrlKeywordsRepairerInterface

deleteHistoryService

deleteHistoryService : \DeleteHistoryWriteService