CoolCMS API

StockItem extends StockItem
in package

Stock item; the admin object graph maps only the translations collection.

Levels and batches are server-managed and deliberately not mapped as collections here, because a full-replace save would wipe the stock state. They are read via StockReader into transient properties.

Tags
extends
Attributes
#[Entity]
#[Table]
$name: 'cms_mod_store_stock_items'
#[TableAlias]
'stockItem'

Table of Contents

Properties

$activated  : bool
$avgPurchasePrice  : string|null
$code  : string
$ean  : string|null
$externalId  : int|null
$externalModule  : int|null
$id  : int|null
$insertDatetime  : DateTime
$lastPurchasePrice  : string|null
$minQuantity  : string|null
$sumAvailable  : string|null
$sumQuantity  : string|null
$sumReserved  : string|null
$supplier  : Supplier|null
$supplierId  : int|null
$translations  : Collection
$unit  : string
$unitId  : int|null
$updateDatetime  : DateTime|null

Methods

__construct()  : mixed
addTranslation()  : $this
callInitMethods()  : void
Calls `init{TraitName}()` for every used trait that defines such a method.
getActivated()  : bool
getAllTraits()  : array<string, string>
Returns all traits the class uses, including those used by parent classes and nested traits.
getAvgPurchasePrice()  : string|null
getCode()  : string
getEan()  : string|null
getExternalId()  : int|null
getExternalModule()  : int|null
getId()  : int|null
getInsertDatetime()  : DateTime
getLastPurchasePrice()  : string|null
getMinQuantity()  : string|null
getSumAvailable()  : string|null
getSumQuantity()  : string|null
getSumReserved()  : string|null
getSupplier()  : Supplier|null
getSupplierId()  : int|null
getTranslation()  : TTranslation|null
getTranslations()  : Collection<int, TTranslation>
getUnit()  : string
getUnitId()  : int|null
getUpdateDatetime()  : DateTime|null
isActivated()  : bool
isLowStock()  : bool
Returns whether the available sum over all warehouses is below the minimum stock (false until the decorator has run).
isPersisted()  : bool
removeTranslation()  : $this
setActivated()  : $this
setAvgPurchasePrice()  : $this
setCode()  : $this
setEan()  : $this
setExternalId()  : $this
setExternalModule()  : $this
setId()  : $this
setInsertDatetime()  : $this
setLastPurchasePrice()  : $this
setMinQuantity()  : $this
setSumAvailable()  : self
setSumQuantity()  : self
setSumReserved()  : self
setSupplier()  : self
setSupplierId()  : $this
setTranslations()  : $this
setUnit()  : $this
setUnitId()  : TTranslation>
setUpdateDatetime()  : $this
translationCollectionInit()  : void
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.
n()  : numeric-string

Properties

$avgPurchasePrice

protected string|null $avgPurchasePrice = null
Attributes
#[Column]
$name: 'avg_purchase_price'
$type: 'decimal'
$precision: 10
$scale: 3
$nullable: true
#[ExternalReadonly]

$code

protected string $code = ''
Attributes
#[Column]
$name: 'code'
$type: 'string'
$length: 80

$ean

protected string|null $ean = null
Attributes
#[Column]
$name: 'ean'
$type: 'string'
$length: 45
$nullable: true

$externalId

protected int|null $externalId = null
Attributes
#[Column]
$name: 'external_id'
$type: 'integer'
$nullable: true
$options: ['unsigned' => true]
#[ExternalReadonly]

$externalModule

protected int|null $externalModule = null
Attributes
#[Column]
$name: 'external_module'
$type: 'integer'
$nullable: true
$options: ['unsigned' => true]
#[ExternalReadonly]

$id

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

$insertDatetime

protected DateTime $insertDatetime = new DateTime()
Attributes
#[Column]
$name: 'insert_datetime'
$type: 'datetime'
#[ExternalReadonly]

$lastPurchasePrice

protected string|null $lastPurchasePrice = null
Attributes
#[Column]
$name: 'last_purchase_price'
$type: 'decimal'
$precision: 10
$scale: 3
$nullable: true
#[ExternalReadonly]

$minQuantity

protected string|null $minQuantity = null
Attributes
#[Column]
$name: 'min_quantity'
$type: 'decimal'
$precision: 10
$scale: 3
$nullable: true

$supplier

protected Supplier|null $supplier = null
Attributes
#[EntityOf]
\App\UI\Admin\Store\Models\Entities\Supplier::class
#[JoinColumn]
$name: 'cms_mod_store_suppliers_supplier_id'
$referencedColumnName: 'supplier_id'
$onDelete: 'SET NULL'
#[ManyToOne]
$targetEntity: \App\UI\Admin\Store\Models\Entities\Supplier::class

$supplierId

protected int|null $supplierId = null
Attributes
#[Column]
$name: 'cms_mod_store_suppliers_supplier_id'
$type: 'integer'
$insertable: false
$updatable: false
$nullable: true
$options: ['unsigned' => true]

$translations

protected Collection $translations
Attributes
#[CollectionOf]
\App\UI\Admin\Store\Models\Entities\StockItemText::class
$owned: true
#[OneToMany]
$targetEntity: \App\UI\Admin\Store\Models\Entities\StockItemText::class
$mappedBy: 'parent'
$cascade: ['persist', 'remove']
$orphanRemoval: true
$fetch: 'LAZY'

$unit

protected string $unit = 'ks'
Attributes
#[Column]
$name: 'unit'
$type: 'string'
$length: 20

$unitId

protected int|null $unitId = null
Attributes
#[Column]
$name: 'cms_system_units_unit_id'
$type: 'integer'
$nullable: true
$options: ['unsigned' => true]

$updateDatetime

protected DateTime|null $updateDatetime = null
Attributes
#[Column]
$name: 'update_datetime'
$type: 'datetime'
$nullable: true
#[ExternalReadonly]

Methods

__construct()

public __construct([int|null $id = null ][, string $code = '' ][, string|null $ean = null ][, string $unit = 'ks' ][, int|null $unitId = null ][, int|null $supplierId = null ][, int|null $externalModule = null ][, int|null $externalId = null ][, string|null $minQuantity = null ][, string|null $avgPurchasePrice = null ][, string|null $lastPurchasePrice = null ][, bool $activated = true ][, DateTime $insertDatetime = new DateTime() ][, DateTime|null $updateDatetime = null ][, Collection $translations = new ArrayCollection() ]) : mixed
Parameters
$id : int|null = null
$code : string = ''
$ean : string|null = null
$unit : string = 'ks'
$unitId : int|null = null
$supplierId : int|null = null
$externalModule : int|null = null
$externalId : int|null = null
$minQuantity : string|null = null
$avgPurchasePrice : string|null = null
$lastPurchasePrice : string|null = null
$activated : bool = true
$insertDatetime : DateTime = new DateTime()
$updateDatetime : DateTime|null = null
$translations : Collection = new ArrayCollection()

addTranslation()

public addTranslation(TTranslation $translation) : $this
Parameters
$translation : TTranslation
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>

getAvgPurchasePrice()

public getAvgPurchasePrice() : string|null
Return values
string|null

getCode()

public getCode() : string
Return values
string

getEan()

public getEan() : string|null
Return values
string|null

getExternalId()

public getExternalId() : int|null
Return values
int|null

getExternalModule()

public getExternalModule() : int|null
Return values
int|null

getInsertDatetime()

public getInsertDatetime() : DateTime
Return values
DateTime

getLastPurchasePrice()

public getLastPurchasePrice() : string|null
Return values
string|null

getMinQuantity()

public getMinQuantity() : string|null
Return values
string|null

getSumAvailable()

public getSumAvailable() : string|null
Return values
string|null

getSumQuantity()

public getSumQuantity() : string|null
Return values
string|null

getSumReserved()

public getSumReserved() : string|null
Return values
string|null

getSupplierId()

public getSupplierId() : int|null
Return values
int|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>

getUnit()

public getUnit() : string
Return values
string

getUnitId()

public getUnitId() : int|null
Return values
int|null

getUpdateDatetime()

public getUpdateDatetime() : DateTime|null
Return values
DateTime|null

isActivated()

public isActivated() : bool
Return values
bool

isLowStock()

Returns whether the available sum over all warehouses is below the minimum stock (false until the decorator has run).

public isLowStock() : bool
Return values
bool

removeTranslation()

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

setActivated()

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

setAvgPurchasePrice()

public setAvgPurchasePrice(string|null $avgPurchasePrice) : $this
Parameters
$avgPurchasePrice : string|null
Return values
$this

setCode()

public setCode(string $code) : $this
Parameters
$code : string
Return values
$this

setEan()

public setEan(string|null $ean) : $this
Parameters
$ean : string|null
Return values
$this

setExternalId()

public setExternalId(int|null $externalId) : $this
Parameters
$externalId : int|null
Return values
$this

setExternalModule()

public setExternalModule(int|null $externalModule) : $this
Parameters
$externalModule : int|null
Return values
$this

setId()

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

setInsertDatetime()

public setInsertDatetime(DateTime $insertDatetime) : $this
Parameters
$insertDatetime : DateTime
Return values
$this

setLastPurchasePrice()

public setLastPurchasePrice(string|null $lastPurchasePrice) : $this
Parameters
$lastPurchasePrice : string|null
Return values
$this

setMinQuantity()

public setMinQuantity(string|null $minQuantity) : $this
Parameters
$minQuantity : string|null
Return values
$this

setSumAvailable()

public setSumAvailable(string|null $sumAvailable) : self
Parameters
$sumAvailable : string|null
Return values
self

setSumQuantity()

public setSumQuantity(string|null $sumQuantity) : self
Parameters
$sumQuantity : string|null
Return values
self

setSumReserved()

public setSumReserved(string|null $sumReserved) : self
Parameters
$sumReserved : string|null
Return values
self

setSupplierId()

public setSupplierId(int|null $supplierId) : $this
Parameters
$supplierId : int|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

setUnit()

public setUnit(string $unit) : $this
Parameters
$unit : string
Return values
$this

setUnitId()

public setUnitId(int|null $unitId) : TTranslation>
Parameters
$unitId : int|null
Return values
TTranslation>

setUpdateDatetime()

public setUpdateDatetime(DateTime|null $updateDatetime) : $this
Parameters
$updateDatetime : DateTime|null
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>

n()

private n(string $value) : numeric-string
Parameters
$value : string
Return values
numeric-string —

bcmath wrapper (normalizes a plain string)

On this page

Search results