phpDocumentor

CategoryRepositoryWriter
in package
implements CategoryRepositoryWriterInterface

Class CategoryRepositoryWriter

This class provides methods for creating and updating specific category records in the database and is used in the category repository among the classes for reading and deleting category records.

Tags
category

System

subpackage

Repositories

Interfaces, Classes and Traits

CategoryRepositoryWriterInterface
Interface CategoryRepositoryWriterInterface

Table of Contents

$categoriesTable  : string
$db  : CI_DB_query_builder
$languageProvider  : LanguageProviderInterface
__construct()  : mixed
CategoryRepositoryWriter constructor.
detachMainCategoryFromProducts()  : CategoryRepositoryWriter
Updates the "products" table with the lowest category ID attached to the product
insert()  : int
Inserts a category record into the database accordingly to the provided category object and returns the ID from the saved entity.
update()  : CategoryRepositoryWriter
Updates an existing category record accordingly to the provided category object.
_parseCategoryData()  : mixed
_parseCategoryDescriptionData()  : mixed

Properties

Methods

detachMainCategoryFromProducts()

Updates the "products" table with the lowest category ID attached to the product

public detachMainCategoryFromProducts(IdType $categoryId) : CategoryRepositoryWriter

Note:

  • If the product has only one category: updates with the lowest category id.
  • if the product has more than one category: updates with the lowest category id, excluding the ID 0.
Parameters
$categoryId : IdType
Return values
CategoryRepositoryWriter

insert()

Inserts a category record into the database accordingly to the provided category object and returns the ID from the saved entity.

public insert(CategoryInterface $category) : int
Parameters
$category : CategoryInterface

The category to insert.

Tags
throws
UnexpectedValueException

When no language id was found by the given language code.

throws
InvalidArgumentException
Return values
int

Returns the ID of the new category.

Search results