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
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'
$asset
protected
TImage|null
$asset
= null
$categories
protected
Collection<int, TCategory>
$categories
= new ArrayCollection()
$deleted
protected
bool
$deleted
= false
Attributes
- #[Column]
- $name: 'deleted'
- $type: 'boolean'
$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'
$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
$thisaddTranslation()
public
addTranslation(TTranslation $translation) : $this
Parameters
- $translation : TTranslation
Return values
$thisaddVariant()
public
addVariant(TVariant $variant) : $this
Parameters
- $variant : TVariant
Return values
$thiscallInitMethods()
Calls `init{TraitName}()` for every used trait that defines such a method.
public
callInitMethods() : void
categoryCollectionInit()
public
categoryCollectionInit() : void
clearCategories()
public
clearCategories() : $this
Return values
$thisclearVariants()
public
clearVariants() : $this
Return values
$thisgetActivated()
public
getActivated() : bool
Return values
boolgetAllTraits()
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|nullgetCategories()
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
boolgetFirstCategoryId()
public
getFirstCategoryId() : int|null
Return values
int|nullgetId()
public
getId() : int|null
Return values
int|nullgetInsertDate()
public
getInsertDate() : DateTime
Return values
DateTimegetProducer()
public
getProducer() : TProducer|null
Return values
TProducer|nullgetProductType()
public
getProductType() : TProductType|null
Return values
TProductType|nullgetTranslation()
public
getTranslation(int $langId) : TTranslation|null
Parameters
- $langId : int
Return values
TTranslation|nullgetTranslations()
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
boolisDeleted()
public
isDeleted() : bool
Return values
boolisPersisted()
public
isPersisted() : bool
Return values
boolremoveCategory()
public
removeCategory(TCategory $category) : $this
Parameters
- $category : TCategory
Return values
$thisremoveTranslation()
public
removeTranslation(TTranslation $translation) : $this
Parameters
- $translation : TTranslation
Return values
$thisremoveVariant()
public
removeVariant(TVariant $variant) : $this
Parameters
- $variant : TVariant
Return values
$thissetActivated()
public
setActivated(bool $activated) : $this
Parameters
- $activated : bool
Return values
$thissetAsset()
public
setAsset(TImage|null $asset) : $this
Parameters
- $asset : TImage|null
Return values
$thissetCategories()
public
setCategories(Collection<int, TCategory>|array<int, TCategory> $categories) : $this
Parameters
- $categories : Collection<int, TCategory>|array<int, TCategory>
Return values
$thissetDeleted()
public
setDeleted(bool $deleted) : $this
Parameters
- $deleted : bool
Return values
$thissetId()
public
setId(int|null $id) : $this
Parameters
- $id : int|null
Return values
$thissetInsertDate()
public
setInsertDate(DateTime $insertDate) : $this
Parameters
- $insertDate : DateTime
Return values
$thissetProducer()
public
setProducer(TProducer|null $producer) : $this
Parameters
- $producer : TProducer|null
Return values
$thissetProductType()
public
setProductType(TProductType|null $productType) : $this
Parameters
- $productType : TProductType|null
Return values
$thissetTranslations()
public
setTranslations(Collection<int, TTranslation>|array<int, TTranslation> $translations) : $this
Parameters
- $translations : Collection<int, TTranslation>|array<int, TTranslation>
Return values
$thissetVariants()
public
setVariants(Collection<int, TVariant>|array<int, TVariant> $variants) : $this
Parameters
- $variants : Collection<int, TVariant>|array<int, TVariant>
Return values
$thistranslationCollectionInit()
public
translationCollectionInit() : void
variantCollectionInit()
public
variantCollectionInit() : void
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>