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_OptionMatrixManager class

Defined in /modules/shop/classes/shop_optionmatrixmanager.php, lines 11-511
Author LemonStand eCommerce Inc.
Provides methods for creating and updating Option Matrix records.

Public methods

Method Description Defined By
add_or_update() adds or updates Option Matrix record in the database. Shop_OptionMatrixManager
get_record() returns data field values for Option Matrix record identified with product options and product. Shop_OptionMatrixManager
__construct() creates the Option Matrix Manager class instance. Shop_OptionMatrixManager

Method details

add_or_update() method

public mixed add_or_update(Shop_Product $product, array $options, array $data, boolean $skip_existing=false)
$product Shop_Product specifies a product the record belongs to.
$options array a list of the product options and option values in the following format: ['Color'=>'Red', 'Size'=>'M'].
$data array data values to assign to the record.
$skip_existing boolean skip the operation if a record with specified options already exists (do not update it).
{return} mixed returns an object with the following fields: status, operation, warnings, id.
Adds or updates Option Matrix record in the database. The $options parameter should contain data values to assign to the record, as an associative array. Below is a full list of supported fields:
  • disabled - determines whether the record is disabled. String value, accepts yes and no values.
  • sku - specifies the product SKU.
  • images - an array of absolute paths to image files.
  • base_price - specifies the base price of the record.
  • tier_price - an array of tier prices in the following format: [['group_id'=>10, 'quantity'=>4, 'price'=>10], ...]. Use NULL for group_id element to indicate "Any customer group".
  • cost - specifies the product cost.
  • on_sale - determines whether the product is on sale.
  • sale_price_or_discount - specifies the sale price or discount in the following format: 10, -10, 10%.
  • in_stock - specifies the number of items in stock.
  • expected_availability_date - specifies the expected availability date in format YYYY-MM-DD.
  • allow_pre_order - indicates whether pre-ordering is allowed.
  • weight - specifies the product weight.
  • width - specifies the product width.
  • height - specifies the product height.
  • depth - specifies the product depth.
  • API columns - any columns added with shop:onExtendOptionMatrix event.
The method returns an object with the following fields:
  • status - OK, SKIPPED or OK-WITH-WARNINGS string value.
  • operation - ADD or UPDATE string value.
  • warnings - an array of warnings.
  • id - identifier of the added/updated record.
The method throws an exception if the operation cannot be executed. Usage example:
$manager = new Shop_OptionMatrixManager();

$options = array(
  'Color'=>'Red',
  'Size'=>'Large'
);

$data = array(
  'disabled'=>'no',
  'sku'=>'red-large',
  'images'=>array(PATH_APP.'/temp/images/red-1.jpg', PATH_APP.'/temp/images/red-2.jpg'),
  'base_price'=>50,
  'cost'=>10,
  'on_sale'=>true,
  'allow_pre_order'=>true,
  'sale_price_or_discount'=>'10%',
  'in_stock'=>32,
  'expected_availability_date'=>'2012-05-29',
  'weight'=>50,
  'width'=>12,
  'height'=>13,
  'depth'=>14
);

$status = $manager->add_or_update($test_product, $options, $data);

get_record() method

public mixed get_record(mixed $product, array $options)
$product mixed specifies either product identifier or product object (Shop_Product) the record belongs to.
$options array a list of the record options in the following format: ['Color'=>'Red', 'Size'=>'M']
{return} mixed returns an object containing the record data or NULL if the record cannot be found.
Returns data field values for Option Matrix record identified with product options and product.

__construct() method

public Shop_OptionMatrixManager __construct()
{return} Shop_OptionMatrixManager returns the manager object.
Creates the Option Matrix Manager class instance.