CoolCMS API

Product extends BaseEntity
in package
implements IdentifiableInterface uses IdentifiableTrait, TranslationCollectionTrait, CategoryCollectionTrait, VariantCollectionTrait

AbstractYes

Abstract product card: the common base of 1..n sellable `ProductSet`s (via `product_sets.cms_mod_eshop_products_product_id`, nullable for bundle sets without a single owner). Categories stay here as many-to-many.

Tags
template
Attributes
#[MappedSuperclass]
#[TableAlias]
$alias: 'product'

Table of Contents

Interfaces

IdentifiableInterface
Entity with a simple integer primary key. Most entities have one (often via {@see \App\Core\Traits\Shared\Models\Entities\IdentifiableTrait}); texts and links with a composite key do not, which is why `getId()` is not on {@see \App\Core\Base\BaseEntity}. Code that needs the id of a generic entity asks for this interface (parameter type, template bound, `instanceof`).

Properties

$activated  : bool
$asset  : TImage|null
$categories  : Collection<int, TCategory>
$deleted  : bool
$id  : int|null
$insertDate  : DateTime
$producer  : TProducer|null
$productType  : TProductType|null
$translations  : Collection<int, TTranslation>
$variants  : Collection<int, TVariant>

Methods

__construct()  : mixed
addCategory()  : $this
addTranslation()  : $this
addVariant()  : $this
callInitMethods()  : void
Calls `init{TraitName}()` for every used trait that defines such a method.
categoryCollectionInit()  : void
clearCategories()  : $this
clearVariants()  : $this
getActivated()  : bool
getAllTraits()  : array<string, string>
Returns all traits the class uses, including those used by parent classes and nested traits.
getAsset()  : TImage|null
getCategories()  : Collection<int, TCategory>
getCategoryIds()  : array<string|int, int>
getDeleted()  : bool
getFirstCategoryId()  : int|null
getId()  : int|null
getInsertDate()  : DateTime
getProducer()  : TProducer|null
getProductType()  : TProductType|null
getTranslation()  : TTranslation|null
getTranslations()  : Collection<int, TTranslation>
getVariants()  : Collection<int, TVariant>
isActivated()  : bool
isDeleted()  : bool
isPersisted()  : bool
removeCategory()  : $this
removeTranslation()  : $this
removeVariant()  : $this
setActivated()  : $this
setAsset()  : $this
setCategories()  : $this
setDeleted()  : $this
setId()  : $this
setInsertDate()  : $this
setProducer()  : $this
setProductType()  : $this
setTranslations()  : $this
setVariants()  : $this
translationCollectionInit()  : void
variantCollectionInit()  : void
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.

Properties

$activated

protected bool $activated = true
Attributes
#[Column]
$name: 'activated'
$type: 'boolean'
#[ExternalReadonly]

$asset

protected TImage|null $asset = null

$categories

protected Collection<int, TCategory> $categories = new ArrayCollection()

$id

protected int|null $id = null
Attributes
#[Column]
$name: 'product_id'
$type: 'integer'
$options: ['unsigned' => true]
#[GeneratedValue]
#[Id]

$insertDate

protected DateTime $insertDate = new DateTime()
Attributes
#[Column]
$name: 'insert_date'
$type: 'date'
#[ExternalReadonly]

$producer

protected TProducer|null $producer = null

$productType

protected TProductType|null $productType = null

$translations

protected Collection<int, TTranslation> $translations = new ArrayCollection()

$variants

protected Collection<int, TVariant> $variants = new ArrayCollection()

Methods

__construct()

public __construct([int|null $id = null ][, bool $activated = true ][, bool $deleted = false ][, mixed $producer = null ][, DateTime $insertDate = new DateTime() ][, mixed $asset = null ][, mixed $productType = null ][, Collection $translations = new ArrayCollection() ][, Collection $categories = new ArrayCollection() ][, Collection $variants = new ArrayCollection() ]) : mixed
Parameters
$id : int|null = null
$activated : bool = true
$deleted : bool = false
$producer : mixed = null
$insertDate : DateTime = new DateTime()
$asset : mixed = null
$productType : mixed = null
$translations : Collection = new ArrayCollection()
$categories : Collection = new ArrayCollection()
$variants : Collection = new ArrayCollection()

addCategory()

public addCategory(TCategory $category) : $this
Parameters
$category : TCategory
Return values
$this

addTranslation()

public addTranslation(TTranslation $translation) : $this
Parameters
$translation : TTranslation
Return values
$this

addVariant()

public addVariant(TVariant $variant) : $this
Parameters
$variant : TVariant
Return values
$this

callInitMethods()

Calls `init{TraitName}()` for every used trait that defines such a method.

public callInitMethods() : void

getActivated()

public getActivated() : bool
Return values
bool

getAllTraits()

Returns all traits the class uses, including those used by parent classes and nested traits.

public getAllTraits() : array<string, string>
Return values
array<string, string>

getAsset()

public getAsset() : TImage|null
Return values
TImage|null

getCategories()

public getCategories() : Collection<int, TCategory>
Return values
Collection<int, TCategory>

getCategoryIds()

public getCategoryIds() : array<string|int, int>
Return values
array<string|int, int>

getDeleted()

public getDeleted() : bool
Return values
bool

getInsertDate()

public getInsertDate() : DateTime
Return values
DateTime

getProducer()

public getProducer() : TProducer|null
Return values
TProducer|null

getProductType()

public getProductType() : TProductType|null
Return values
TProductType|null

getTranslation()

public getTranslation(int $langId) : TTranslation|null
Parameters
$langId : int
Return values
TTranslation|null

getTranslations()

public getTranslations() : Collection<int, TTranslation>
Return values
Collection<int, TTranslation>

getVariants()

public getVariants() : Collection<int, TVariant>
Return values
Collection<int, TVariant>

isActivated()

public isActivated() : bool
Return values
bool

isDeleted()

public isDeleted() : bool
Return values
bool

removeCategory()

public removeCategory(TCategory $category) : $this
Parameters
$category : TCategory
Return values
$this

removeTranslation()

public removeTranslation(TTranslation $translation) : $this
Parameters
$translation : TTranslation
Return values
$this

removeVariant()

public removeVariant(TVariant $variant) : $this
Parameters
$variant : TVariant
Return values
$this

setActivated()

public setActivated(bool $activated) : $this
Parameters
$activated : bool
Return values
$this

setAsset()

public setAsset(TImage|null $asset) : $this
Parameters
$asset : TImage|null
Return values
$this

setCategories()

public setCategories(Collection<int, TCategory>|array<int, TCategory> $categories) : $this
Parameters
$categories : Collection<int, TCategory>|array<int, TCategory>
Return values
$this

setDeleted()

public setDeleted(bool $deleted) : $this
Parameters
$deleted : bool
Return values
$this

setId()

public setId(int|null $id) : $this
Parameters
$id : int|null
Return values
$this

setInsertDate()

public setInsertDate(DateTime $insertDate) : $this
Parameters
$insertDate : DateTime
Return values
$this

setProducer()

public setProducer(TProducer|null $producer) : $this
Parameters
$producer : TProducer|null
Return values
$this

setProductType()

public setProductType(TProductType|null $productType) : $this
Parameters
$productType : TProductType|null
Return values
$this

setTranslations()

public setTranslations(Collection<int, TTranslation>|array<int, TTranslation> $translations) : $this
Parameters
$translations : Collection<int, TTranslation>|array<int, TTranslation>
Return values
$this

setVariants()

public setVariants(Collection<int, TVariant>|array<int, TVariant> $variants) : $this
Parameters
$variants : Collection<int, TVariant>|array<int, TVariant>
Return values
$this

getTraitsRecursive()

Walks the trait list recursively and collects nested traits too.

private static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
$traits : array<string, string>
Return values
array<string, string>
On this page

Search results