Documentation

Mage_CatalogInventory_Model_Stock_Item extends Mage_Core_Model_Abstract
in package

Catalog Inventory Stock Model

Table of Contents

Constants

ENTITY  : mixed = 'cataloginventory_stock_item'
XML_PATH_BACKORDERS  : mixed = 'cataloginventory/item_options/backorders'
XML_PATH_CAN_BACK_IN_STOCK  : mixed = 'cataloginventory/options/can_back_in_stock'
XML_PATH_CAN_SUBTRACT  : mixed = 'cataloginventory/options/can_subtract'
XML_PATH_ENABLE_QTY_INCREMENTS  : mixed = 'cataloginventory/item_options/enable_qty_incre...
XML_PATH_GLOBAL  : mixed = 'cataloginventory/options/'
XML_PATH_ITEM  : mixed = 'cataloginventory/item_options/'
XML_PATH_MANAGE_STOCK  : mixed = 'cataloginventory/item_options/manage_stock'
XML_PATH_MAX_SALE_QTY  : mixed = 'cataloginventory/item_options/max_sale_qty'
XML_PATH_MIN_QTY  : mixed = 'cataloginventory/item_options/min_qty'
XML_PATH_MIN_SALE_QTY  : mixed = 'cataloginventory/item_options/min_sale_qty'
XML_PATH_NOTIFY_STOCK_QTY  : mixed = 'cataloginventory/item_options/notify_stock_qty'
XML_PATH_QTY_INCREMENTS  : mixed = 'cataloginventory/item_options/qty_increments'
XML_PATH_SYNC_AVAIL_WITH_QTY  : mixed = 'cataloginventory/options/sync_stock_availabili...

Properties

$_cacheTag  : string|bool|array<string|int, mixed>
Model cache tag for clear cache in after save and after delete
$_customerGroupId  : int|null
Customer group id
$_data  : array<string|int, mixed>|null
Object attributes
$_dataSaveAllowed  : bool
Flag which can stop data saving after before save Can be used for next sequence: we check data in _beforeSave, if data are not valid - we can set this flag to false value and save process will be stopped
$_dirty  : array<string|int, mixed>
$_eventObject  : string
Parameter name in event
$_eventPrefix  : string
Prefix of model events names
$_hasDataChanges  : bool
Data changes flag (true after setData|unsetData call)
$_idFieldName  : string
Name of object id field
$_isDeleted  : bool
Object delete flag
$_isObjectNew  : bool|null
Flag which allow detect object state: is it new object (without id) or existing one (with id)
$_oldFieldsMap  : array<string|int, mixed>
Map short fields names to its full names
$_origData  : array<string|int, mixed>|null
Original data that was loaded
$_processIndexEvents  : bool
Whether index events should be processed immediately
$_productInstance  : Mage_Catalog_Model_Product|null
Associated product instance
$_qtyIncrements  : float|false
$_resource  : Mage_Core_Model_Resource_Db_Abstract
Resource model instance
$_resourceCollectionName  : string
Name of the resource collection model
$_resourceName  : string
Name of the resource model
$_syncFieldsMap  : mixed
Map of fields to sync to other fields upon changing their data
$_underscoreCache  : array<string|int, mixed>
Setter/Getter underscore transformation cache
$_minSaleQtyCache  : array<string|int, mixed>

Methods

__call()  : mixed
Set/Get attribute wrapper
__construct()  : mixed
Constructor
__get()  : mixed
Attribute getter (deprecated)
__set()  : mixed
Attribute setter (deprecated)
__toArray()  : array<string|int, mixed>
Convert object attributes to array
_getResource()  : Mage_CatalogInventory_Model_Resource_Stock_Item
Get resource instance
addCatalogInventoryToProductCollection()  : $this
Add join for catalog in stock field to product collection
addData()  : $this
Add data to the object.
addQty()  : $this
Add quantity process
afterCommitCallback()  : $this
Callback function which called after transaction commit in resource model
afterLoad()  : $this
Object after load processing. Implemented as public interface for supporting objects after load in collections
assignProduct()  : $this
Adding stock data to product
canSubtractQty()  : bool
Check if is possible subtract value from item qty
checkQty()  : bool
Check quantity
checkQtyIncrements()  : DataObject
Check qty increments
checkQuoteItemQty()  : DataObject
Checking quote item quantity
cleanModelCache()  : $this
Remove model object related cache
clearInstance()  : $this
Clearing object for correct deleting by garbage collector
dataHasChangedFor()  : bool
Compare object data with original data
debug()  : string|array<string|int, mixed>
Present object data as string in debug mode
delete()  : $this
Delete object from database
flagDirty()  : $this
getBackorders()  : int
Retrieve backorders status
getBillingAddress()  : Mage_Customer_Model_Address_Abstract|null
getCacheIdTags()  : array<string|int, mixed>|false
Get cache tags associated with object id
getCacheTags()  : array<string|int, mixed>|false
Get list of cache tags applied to model object.
getCanBackInStock()  : bool
Retrieve can Back in stock
getCollection()  : Mage_CatalogInventory_Model_Resource_Stock_Item_Collection
getCreatedAt()  : string|null
getCustomerGroupId()  : int
Getter for customer group id
getData()  : mixed
Object data getter
getDataByKey()  : mixed
Get object data by particular key
getDataByPath()  : mixed
Get object data by path
getDataSetDefault()  : mixed
Fast get data or set default if value is not available
getDataUsingMethod()  : mixed
Get object data by key with calling getter method
getEnableQtyIncrements()  : bool
Retrieve whether Quantity Increments is enabled
getEntityId()  : int
getId()  : int|string|null
Retrieve model object identifier
getIdFieldName()  : string
Retrieve identifier field name for model
getIsChildItem()  : bool|null
getIsInStock()  : bool|null
getIsQtyDecimal()  : bool|null
getLowStockDate()  : string|null
getManageStock()  : int
Retrieve Manage Stock data wrapper
getMaxSaleQty()  : float
Retrieve Maximum Qty Allowed in Shopping Cart data wrapper DBAL returns DECIMAL as string, so we cast to float
getMinQty()  : float
Retrieve minimal quantity available for item status in stock
getMinSaleQty()  : float|null
Retrieve Minimum Qty Allowed in Shopping Cart or NULL when there is no limitation DBAL returns DECIMAL as string, so we cast to float
getNotifyStockQty()  : float
Retrieve Notify for Quantity Below data wrapper
getOrderedItems()  : float|null
getOrigData()  : mixed
Get object loaded data (original data)
getProduct()  : Mage_Catalog_Model_Product|null
Returns product instance
getProductId()  : int
Retrieve Product Id data wrapper
getProductName()  : string|null
getProductTypeId()  : string|null
getQty()  : float|null
getQtyCorrection()  : float|null
Get quantity correction with proper float casting DBAL returns DECIMAL as string, so we cast to float
getQtyIncrements()  : float|false
Retrieve Quantity Increments data wrapper
getResource()  : Mage_CatalogInventory_Model_Resource_Stock_Item
Retrieve model resource
getResourceCollection()  : Mage_Core_Model_Resource_Db_Collection_Abstract
Get collection instance
getResourceName()  : string
Retrieve model resource name
getShippingAddress()  : Mage_Customer_Model_Address_Abstract|null
getStockId()  : int
Retrieve stock identifier
getStockQty()  : float
Retrieve stock qty whether product is composite or no
getStockStatus()  : bool|null
getStockStatusChangedAutomatically()  : int|null
getStockStatusChangedAutomaticallyFlag()  : bool|null
getStoreId()  : int
Retrieve Store Id (product or current)
getSuppressCheckQtyIncrements()  : bool|null
getTypeId()  : string|null
getUseConfigBackorders()  : bool|null
getUseConfigEnableQtyIncrements()  : int|null
getUseConfigManageStock()  : bool|null
getUseConfigMaxSaleQty()  : bool|null
getUseConfigMinQty()  : bool|null
getUseConfigMinSaleQty()  : bool|null
getUseConfigNotifyStockQty()  : bool|null
getUseConfigQtyIncrements()  : bool|null
hasData()  : bool
If $key is empty, checks whether there's any data in the object Otherwise checks if the specified attribute is set.
hasDataChanges()  : bool
Get data change status
hasErrors()  : bool
hasIsChildItem()  : $this
hasStockQty()  : bool
hasStockStatusChangedAutomaticallyFlag()  : bool
isDeleted()  : bool
Set _isDeleted flag value (if $isDeleted param is defined) and return current flag value
isDirty()  : bool
isEmpty()  : bool
checks whether the object is empty
isModuleEnabled()  : bool
isObjectNew()  : bool
Check object state (true - if it is object without id on object just created) This method can help detect if object just created in _afterSave method problem is what in after save object has id and we can't detect what object was created in this transaction
jsonSerialize()  : array<string|int, mixed>
Implementation of JsonSerializable::jsonSerialize()
load()  : $this
Load object data
loadByProduct()  : $this
Load item data by product
offsetExists()  : bool
Implementation of ArrayAccess::offsetExists()
offsetGet()  : mixed
Implementation of ArrayAccess::offsetGet()
offsetSet()  : void
Implementation of ArrayAccess::offsetSet()
offsetUnset()  : void
Implementation of ArrayAccess::offsetUnset()
reset()  : $this
Reset model data
save()  : $this
Save object data
serialize()  : string
serialize object attributes
setAttribute()  : $this
setBackorders()  : static
setCreatedAt()  : static
setCustomerGroupId()  : $this
Setter for customer group id
setData()  : $this
Overwrite data in the object.
setDataChanges()  : $this
Clears data changes status
setDataUsingMethod()  : $this
Set object data with calling setter method
setEnableQtyIncrements()  : static
setId()  : $this
Declare model object identifier value
setIdFieldName()  : $this
set name of object id field
setIsChildItem()  : static
setIsInStock()  : static
setIsQtyDecimal()  : static
setLowStockDate()  : static
setManageStock()  : static
setMaxSaleQty()  : static
setMinQty()  : static
setMinSaleQty()  : static
setNotifyStockQty()  : static
setOrderedItems()  : static
setOrigData()  : $this
Initialize object original data
setParentItem()  : static
setProcessIndexEvents()  : $this
Set whether index events should be processed immediately
setProduct()  : $this
Add product data to stock item
setProductChangedWebsites()  : static
setProductId()  : static
setProductName()  : static
setProductStatusChanged()  : static
setProductTypeId()  : static
setQty()  : static
setQtyIncrements()  : static
setStockId()  : static
setStockQty()  : static
setStockStatusChangedAutomatically()  : static
setStockStatusChangedAutomaticallyFlag()  : static
setStoreId()  : static
setSuppressCheckQtyIncrements()  : static
setUpdatedAt()  : static
setUseConfigBackorders()  : static
setUseConfigEnableQtyIncrements()  : static
setUseConfigManageStock()  : static
setUseConfigMaxSaleQty()  : static
setUseConfigMinQty()  : static
setUseConfigMinSaleQty()  : static
setUseConfigNotifyStockQty()  : static
setUseConfigQtyIncrements()  : static
subtractQty()  : $this
Subtract quote item quantity
suggestQty()  : int|float
Returns suggested qty that satisfies qty increments and minQty/maxQty/minSaleQty/maxSaleQty conditions or original qty if such value does not exist
toArray()  : array<string|int, mixed>
Public wrapper for __toArray
toJson()  : string
Public wrapper for __toJson
toString()  : string
Public wrapper for __toString
toXml()  : string
Public wrapper for __toXml
unsetData()  : $this
Unset data from the object.
unsetOldData()  : $this
Unset old fields data from the object.
unsIsChildItem()  : $this
verifyNotification()  : bool
Check if item qty require stock status notification
verifyStock()  : bool
Chceck if item should be in stock or out of stock based on $qty param of existing item qty
__toJson()  : string
Convert object attributes to JSON
__toXml()  : string
Convert object attributes to XML
_addFullNames()  : mixed
_addQuoteItemError()  : $this
Add error to Quote Item
_afterDelete()  : $this
Processing object after delete data
_afterDeleteCommit()  : $this
Processing manipulation after main transaction commit
_afterLoad()  : $this
Processing object after load data
_afterSave()  : $this
Processing object after save data
_beforeDelete()  : $this
Processing object before delete data
_beforeLoad()  : $this
Processing object before load data
_beforeSave()  : $this
Before save prepare process
_camelize()  : string
_clearData()  : $this
Clearing object's data
_clearReferences()  : $this
Clearing cyclic references
_construct()  : void
Internal constructor not depended on params. Can be used for object initialization
_getData()  : mixed
Get value from _data array without parse key
_getEventData()  : array<string|int, mixed>
Get array of objects transferred to default events processing
_hasModelChanged()  : bool
Check whether model has changed data.
_init()  : mixed
Standard model initialization
_initOldFieldsMap()  : void
Init mapping array of short fields to its full names
_prepareArray()  : array<string|int, mixed>
Set required array elements
_prepareSyncFieldsMap()  : $this
Called after old fields are inited. Forms synchronization map to sync old fields and new fields between each other.
_protectFromNonAdmin()  : mixed
Safeguard func that will check, if we are in admin area
_setResourceModel()  : mixed
Set resource names
_underscore()  : string
Converts field names for setters and getters

Constants

ENTITY

public mixed ENTITY = 'cataloginventory_stock_item'

XML_PATH_BACKORDERS

public mixed XML_PATH_BACKORDERS = 'cataloginventory/item_options/backorders'

XML_PATH_CAN_BACK_IN_STOCK

public mixed XML_PATH_CAN_BACK_IN_STOCK = 'cataloginventory/options/can_back_in_stock'

XML_PATH_CAN_SUBTRACT

public mixed XML_PATH_CAN_SUBTRACT = 'cataloginventory/options/can_subtract'

XML_PATH_ENABLE_QTY_INCREMENTS

public mixed XML_PATH_ENABLE_QTY_INCREMENTS = 'cataloginventory/item_options/enable_qty_increments'

XML_PATH_GLOBAL

public mixed XML_PATH_GLOBAL = 'cataloginventory/options/'

XML_PATH_ITEM

public mixed XML_PATH_ITEM = 'cataloginventory/item_options/'

XML_PATH_MANAGE_STOCK

public mixed XML_PATH_MANAGE_STOCK = 'cataloginventory/item_options/manage_stock'

XML_PATH_MAX_SALE_QTY

public mixed XML_PATH_MAX_SALE_QTY = 'cataloginventory/item_options/max_sale_qty'

XML_PATH_MIN_QTY

public mixed XML_PATH_MIN_QTY = 'cataloginventory/item_options/min_qty'

XML_PATH_MIN_SALE_QTY

public mixed XML_PATH_MIN_SALE_QTY = 'cataloginventory/item_options/min_sale_qty'

XML_PATH_NOTIFY_STOCK_QTY

public mixed XML_PATH_NOTIFY_STOCK_QTY = 'cataloginventory/item_options/notify_stock_qty'

XML_PATH_QTY_INCREMENTS

public mixed XML_PATH_QTY_INCREMENTS = 'cataloginventory/item_options/qty_increments'

XML_PATH_SYNC_AVAIL_WITH_QTY

public mixed XML_PATH_SYNC_AVAIL_WITH_QTY = 'cataloginventory/options/sync_stock_availability_with_qty'

Properties

$_cacheTag

Model cache tag for clear cache in after save and after delete

protected string|bool|array<string|int, mixed> $_cacheTag = \false

When you use true - all cache will be clean

$_customerGroupId

Customer group id

protected int|null $_customerGroupId

$_data

Object attributes

protected array<string|int, mixed>|null $_data = []

$_dataSaveAllowed

Flag which can stop data saving after before save Can be used for next sequence: we check data in _beforeSave, if data are not valid - we can set this flag to false value and save process will be stopped

protected bool $_dataSaveAllowed = \true

$_dirty

protected array<string|int, mixed> $_dirty

$_eventObject

Parameter name in event

protected string $_eventObject = 'item'

In observe method you can use $observer->getEvent()->getItem() in this case

Attributes
#[Override]

$_eventPrefix

Prefix of model events names

protected string $_eventPrefix = 'cataloginventory_stock_item'
Attributes
#[Override]

$_hasDataChanges

Data changes flag (true after setData|unsetData call)

protected bool $_hasDataChanges = false

$_idFieldName

Name of object id field

protected string $_idFieldName = null

$_isDeleted

Object delete flag

protected bool $_isDeleted = false

$_isObjectNew

Flag which allow detect object state: is it new object (without id) or existing one (with id)

protected bool|null $_isObjectNew = \null

$_oldFieldsMap

Map short fields names to its full names

protected array<string|int, mixed> $_oldFieldsMap = []

$_origData

Original data that was loaded

protected array<string|int, mixed>|null $_origData

$_processIndexEvents

Whether index events should be processed immediately

protected bool $_processIndexEvents = \true

$_qtyIncrements

protected float|false $_qtyIncrements

$_resourceCollectionName

Name of the resource collection model

protected string $_resourceCollectionName

$_resourceName

Name of the resource model

protected string $_resourceName

$_syncFieldsMap

Map of fields to sync to other fields upon changing their data

protected mixed $_syncFieldsMap = []

$_underscoreCache

Setter/Getter underscore transformation cache

protected static array<string|int, mixed> $_underscoreCache = []

$_minSaleQtyCache

private array<string|int, mixed> $_minSaleQtyCache = []

Methods

__call()

Set/Get attribute wrapper

public __call(string $method, array<string|int, mixed> $args) : mixed
Parameters
$method : string
$args : array<string|int, mixed>

__construct()

Constructor

public __construct() : mixed

By default, is looking for first argument as array and assigns it as object attributes This behaviour may change in child classes

__get()

Attribute getter (deprecated)

public __get(string $var) : mixed
Parameters
$var : string

__set()

Attribute setter (deprecated)

public __set(string $var, mixed $value) : mixed
Parameters
$var : string
$value : mixed

__toArray()

Convert object attributes to array

public __toArray([array<string|int, mixed> $arrAttributes = [] ]) : array<string|int, mixed>
Parameters
$arrAttributes : array<string|int, mixed> = []

array of required attributes

Return values
array<string|int, mixed>

addData()

Add data to the object.

public addData(array<string|int, mixed> $arr) : $this

Retains previous data in the object.

Parameters
$arr : array<string|int, mixed>
Return values
$this

addQty()

Add quantity process

public addQty(float $qty) : $this
Parameters
$qty : float
Return values
$this

afterCommitCallback()

Callback function which called after transaction commit in resource model

public afterCommitCallback() : $this
Attributes
#[Override]
Return values
$this

afterLoad()

Object after load processing. Implemented as public interface for supporting objects after load in collections

public afterLoad() : $this
Return values
$this

canSubtractQty()

Check if is possible subtract value from item qty

public canSubtractQty() : bool
Return values
bool

checkQty()

Check quantity

public checkQty(float $qty) : bool
Parameters
$qty : float
Tags
throws
Mage_Core_Exception
Return values
bool

checkQtyIncrements()

Check qty increments

public checkQtyIncrements(int|float $qty) : DataObject
Parameters
$qty : int|float
Return values
DataObject

checkQuoteItemQty()

Checking quote item quantity

public checkQuoteItemQty(mixed $qty, mixed $summaryQty[, mixed $origQty = 0 ]) : DataObject

Second parameter of this method specifies quantity of this product in whole shopping cart which should be checked for stock availability

Parameters
$qty : mixed

quantity of this item (item qty x parent item qty)

$summaryQty : mixed

quantity of this product

$origQty : mixed = 0

original qty of item (not multiplied on parent item qty)

Return values
DataObject

cleanModelCache()

Remove model object related cache

public cleanModelCache() : $this
Return values
$this

clearInstance()

Clearing object for correct deleting by garbage collector

public final clearInstance() : $this
Return values
$this

dataHasChangedFor()

Compare object data with original data

public dataHasChangedFor(string $field) : bool
Parameters
$field : string
Return values
bool

debug()

Present object data as string in debug mode

public debug([mixed $data = null ][, array<string|int, mixed> &$objects = [] ]) : string|array<string|int, mixed>
Parameters
$data : mixed = null
$objects : array<string|int, mixed> = []
Return values
string|array<string|int, mixed>

delete()

Delete object from database

public delete() : $this
Tags
throws
Throwable
Return values
$this

flagDirty()

public flagDirty(string $field[, bool $flag = true ]) : $this
Parameters
$field : string
$flag : bool = true
Return values
$this

getBackorders()

Retrieve backorders status

public getBackorders() : int
Return values
int

getCacheIdTags()

Get cache tags associated with object id

public getCacheIdTags() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false

getCacheTags()

Get list of cache tags applied to model object.

public getCacheTags() : array<string|int, mixed>|false

Return false if cache tags are not supported by model

Return values
array<string|int, mixed>|false

getCanBackInStock()

Retrieve can Back in stock

public getCanBackInStock() : bool
Return values
bool

getCreatedAt()

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

getCustomerGroupId()

Getter for customer group id

public getCustomerGroupId() : int
Return values
int

getData()

Object data getter

public getData([string $key = '' ][, string|int $index = null ]) : mixed

If $key is not defined will return all the data as an array. Otherwise, it will return value of the element specified by $key. It is possible to use keys like a/b/c for access nested array data

If $index is specified it will assume that attribute data is an array and retrieve corresponding member. If data is the string - it will be explode by new line character and converted to array.

Parameters
$key : string = ''
$index : string|int = null

getDataByKey()

Get object data by particular key

public getDataByKey(string $key) : mixed
Parameters
$key : string

getDataByPath()

Get object data by path

public getDataByPath(string $path) : mixed

Method consider the path as chain of keys: a/b/c => ['a']['b']['c']

Parameters
$path : string

getDataSetDefault()

Fast get data or set default if value is not available

public getDataSetDefault(string $key, mixed $default) : mixed
Parameters
$key : string
$default : mixed

getDataUsingMethod()

Get object data by key with calling getter method

public getDataUsingMethod(string $key[, mixed $args = null ]) : mixed
Parameters
$key : string
$args : mixed = null

getEnableQtyIncrements()

Retrieve whether Quantity Increments is enabled

public getEnableQtyIncrements() : bool
Return values
bool

getEntityId()

public getEntityId() : int
Return values
int

getId()

Retrieve model object identifier

public getId() : int|string|null
Attributes
#[Override]
Return values
int|string|null

getIdFieldName()

Retrieve identifier field name for model

public getIdFieldName() : string
Attributes
#[Override]
Return values
string

getIsChildItem()

public getIsChildItem() : bool|null
Return values
bool|null

getIsInStock()

public getIsInStock() : bool|null
Return values
bool|null

getIsQtyDecimal()

public getIsQtyDecimal() : bool|null
Return values
bool|null

getLowStockDate()

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

getManageStock()

Retrieve Manage Stock data wrapper

public getManageStock() : int
Return values
int

getMaxSaleQty()

Retrieve Maximum Qty Allowed in Shopping Cart data wrapper DBAL returns DECIMAL as string, so we cast to float

public getMaxSaleQty() : float
Return values
float

getMinQty()

Retrieve minimal quantity available for item status in stock

public getMinQty() : float
Return values
float

getMinSaleQty()

Retrieve Minimum Qty Allowed in Shopping Cart or NULL when there is no limitation DBAL returns DECIMAL as string, so we cast to float

public getMinSaleQty() : float|null
Return values
float|null

getNotifyStockQty()

Retrieve Notify for Quantity Below data wrapper

public getNotifyStockQty() : float
Return values
float

getOrderedItems()

public getOrderedItems() : float|null
Return values
float|null

getOrigData()

Get object loaded data (original data)

public getOrigData([string $key = null ]) : mixed
Parameters
$key : string = null

getProductId()

Retrieve Product Id data wrapper

public getProductId() : int
Return values
int

getProductName()

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

getProductTypeId()

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

getQty()

public getQty() : float|null
Return values
float|null

getQtyCorrection()

Get quantity correction with proper float casting DBAL returns DECIMAL as string, so we cast to float

public getQtyCorrection() : float|null
Return values
float|null

getQtyIncrements()

Retrieve Quantity Increments data wrapper

public getQtyIncrements() : float|false
Return values
float|false

getResourceName()

Retrieve model resource name

public getResourceName() : string
Return values
string

getStockId()

Retrieve stock identifier

public getStockId() : int
Tags
todo

multi stock

Return values
int

getStockQty()

Retrieve stock qty whether product is composite or no

public getStockQty() : float
Return values
float

getStockStatus()

public getStockStatus() : bool|null
Return values
bool|null

getStockStatusChangedAutomatically()

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

getStockStatusChangedAutomaticallyFlag()

public getStockStatusChangedAutomaticallyFlag() : bool|null
Return values
bool|null

getStoreId()

Retrieve Store Id (product or current)

public getStoreId() : int
Return values
int

getSuppressCheckQtyIncrements()

public getSuppressCheckQtyIncrements() : bool|null
Return values
bool|null

getTypeId()

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

getUseConfigBackorders()

public getUseConfigBackorders() : bool|null
Return values
bool|null

getUseConfigEnableQtyIncrements()

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

getUseConfigManageStock()

public getUseConfigManageStock() : bool|null
Return values
bool|null

getUseConfigMaxSaleQty()

public getUseConfigMaxSaleQty() : bool|null
Return values
bool|null

getUseConfigMinQty()

public getUseConfigMinQty() : bool|null
Return values
bool|null

getUseConfigMinSaleQty()

public getUseConfigMinSaleQty() : bool|null
Return values
bool|null

getUseConfigNotifyStockQty()

public getUseConfigNotifyStockQty() : bool|null
Return values
bool|null

getUseConfigQtyIncrements()

public getUseConfigQtyIncrements() : bool|null
Return values
bool|null

hasData()

If $key is empty, checks whether there's any data in the object Otherwise checks if the specified attribute is set.

public hasData([string $key = '' ]) : bool
Parameters
$key : string = ''
Return values
bool

hasDataChanges()

Get data change status

public hasDataChanges() : bool
Return values
bool

hasErrors()

public hasErrors() : bool
Return values
bool

hasIsChildItem()

public hasIsChildItem() : $this
Return values
$this

hasStockQty()

public hasStockQty() : bool
Return values
bool

hasStockStatusChangedAutomaticallyFlag()

public hasStockStatusChangedAutomaticallyFlag() : bool
Return values
bool

isDeleted()

Set _isDeleted flag value (if $isDeleted param is defined) and return current flag value

public isDeleted([bool $isDeleted = null ]) : bool
Parameters
$isDeleted : bool = null
Return values
bool

isDirty()

public isDirty([string $field = null ]) : bool
Parameters
$field : string = null
Return values
bool

isEmpty()

checks whether the object is empty

public isEmpty() : bool
Return values
bool

isModuleEnabled()

public isModuleEnabled(string $moduleName[, string $helperAlias = 'core' ]) : bool
Parameters
$moduleName : string
$helperAlias : string = 'core'
Return values
bool

isObjectNew()

Check object state (true - if it is object without id on object just created) This method can help detect if object just created in _afterSave method problem is what in after save object has id and we can't detect what object was created in this transaction

public isObjectNew([bool $flag = null ]) : bool
Parameters
$flag : bool = null
Return values
bool

jsonSerialize()

Implementation of JsonSerializable::jsonSerialize()

public jsonSerialize() : array<string|int, mixed>

Prepares the object data for JSON serialization. Returns all object data as an array, with special handling for nested DataObject instances:

  • If a nested DataObject has a custom jsonSerialize() implementation, it's preserved as-is
  • If a nested DataObject has a custom toJson() method, it's converted to JSON string
  • If a nested DataObject uses only the base implementations, it's excluded from output

This prevents infinite recursion and circular references when serializing object hierarchies.

Attributes
#[Override]
Return values
array<string|int, mixed>

load()

Load object data

public load(string|null|int $id[, string|null $field = null ]) : $this
Parameters
$id : string|null|int
$field : string|null = null
Return values
$this

loadByProduct()

Load item data by product

public loadByProduct(mixed $product) : $this
Parameters
$product : mixed
Return values
$this

reset()

Reset model data

public reset() : $this
Return values
$this

save()

Save object data

public save() : $this
Tags
throws
Throwable
Return values
$this

serialize()

serialize object attributes

public serialize([array<string|int, mixed> $attributes = [] ][, string $valueSeparator = '=' ][, string $fieldSeparator = ' ' ][, string $quote = '"' ]) : string
Parameters
$attributes : array<string|int, mixed> = []
$valueSeparator : string = '='
$fieldSeparator : string = ' '
$quote : string = '"'
Return values
string

setBackorders()

public setBackorders(int|null $value) : static
Parameters
$value : int|null
Return values
static

setCreatedAt()

public setCreatedAt(string|null $value) : static
Parameters
$value : string|null
Return values
static

setCustomerGroupId()

Setter for customer group id

public setCustomerGroupId(int $value) : $this
Parameters
$value : int

Value of customer group id

Return values
$this

setData()

Overwrite data in the object.

public setData(string|array<string|int, mixed> $key[, mixed $value = null ]) : $this

$key can be string or array. If $key is string, the attribute value will be overwritten by $value

If $key is an array, it will overwrite all the data in the object.

Parameters
$key : string|array<string|int, mixed>
$value : mixed = null
Return values
$this

setDataChanges()

Clears data changes status

public setDataChanges(bool $value) : $this
Parameters
$value : bool
Return values
$this

setDataUsingMethod()

Set object data with calling setter method

public setDataUsingMethod(string $key[, mixed $args = [] ]) : $this
Parameters
$key : string
$args : mixed = []
Return values
$this

setEnableQtyIncrements()

public setEnableQtyIncrements([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setId()

Declare model object identifier value

public setId(mixed $id) : $this
Parameters
$id : mixed
Attributes
#[Override]
Return values
$this

setIdFieldName()

set name of object id field

public setIdFieldName(string $name) : $this
Parameters
$name : string
Return values
$this

setIsChildItem()

public setIsChildItem([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setIsInStock()

public setIsInStock([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setIsQtyDecimal()

public setIsQtyDecimal([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setLowStockDate()

public setLowStockDate(string|null $value) : static
Parameters
$value : string|null
Return values
static

setManageStock()

public setManageStock([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setMaxSaleQty()

public setMaxSaleQty(float|null $value) : static
Parameters
$value : float|null
Return values
static

setMinQty()

public setMinQty(float|null $value) : static
Parameters
$value : float|null
Return values
static

setMinSaleQty()

public setMinSaleQty(float|null $value) : static
Parameters
$value : float|null
Return values
static

setNotifyStockQty()

public setNotifyStockQty(float|null $value) : static
Parameters
$value : float|null
Return values
static

setOrderedItems()

public setOrderedItems(float|null $value) : static
Parameters
$value : float|null
Return values
static

setOrigData()

Initialize object original data

public setOrigData([string $key = null ][, mixed $data = null ]) : $this
Parameters
$key : string = null
$data : mixed = null
Return values
$this

setProcessIndexEvents()

Set whether index events should be processed immediately

public setProcessIndexEvents([bool $process = true ]) : $this
Parameters
$process : bool = true
Return values
$this

setProductChangedWebsites()

public setProductChangedWebsites([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setProductId()

public setProductId(int|null $value) : static
Parameters
$value : int|null
Return values
static

setProductName()

public setProductName(string|null $value) : static
Parameters
$value : string|null
Return values
static

setProductStatusChanged()

public setProductStatusChanged([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setProductTypeId()

public setProductTypeId(string|null $value) : static
Parameters
$value : string|null
Return values
static

setQty()

public setQty(float|null $value) : static
Parameters
$value : float|null
Return values
static

setQtyIncrements()

public setQtyIncrements(float|null $value) : static
Parameters
$value : float|null
Return values
static

setStockId()

public setStockId(int|null $value) : static
Parameters
$value : int|null
Return values
static

setStockQty()

public setStockQty(float|null $value) : static
Parameters
$value : float|null
Return values
static

setStockStatusChangedAutomatically()

public setStockStatusChangedAutomatically(int|null $value) : static
Parameters
$value : int|null
Return values
static

setStockStatusChangedAutomaticallyFlag()

public setStockStatusChangedAutomaticallyFlag([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setStoreId()

public setStoreId(int|null $value) : static
Parameters
$value : int|null
Return values
static

setSuppressCheckQtyIncrements()

public setSuppressCheckQtyIncrements([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setUpdatedAt()

public setUpdatedAt(string|null $value) : static
Parameters
$value : string|null
Return values
static

setUseConfigBackorders()

public setUseConfigBackorders([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setUseConfigEnableQtyIncrements()

public setUseConfigEnableQtyIncrements(int|null $value) : static
Parameters
$value : int|null
Return values
static

setUseConfigManageStock()

public setUseConfigManageStock([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setUseConfigMaxSaleQty()

public setUseConfigMaxSaleQty([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setUseConfigMinQty()

public setUseConfigMinQty([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setUseConfigMinSaleQty()

public setUseConfigMinSaleQty([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setUseConfigNotifyStockQty()

public setUseConfigNotifyStockQty([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

setUseConfigQtyIncrements()

public setUseConfigQtyIncrements([bool|null $value = true ]) : static
Parameters
$value : bool|null = true
Return values
static

subtractQty()

Subtract quote item quantity

public subtractQty(float $qty) : $this
Parameters
$qty : float
Return values
$this

suggestQty()

Returns suggested qty that satisfies qty increments and minQty/maxQty/minSaleQty/maxSaleQty conditions or original qty if such value does not exist

public suggestQty(int|float $qty) : int|float
Parameters
$qty : int|float
Return values
int|float

toArray()

Public wrapper for __toArray

public toArray([array<string|int, mixed> $arrAttributes = [] ]) : array<string|int, mixed>
Parameters
$arrAttributes : array<string|int, mixed> = []
Return values
array<string|int, mixed>

toJson()

Public wrapper for __toJson

public toJson([array<string|int, mixed> $arrAttributes = [] ]) : string
Parameters
$arrAttributes : array<string|int, mixed> = []
Return values
string

toString()

Public wrapper for __toString

public toString([string $format = '' ]) : string

Will use $format as an template and substitute {{key}} for attributes

Parameters
$format : string = ''
Return values
string

toXml()

Public wrapper for __toXml

public toXml([array<string|int, mixed> $arrAttributes = [] ][, string $rootName = 'item' ][, bool $addOpenTag = false ][, bool $addCdata = true ]) : string
Parameters
$arrAttributes : array<string|int, mixed> = []
$rootName : string = 'item'
$addOpenTag : bool = false
$addCdata : bool = true
Return values
string

unsetData()

Unset data from the object.

public unsetData([string $key = null ]) : $this

$key can be a string only. Array will be ignored.

Parameters
$key : string = null
Return values
$this

unsetOldData()

Unset old fields data from the object.

public unsetOldData([string $key = null ]) : $this

$key can be a string only. Array will be ignored.

Parameters
$key : string = null
Return values
$this

unsIsChildItem()

public unsIsChildItem() : $this
Return values
$this

verifyNotification()

Check if item qty require stock status notification

public verifyNotification([float|null $qty = null ]) : bool
Parameters
$qty : float|null = null
Return values
bool —

(true - if require, false - if not require)

verifyStock()

Chceck if item should be in stock or out of stock based on $qty param of existing item qty

public verifyStock([float|null $qty = null ]) : bool
Parameters
$qty : float|null = null
Return values
bool —

true - item in stock | false - item out of stock

__toJson()

Convert object attributes to JSON

protected __toJson([array<string|int, mixed> $arrAttributes = [] ]) : string
Parameters
$arrAttributes : array<string|int, mixed> = []

array of required attributes

Return values
string

__toXml()

Convert object attributes to XML

protected __toXml([array<string|int, mixed> $arrAttributes = [] ][, string $rootName = 'item' ][, bool $addOpenTag = false ][, bool $addCdata = true ]) : string
Parameters
$arrAttributes : array<string|int, mixed> = []

array of required attributes

$rootName : string = 'item'

name of the root element

$addOpenTag : bool = false
$addCdata : bool = true
Return values
string

_addFullNames()

protected _addFullNames() : mixed

_addQuoteItemError()

Add error to Quote Item

protected _addQuoteItemError(Mage_Sales_Model_Quote_Item $item, string $itemError, string $quoteError[, string $errorIndex = 'error' ]) : $this
Parameters
$item : Mage_Sales_Model_Quote_Item
$itemError : string
$quoteError : string
$errorIndex : string = 'error'
Return values
$this

_afterDelete()

Processing object after delete data

protected _afterDelete() : $this
Return values
$this

_afterDeleteCommit()

Processing manipulation after main transaction commit

protected _afterDeleteCommit() : $this
Return values
$this

_afterLoad()

Processing object after load data

protected _afterLoad() : $this
Return values
$this

_afterSave()

Processing object after save data

protected _afterSave() : $this
Return values
$this

_beforeDelete()

Processing object before delete data

protected _beforeDelete() : $this
Return values
$this

_beforeLoad()

Processing object before load data

protected _beforeLoad(int $id[, string|null $field = null ]) : $this
Parameters
$id : int
$field : string|null = null
Return values
$this

_beforeSave()

Before save prepare process

protected _beforeSave() : $this
Attributes
#[Override]
Return values
$this

_camelize()

protected _camelize(string $name) : string
Parameters
$name : string
Return values
string

_clearData()

Clearing object's data

protected _clearData() : $this
Return values
$this

_clearReferences()

Clearing cyclic references

protected _clearReferences() : $this
Return values
$this

_construct()

Internal constructor not depended on params. Can be used for object initialization

protected _construct() : void
Attributes
#[Override]

_getData()

Get value from _data array without parse key

protected _getData(string $key) : mixed
Parameters
$key : string

_getEventData()

Get array of objects transferred to default events processing

protected _getEventData() : array<string|int, mixed>
Return values
array<string|int, mixed>

_hasModelChanged()

Check whether model has changed data.

protected _hasModelChanged() : bool

Can be overloaded in child classes to perform advanced check whether model needs to be saved e.g. using resourceModel->hasDataChanged() or any other technique

Return values
bool

_init()

Standard model initialization

protected _init(string $resourceModel) : mixed
Parameters
$resourceModel : string

_initOldFieldsMap()

Init mapping array of short fields to its full names

protected _initOldFieldsMap() : void
Attributes
#[Override]

_prepareArray()

Set required array elements

protected _prepareArray(array<string|int, mixed> &$arr[, array<string|int, mixed> $elements = [] ]) : array<string|int, mixed>
Parameters
$arr : array<string|int, mixed>
$elements : array<string|int, mixed> = []
Return values
array<string|int, mixed>

_prepareSyncFieldsMap()

Called after old fields are inited. Forms synchronization map to sync old fields and new fields between each other.

protected _prepareSyncFieldsMap() : $this
Return values
$this

_protectFromNonAdmin()

Safeguard func that will check, if we are in admin area

protected _protectFromNonAdmin() : mixed
Tags
throws
Mage_Core_Exception

_setResourceModel()

Set resource names

protected _setResourceModel(string $resourceName[, string|null $resourceCollectionName = null ]) : mixed

If collection name is omitted, resource name will be used with _collection appended

Parameters
$resourceName : string
$resourceCollectionName : string|null = null

_underscore()

Converts field names for setters and getters

protected _underscore(string $name) : string

$this->setMyField($value) === $this->setData('my_field', $value) Uses cache to eliminate unnecessary preg_replace

Parameters
$name : string
Return values
string
On this page

Search results