This is the API docs for LemonStand V1, which has been discontinued. LemonStand is now a cloud based platform, available at lemonstand.com.

LemonStand API

Shop_OptionMatrixRecord class

Defined in /modules/shop/models/shop_optionmatrixrecord.php, lines 27-1161
Inheritance Phpr_Extension » Phpr_Extensible » Phpr_Validatable » Db_Base » Db_WhereBase » Db_SqlBase » Db_ActiveRecord » Shop_OptionMatrixRecord
Author LemonStand eCommerce Inc.
Represents Option Matrix record. Usually you don't need to access objects of this class directly.

Public properties

Show inherited properties.

Property Type Description Defined By
auto_create_timestamps array a list of create timestamp columns. Db_ActiveRecord
auto_timestamps boolean determines whether create and update timestamp field should be set automatically. Db_ActiveRecord
auto_update_timestamps array a list of update timestamp columns. Db_ActiveRecord
base_price float specifies the base price of the record. Shop_OptionMatrixRecord
belongs_to array contains a list of Belongs To Many relations. Db_ActiveRecord
calculated_columns array contains a list of calculated columns. Db_ActiveRecord
cost float specifies the product cost. Shop_OptionMatrixRecord
depth float specifies the product depth. Shop_OptionMatrixRecord
disabled boolean determines whether the record is disabled. Shop_OptionMatrixRecord
expected_availability_date Phpr_DateTime specifies the expected availability date. Shop_OptionMatrixRecord
fetched array contains an associative array of table column values fetched from the database. Db_ActiveRecord
has_and_belongs_to_many array contains a list of Has and Belongs To Many relations. Db_ActiveRecord
has_one array contains a list of Has One relations. Db_ActiveRecord
height float specifies the product height. Shop_OptionMatrixRecord
id integer specifies the record database identifier. Shop_OptionMatrixRecord
images Db_DataCollection a collection of images assigned to the category. Shop_OptionMatrixRecord
in_stock integer specifies the number of items in stock. Shop_OptionMatrixRecord
on_sale boolean determines whether the product is on sale. Shop_OptionMatrixRecord
primary_key string specifies a name of the table primary key. Db_ActiveRecord
sale_price_or_discount. string specifies the sale price or discount in the following format: 10, -10, 10%. Shop_OptionMatrixRecord
sku string specifies the product SKU. Shop_OptionMatrixRecord
validation Phpr_Validation contains the model's validation object. Db_ActiveRecord
weight float specifies the product weight. Shop_OptionMatrixRecord
width float specifies the product width. Shop_OptionMatrixRecord

Public methods

Show inherited methods.

Method Description Defined By
add_form_custom_area() adds a form custom area. Db_ActiveRecord
add_form_field() makes a column visible in forms. Db_ActiveRecord
add_form_partial() adds a custom form partial. Db_ActiveRecord
add_form_section() adds a form section. Db_ActiveRecord
after_create() called after a new object is saved to the database. Db_ActiveRecord
after_create_saved() called after a new object is saved to the database. Db_ActiveRecord
after_delete() called after an existing or new record is deleted from the database. Db_ActiveRecord
after_modify() called after an existing or new record was modified. Db_ActiveRecord
after_save() called after an existing or new record is created or updated in the database. Db_ActiveRecord
after_update() called after an existing record is updated in the database. Db_ActiveRecord
after_validation() triggered after the model column values are validated. Db_ActiveRecord
after_validation_on_create() triggered after a new model column values are validated. Db_ActiveRecord
after_validation_on_update() triggered after an existing model column values are validated. Db_ActiveRecord
before_create() called before a new object is saved to the database. Db_ActiveRecord
before_save() called before an existing or new record is created or updated in the database. Db_ActiveRecord
before_update() called before an existing record is updated in the database. Db_ActiveRecord
before_validation() triggered before the model column values are validated. Db_ActiveRecord
before_validation_on_create() triggered before a new model column values are validated. Db_ActiveRecord
before_validation_on_update() triggered before an existing model column values are validated. Db_ActiveRecord
collection() executes the find_all() method and returns a collection. Db_ActiveRecord
columnValue() alias for the displayField() method. Db_ActiveRecord
define_column() adds a column definition to the model. Db_ActiveRecord
define_multi_relation_column() adds column definition for has_and_belongs_to_many or has_many relation field. Db_ActiveRecord
define_relation_column() adds column definition for has_on or belongs_to relation field. Db_ActiveRecord
delete() deletes the record from the database. Db_ActiveRecord
delete_form_field() deletes a form field by its corresponding column name. Db_ActiveRecord
displayField() returns a formatted column value. The field should be defined with define_column(), Db_ActiveRecord
find() finds a record by its primary key value. Db_ActiveRecord
find_all() finds all records and returns the Db_DataCollection object, containing a list of models. Db_ActiveRecord
find_by() finds a record by a field value. Db_ActiveRecord
find_column_definition() finds a column definition by the column name. Db_ActiveRecord
find_form_field() finds a form field definition by its corresponding column name. Db_ActiveRecord
find_record() returns Option Matrix record by option values. Shop_OptionMatrixRecord
get_options() returns options associated with the record as array of option keys and values. Shop_OptionMatrixRecord
get_price() returns product price, taking into account tier pricing. Returns product price with tax included, Shop_OptionMatrixRecord
get_sale_price() returns product sale price. Returns price with tax included, Shop_OptionMatrixRecord
get_sale_reduction() returns the difference between the regular price and sale price of the product. Shop_OptionMatrixRecord
get_volume() returns the product volume. Shop_OptionMatrixRecord
is_low_stock() returns TRUE if inventory tracking for the product is enabled and the product has reached the low stock threshold. Shop_OptionMatrixRecord
is_on_sale() returns TRUE if there are active catalog-level price rules affecting the product price or if the product is on sale ('On Sale' checkbox). Shop_OptionMatrixRecord
is_out_of_stock() returns TRUE if inventory tracking for the product is enabled and the product is out of stock. Shop_OptionMatrixRecord
is_property_supported() determines whether a specified field can be loaded from the record. Shop_OptionMatrixRecord
join() adds a table to the query with JOIN statement. Db_SqlBase
limit() allows to limit the result of the find_all() method with the specified number of records. Db_ActiveRecord
list_related_records_deferred() returns a list of relation objects, taking into account deferred relations. Db_ActiveRecord
options_as_string() returns options associated with the record as string. Shop_OptionMatrixRecord
order() allows to order the result of the find_all() method by a specific table column. Db_SqlBase
orWhere() adds OR statement to the where clause, allowing to to limit the result of the find() and find_all() methods with SQL filter. Db_WhereBase
paginate() allows to limit the result of the find_all() method with a single page of records. Db_ActiveRecord
requestRowCount() returns a number of rows which would be returned with find_all() method. Db_ActiveRecord
reset_cache() resets Option Matrix internal cache. Shop_OptionMatrixRecord
save() saves record to the database. Db_ActiveRecord
where() allows to limit the result of the find() and find_all() methods with SQL filter. Db_WhereBase

Events

Event Description
shop:onAfterOptionMatrixRecordFound Triggered when an Option Matrix record is loaded from the database.
shop:onExtendOptionMatrix Allows to add new columns to the Option Matrix table.
shop:onExtendOptionMatrixRecordModel Allows to add new columns or relations to the Option Matrix model.

Property details

base_price property

public float $base_price;
Specifies the base price of the record.

cost property

public float $cost;
Specifies the product cost.

depth property

public float $depth;
Specifies the product depth.

disabled property

public boolean $disabled;
Determines whether the record is disabled.

expected_availability_date property

public Phpr_DateTime $expected_availability_date;
Specifies the expected availability date.

height property

public float $height;
Specifies the product height.

id property

public integer $id;
Specifies the record database identifier.

images property

public Db_DataCollection $images;
A collection of images assigned to the category. Each element in the collection is an object of the Db_File class. You can use this property directly to output category images, or use the image_url() method. Not proxiable.

in_stock property

public integer $in_stock;
Specifies the number of items in stock.

on_sale property

public boolean $on_sale;
Determines whether the product is on sale.

sale_price_or_discount. property

public string $sale_price_or_discount.;
Specifies the sale price or discount in the following format: 10, -10, 10%.

sku property

public string $sku;
Specifies the product SKU.

weight property

public float $weight;
Specifies the product weight.

width property

public float $width;
Specifies the product width.

Method details

find_record() method

public static Shop_OptionMatrixRecord find_record(array $options, mixed $product, boolean $option_keys=false)
$options array specifies product option values
$product mixed product object (Shop_Product) or product identifier.
$option_keys boolean indicates whether array keys in the $options parameter represent option keys (md5(name)) rather than option names. Otherwise $options keys are considered to be plain option name.
{return} Shop_OptionMatrixRecord returns the Option Matrix record object or NULL.
Returns Option Matrix record by option values. The $options parameter should contain a list of product options and option values in the following format: ['Option name 1'=>'option value 1', 'Option name 2'=>'option value 2'] or: ['option_key_1'=>'option value 1', 'option_key_2'=>'option value 2']. Option keys and values are case sensitive. See also $option_keys parameter.

get_options() method

public array get_options(boolean $option_keys=true)
$option_keys boolean specifies whether options should be presented with option keys instead of names.
{return} array returns an array of option keys and values.
Returns options associated with the record as array of option keys and values.

get_price() method

public float get_price(mixed $product, integer $quantity=1, integer $customer_group_id=NULL, boolean $no_tax=false)
$product mixed product object (Shop_Product) or product identifier.
$quantity integer quantity for the tier price calculations.
$customer_group_id integer Customer group identifier.
$no_tax boolean forces the function to not include tax into the result even if the Display catalog/cart prices including tax option is enabled.
{return} float returns product price.
Returns product price, taking into account tier pricing. Returns product price with tax included, if the Display catalog/cart prices including tax option is enabled unless the $no_tax parameter value is FALSE.

get_sale_price() method

public float get_sale_price(mixed $product, integer $quantity=1, integer $customer_group_id=NULL, boolean $no_tax=false)
$product mixed product object (Shop_Product) or product identifier.
$quantity integer quantity for the tier price calculations.
$customer_group_id integer Customer group identifier.
$no_tax boolean forces the function to not include tax into the result even if the Display catalog/cart prices including tax option is enabled.
{return} float returns product sale price.
Returns product sale price. Returns price with tax included, if the Display catalog/cart prices including tax option is enabled unless the $no_tax parameter value is FALSE.

get_sale_reduction() method

public float get_sale_reduction(mixed $product, integer $quantity=1, $customer_group_id=NULL)
$product mixed product object (Shop_Product) or product identifier.
$quantity integer quantity for the tier price calculations.
$customer_group_id
{return} float returns the sale reduction value.
Returns the difference between the regular price and sale price of the product.

get_volume() method

public float get_volume(mixed $product)
$product mixed product object (Shop_Product) or product identifier.
{return} float returns the volume.
Returns the product volume.

is_low_stock() method

public boolean is_low_stock(mixed $product)
$product mixed product object (Shop_Product) or product identifier.
{return} boolean returns TRUE if the product is out of stock.
Returns TRUE if inventory tracking for the product is enabled and the product has reached the low stock threshold.

is_on_sale() method

public boolean is_on_sale(mixed $product)
$product mixed product object (Shop_Product) or product identifier.
{return} boolean returns TRUE if the product is on sale.
Returns TRUE if there are active catalog-level price rules affecting the product price or if the product is on sale ('On Sale' checkbox).

is_out_of_stock() method

public boolean is_out_of_stock(mixed $product)
$product mixed product object (Shop_Product) or product identifier.
{return} boolean returns TRUE if the product is out of stock.
Returns TRUE if inventory tracking for the product is enabled and the product is out of stock.

is_property_supported() method

public mixed is_property_supported(string $field_name)
$field_name string specifies the field name.
{return} mixed returns TRUE if the field could be loaded from the record. Otherwise returns name of a product field.
Determines whether a specified field can be loaded from the record. Not supported properties are loaded from a base product.

options_as_string() method

public void options_as_string()
Returns options associated with the record as string. The returned string has the following format: Color: green, Size: large.

reset_cache() method

public static void reset_cache()
Resets Option Matrix internal cache. Option Matrix caches records within a single request using product options as a cache key.