CategoryWriteService
in package
implements
CategoryWriteServiceInterface
Class CategoryWriteService
This class provides methods for creating, updating and deleting categories data.
Tags
Interfaces, Classes and Traits
- CategoryWriteServiceInterface
- Interface CategoryWriteServiceInterface
Table of Contents
- $cacheControl : CacheControl
- $categoryIconStorage : AbstractFileStorage
- Category icon.
- $categoryImageStorage : AbstractFileStorage
- Category image.
- $categoryOpenGraphImageStorage : AbstractFileStorage
- Category OpenGraph image.
- $categoryRepo : CategoryRepositoryInterface
- Category repository.
- $productPermissionSetter : ProductPermissionSetterInterface
- ProductPermissionSetter
- $urlKeywordsRepairer : UrlKeywordsRepairerInterface
- Used for writing and repairing category's url keywords
- __construct() : mixed
- CategoryWriteService constructor.
- activateCategory() : CategoryWriteServiceInterface
- Activates a specific category and its subcategories if desired.
- createCategory() : int
- Stores a category in the database and returns the newly created ID of it.
- deactivateCategory() : CategoryWriteServiceInterface
- Deactivates a specific category and its subcategories if desired.
- deleteCategoryById() : CategoryWriteService
- Deletes a category depending on the provided category ID.
- deleteCategoryIconFile() : CategoryWriteServiceInterface
- Deletes a category icon file.
- deleteCategoryImageFile() : CategoryWriteServiceInterface
- Deletes a category image file.
- deleteCategoryOpenGraphImageFile() : CategoryWriteServiceInterface
- Deletes a category icon file.
- duplicateCategory() : int
- Duplicates a category specified by its category ID.
- importCategoryIconFile() : string
- Imports an icon file and stores it.
- importCategoryImageFile() : string
- Imports an image file and stores it.
- importCategoryOpenGraphImageFile() : string
- Imports an OpenGraph image file and stores it.
- moveCategory() : CategoryWriteService
- Moves a category into another category.
- renameCategoryIconFile() : CategoryWriteServiceInterface
- Renames a category icon file.
- renameCategoryImageFile() : CategoryWriteServiceInterface
- Renames a category image file.
- renameCategoryOpenGraphImageFile() : CategoryWriteServiceInterface
- Renames a category OpenGraph image file.
- setCustomerStatusPermission() : CategoryWriteServiceInterface
- Sets the customer status permissions.
- updateCategory() : CategoryWriteService
- Updates the provided category and returns itself.
Properties
$cacheControl
protected
CacheControl
$cacheControl
$categoryIconStorage
Category icon.
protected
AbstractFileStorage
$categoryIconStorage
$categoryImageStorage
Category image.
protected
AbstractFileStorage
$categoryImageStorage
$categoryOpenGraphImageStorage
Category OpenGraph image.
protected
AbstractFileStorage
$categoryOpenGraphImageStorage
$categoryRepo
Category repository.
protected
CategoryRepositoryInterface
$categoryRepo
$productPermissionSetter
ProductPermissionSetter
protected
ProductPermissionSetterInterface
$productPermissionSetter
$urlKeywordsRepairer
Used for writing and repairing category's url keywords
protected
UrlKeywordsRepairerInterface
$urlKeywordsRepairer
Methods
__construct()
CategoryWriteService constructor.
public
__construct(CategoryRepositoryInterface $categoryRepo, AbstractFileStorage $categoryImageStorage, AbstractFileStorage $categoryIconStorage, AbstractFileStorage $categoryOpenGraphImageStorage, ProductPermissionSetterInterface $productPermissionSetter, UrlKeywordsRepairerInterface $urlKeywordsRepairer, CacheControl $cacheControl) : mixed
Parameters
- $categoryRepo : CategoryRepositoryInterface
-
Category repository.
- $categoryImageStorage : AbstractFileStorage
-
Category image.
- $categoryIconStorage : AbstractFileStorage
-
Category icon.
- $categoryOpenGraphImageStorage : AbstractFileStorage
-
Category OpenGraph image.
- $productPermissionSetter : ProductPermissionSetterInterface
-
ProductPermissionSetter.
- $urlKeywordsRepairer : UrlKeywordsRepairerInterface
-
Repairs urls.
- $cacheControl : CacheControl
-
Used to reset category cache.
Return values
mixed —activateCategory()
Activates a specific category and its subcategories if desired.
public
activateCategory(IdType $categoryId, BoolType $includeSubcategories) : CategoryWriteServiceInterface
Parameters
- $categoryId : IdType
-
Category ID of the category to activate.
- $includeSubcategories : BoolType
-
Shall the subcategories be activated also?
Return values
CategoryWriteServiceInterface —Same instance for chained method calls.
createCategory()
Stores a category in the database and returns the newly created ID of it.
public
createCategory(CategoryInterface $category) : int
Parameters
- $category : CategoryInterface
-
The category to store.
Return values
int —Returns the ID of the new category record.
deactivateCategory()
Deactivates a specific category and its subcategories if desired.
public
deactivateCategory(IdType $categoryId, BoolType $includeSubcategories) : CategoryWriteServiceInterface
Parameters
- $categoryId : IdType
-
Category ID of the category to deactivate.
- $includeSubcategories : BoolType
-
Shall the subcategories be deactivated also?
Return values
CategoryWriteServiceInterface —Same instance for chained method calls.
deleteCategoryById()
Deletes a category depending on the provided category ID.
public
deleteCategoryById(IdType $categoryId) : CategoryWriteService
Parameters
- $categoryId : IdType
-
Category ID of the category to delete.
Return values
CategoryWriteService —Same instance for chained method calls.
deleteCategoryIconFile()
Deletes a category icon file.
public
deleteCategoryIconFile(FilenameStringType $filename) : CategoryWriteServiceInterface
Parameters
- $filename : FilenameStringType
-
Category icon file name.
Return values
CategoryWriteServiceInterface —Same instance for chained method calls.
deleteCategoryImageFile()
Deletes a category image file.
public
deleteCategoryImageFile(FilenameStringType $filename) : CategoryWriteServiceInterface
Parameters
- $filename : FilenameStringType
-
Category image file name.
Return values
CategoryWriteServiceInterface —Same instance for chained method calls.
deleteCategoryOpenGraphImageFile()
Deletes a category icon file.
public
deleteCategoryOpenGraphImageFile(FilenameStringType $filename) : CategoryWriteServiceInterface
Parameters
- $filename : FilenameStringType
-
Category icon file name.
Return values
CategoryWriteServiceInterface —Same instance for chained method calls.
duplicateCategory()
Duplicates a category specified by its category ID.
public
duplicateCategory(IdType $categoryId, IdType $targetParentId[, BoolType $duplicateProducts = null ][, BoolType $duplicateAttributes = null ][, BoolType $duplicateSpecials = null ][, BoolType $duplicateCrossSelling = null ]) : int
This method duplicates the category which are identified by the provided category ID and links the duplicated category with the provided parent category ID. Containing subcategories and products will also be recursively duplicated with their attributes, specials and cross selling data depending on the last four arguments.
Parameters
- $categoryId : IdType
-
The category ID of the category to duplicate.
- $targetParentId : IdType
-
The target parent ID of the duplicated category.
- $duplicateProducts : BoolType = null
-
Should the products be duplicated?
- $duplicateAttributes : BoolType = null
-
Should the attributes be duplicated?
- $duplicateSpecials : BoolType = null
-
Should the specials be duplicated?
- $duplicateCrossSelling : BoolType = null
-
Should cross selling be duplicated?
Tags
Return values
int —Returns the ID of the new category record.
importCategoryIconFile()
Imports an icon file and stores it.
public
importCategoryIconFile(ExistingFile $sourceFile, FilenameStringType $saveAsFilename) : string
Parameters
- $sourceFile : ExistingFile
-
The icon file to import.
- $saveAsFilename : FilenameStringType
-
The name under which the icon should be stored.
Return values
string —The new filename.
importCategoryImageFile()
Imports an image file and stores it.
public
importCategoryImageFile(ExistingFile $sourceFile, FilenameStringType $saveAsFilename) : string
Parameters
- $sourceFile : ExistingFile
-
The image file to import.
- $saveAsFilename : FilenameStringType
-
The name under which the image should to be stored.
Return values
string —The new filename.
importCategoryOpenGraphImageFile()
Imports an OpenGraph image file and stores it.
public
importCategoryOpenGraphImageFile(ExistingFile $sourceFile, FilenameStringType $saveAsFilename) : string
Parameters
- $sourceFile : ExistingFile
-
The image file to import.
- $saveAsFilename : FilenameStringType
-
The name under which the image should be stored.
Return values
string —The new filename.
moveCategory()
Moves a category into another category.
public
moveCategory(IdType $categoryId, IdType $newParentId) : CategoryWriteService
This method moves a category specified by its category ID into another parent category specified by its category ID.
Parameters
Return values
CategoryWriteService —Same instance for chained method calls.
renameCategoryIconFile()
Renames a category icon file.
public
renameCategoryIconFile(FilenameStringType $oldName, FilenameStringType $newName) : CategoryWriteServiceInterface
Parameters
- $oldName : FilenameStringType
-
Old file name.
- $newName : FilenameStringType
-
New file name.
Return values
CategoryWriteServiceInterface —Same instance for chained method calls.
renameCategoryImageFile()
Renames a category image file.
public
renameCategoryImageFile(FilenameStringType $oldName, FilenameStringType $newName) : CategoryWriteServiceInterface
Parameters
- $oldName : FilenameStringType
-
Old file name.
- $newName : FilenameStringType
-
New file name.
Return values
CategoryWriteServiceInterface —Same instance for chained method calls.
renameCategoryOpenGraphImageFile()
Renames a category OpenGraph image file.
public
renameCategoryOpenGraphImageFile(FilenameStringType $oldName, FilenameStringType $newName) : CategoryWriteServiceInterface
Parameters
- $oldName : FilenameStringType
-
Old file name.
- $newName : FilenameStringType
-
New file name.
Return values
CategoryWriteServiceInterface —Same instance for chained method calls.
setCustomerStatusPermission()
Sets the customer status permissions.
public
setCustomerStatusPermission(IdType $categoryId, IdType $customerStatusId, BoolType $permitted, BoolType $includeSubcategoriesAndProducts) : CategoryWriteServiceInterface
The customer status permissions decides if the category is visible for a specific customer group. The permissions can be applied for subcategories also if desired.
Parameters
- $categoryId : IdType
-
Category ID.
- $customerStatusId : IdType
-
Customer status ID.
- $permitted : BoolType
-
Grant permission?
- $includeSubcategoriesAndProducts : BoolType
-
Grant permission including subcategories?
Return values
CategoryWriteServiceInterface —Same instance for chained method calls.
updateCategory()
Updates the provided category and returns itself.
public
updateCategory(StoredCategoryInterface $category) : CategoryWriteService
Parameters
- $category : StoredCategoryInterface
-
The category to update.
Return values
CategoryWriteService —Same instance for chained method calls.