SilverCart\Model\Product\StockItemEntry
Represents a stock item entry to manage a product's stock.
- Author: Sebastian Diel <sdiel@pixeltricks.de>
- Copyright: 2019 pixeltricks GmbH
- License: see license file in modules root directory
Synopsis
class StockItemEntry
extends DataObject
{
- // constants
- const ORIGIN_CODE_INITIAL = 1;
- const ORIGIN_CODE_UNDEFINED = 0;
- const ORIGIN_CODE_NEW_PRODUCT = 1;
- const ORIGIN_CODE_USER_INPUT = 2;
- const ORIGIN_CODE_ORDER_PLACED = 3;
- const ORIGIN_CODE_ORDER_UPDATE = 4;
- const ORIGIN_CODE_ORDER_CANCEL = 5;
- const ORIGIN_CODE_API_IMPORT = 6;
- // members
- private static string $table_name = 'SilvercartStockItemEntry';
- private static array $db = ;
- private static array $has_one = ;
- private static string $default_sort = 'Created DESC';
- private static array $casting = ;
- protected bool $skipProductUpdate = false;
- // methods
- public static StockItemEntry add()
- public string singular_name()
- public string plural_name()
- public bool canDelete()
- public FieldList getCMSFields()
- public array fieldLabels()
- public array summaryFields()
- protected void onAfterWrite()
- public void requireDefaultRecords()
- public string getMemberName()
- public string getOrigin()
- public string getQuantityWithSign()
- public $this setSkipProductUpdate()
- public bool getSkipProductUpdate()
- public bool skipProductUpdate()
- // Inherited methods from ExtensibleDataObject
- protected void beforeRequireDefaultRecords()
- protected void beforeUpdateCMSActions()
- protected void beforeUpdateFieldLabels()
- protected void beforeUpdateProvidePermissions()
- public array defaultFieldLabels()
- public static void reset_field_labels()
- protected array scaffoldFieldLabels()
Hierarchy
Constants
Name | Value |
---|---|
ORIGIN_CODE_INITIAL | 1 |
ORIGIN_CODE_UNDEFINED | 0 |
ORIGIN_CODE_NEW_PRODUCT | 1 |
ORIGIN_CODE_USER_INPUT | 2 |
ORIGIN_CODE_ORDER_PLACED | 3 |
ORIGIN_CODE_ORDER_UPDATE | 4 |
ORIGIN_CODE_ORDER_CANCEL | 5 |
ORIGIN_CODE_API_IMPORT | 6 |
Members
private
- $casting
—
array
Casted attributes. - $db
—
array
DB attributes. - $default_sort
—
string
Default sort. - $has_one
—
array
Has one relations. - $table_name
—
string
DB table name.
protected
- $defaultFieldLabels
—
array
Default field labels. - $skipProductUpdate
—
SilverCart\Model\Product\bool
Set to true before writing a new stock item entry to skip the update of the real product stock quantity.
Methods
protected
- onAfterWrite() — Updates the related product's stock quantity after writing a stock item entry.
public
- add() — Adds a new stock item entry to the database.
- canDelete() — Returns whether this object can be deleted.
- fieldLabels() — Returns the field labels.
- getCMSFields() — Returns the CMS fields.
- getMemberName() — Returns the origin text.
- getOrigin() — Returns the origin text.
- getQuantityWithSign() — Returns the quantiy with plus or minus sign as text.
- getSkipProductUpdate() — Returns whether to skip the real product stock quantity update after writing or not.
- plural_name() — Returns the translated plural name of the object.
- requireDefaultRecords() — If there are no stock item entries yet, this method will create an initial stock item entry for each product with a stock above or below 0.
- setSkipProductUpdate() — Sets whether to skip the real product stock quantity update after writing or not.
- singular_name() — Returns the translated singular name of the object.
- skipProductUpdate() — Returns whether to skip the real product stock quantity update after writing or not.
- summaryFields() — Returns the summary fields.
Inherited from SilverCart\ORM\ExtensibleDataObject
protected
- beforeRequireDefaultRecords() — Allows user code to hook into DataObject::requireDefaultRecords() prior to requireDefaultRecords being called on extensions.
- beforeUpdateCMSActions() — Allows user code to hook into DataObject::getCMSActions prior to updateCMSActions being called on extensions.
- beforeUpdateFieldLabels() — Allows user code to hook into DataObject::fieldLabels() prior to updateFieldLabels being called on extensions.
- beforeUpdateProvidePermissions() — Allows user code to hook into DataObject::updateProvidePermissions() prior to providePermissions being called on extensions.
- scaffoldFieldLabels() — Returns the default field labels for this DataObject.
public
- defaultFieldLabels() — Returns the default field labels.
- reset_field_labels() — Resets the field label cache.