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

Defined in /modules/shop/models/shop_manufacturer.php, lines 44-554
Inheritance Phpr_Extension » Phpr_Extensible » Phpr_Validatable » Db_Base » Db_WhereBase » Db_SqlBase » Db_ActiveRecord » Shop_Manufacturer
Author LemonStand eCommerce Inc.
Represents a product manufacturer. This class has fields and methods for accessing a manufacturer name, address and contact information. Objects of this class are accessible through the manufacturer field of the Shop_Product class.
You can use the following code for displaying a list of manufacturers on a page:
<? $manufacturers = Shop_Manufacturer::create()->order('name')->find_all(); ?>
<ul>
  <? foreach ($manufacturers as $manufacturer): ?>
    <li><?= h($manufacturer->name) ?></li>
  <? endforeach ?>
</ul>
Alternatively you can use the shop:manufacturers action for creating the Manufacturer List Page.

Public properties

Show inherited properties.

Property Type Description Defined By
address string specifies the manufacturer address. Shop_Manufacturer
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
city string specifies the manufacturer city. Shop_Manufacturer
country Shop_Country specifies the manufacturer country. Shop_Manufacturer
custom_columns array contains a list of custom fields definition. Db_ActiveRecord
description string specifies the manufacturer description. Shop_Manufacturer
email string specifies the manufacturer email address. Shop_Manufacturer
fax string specifies the manufacturer fax number. Shop_Manufacturer
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
id integer specifies the manufacturer record identifier. Shop_Manufacturer
is_disabled boolean determines whether the manufacturer is disabled. Shop_Manufacturer
logo Db_DataCollection a collection of the manufacturer logo images. Shop_Manufacturer
name string specifies the manufacturer name. Shop_Manufacturer
phone string specifies the manufacturer phone number. Shop_Manufacturer
primary_key string specifies a name of the table primary key. Db_ActiveRecord
state Shop_CountryState specifies the manufacturer country state. Shop_Manufacturer
url string specifies the manufacturer website URL. Shop_Manufacturer
url_name string specifies the manufacturer URL name. Shop_Manufacturer
validation Phpr_Validation contains the model's validation object. Db_ActiveRecord
zip string specifies the manufacturer ZIP/postal code. Shop_Manufacturer

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_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
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_categories() returns a list of product categories the manufacturer products belong to. Shop_Manufacturer
list_products() returns a list of the manufacturer products. Shop_Manufacturer
list_related_records_deferred() returns a list of relation objects, taking into account deferred relations. Db_ActiveRecord
logo_url() returns an URL of the manufacturer logo image thumbnail. Shop_Manufacturer
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
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:onExtendManufacturerForm Allows to add new fields to the Create/Edit Manufacturer form in the Administration Area.
shop:onExtendManufacturerModel Allows to define new columns in the product manufacturer model.
shop:onGetManufacturerFieldOptions Allows to populate drop-down, radio- or checkbox list fields, which have been added with shop:onExtendManufacturerForm event.
shop:onGetManufacturerFieldState Determines whether a custom radio button or checkbox list option is checked.

Property details

address property

public string $address;
Specifies the manufacturer address.

city property

public string $city;
Specifies the manufacturer city.

country property

public Shop_Country $country;
Specifies the manufacturer country.

description property

public string $description;
Specifies the manufacturer description.

email property

public string $email;
Specifies the manufacturer email address.

fax property

public string $fax;
Specifies the manufacturer fax number.

id property

public integer $id;
Specifies the manufacturer record identifier.

is_disabled property

public boolean $is_disabled;
Determines whether the manufacturer is disabled. Disabled manufacturers are not displayed by the shop:manufacturers and shop:manufacturer CMS actions.

logo property

public Db_DataCollection $logo;
A collection of the manufacturer logo images. The collection always contains zero or one element - an object of Db_File class. See logo_url() method.

name property

public string $name;
Specifies the manufacturer name.

phone property

public string $phone;
Specifies the manufacturer phone number.

state property

public Shop_CountryState $state;
Specifies the manufacturer country state.

url property

public string $url;
Specifies the manufacturer website URL.

url_name property

public string $url_name;
Specifies the manufacturer URL name.

zip property

public string $zip;
Specifies the manufacturer ZIP/postal code.

Method details

list_categories() method

public Db_DataCollection list_categories(array $options=array())
$options array specifies the method options.
{return} Db_DataCollection returns a collection of Shop_Category objects.
Returns a list of product categories the manufacturer products belong to. You can pass an array of options to the method. The only supported option is sorting
$categories = $manufacturer->list_categories(array(
  'sorting'=>array('name', 'code')
));
The supported fields you can sort the categories by are:
  • name - sort the category list by name
  • code - sort the category list by the API code
  • title - sort the category list by title
  • front_end_sort_order - sort the category list by the sort order defined in the Administration Area manually
  • rand() - sort categories randomly

You can add desc suffix to the sort field name to enable the descending sorting:
$categories = $manufacturer->list_categories(array(
  'sorting'=>array('name desc')
));

list_products() method

public Shop_Product list_products(array $options=array())
$options array specifies the method options.
{return} Shop_Product returns an object of the Shop_Product class.
Returns a list of the manufacturer products. The result of this function is an object of the Shop_Product class. To obtain a collection of all manufacturer products call the find_all() methods of the method result.
$full_product_list = $manufacturer->list_products()->find_all();
You can pass an array of options to the method parameter. The currently supported option is the sorting. By default the product list is sorted by product name. You can sort product them by another field. Also, you can sort the product list by multiple fields:
$product_list = $manufacturer->list_products(array(
  'sorting'=>array('price', 'name')
))
The supported fields you can sort the products are:
  • name - sort the product list by name
  • price - sort the product list by the base price
  • sku - sort the product list by SKU
  • weight - sort the product list by weight
  • width - sort the product list by width
  • height - sort the product list by height
  • depth - sort the product list by depth
  • created_at - sort the product list by the product creation date
  • rand() - sort products randomly
  • manufacturer - sort products by the manufacturer name
  • expected_availability_date - sort products by the availability date
You can add desc suffix to the sort field name to enable the descending sorting. For example, to sort the product list by price in descending order, you can use the following code:
$product_list = $manufacturer->list_products(array(
  'sorting'=>array('price desc')
))
You can add custom sorting fields with shop:onGetProductSortColumns event.

logo_url() method

public string logo_url(mixed $width, mixed $height, boolean $as_jpeg=true, array $params=array( 'mode'=>'keep_ratio'))
$width mixed specifies the thumbnail width. Use the 'auto' word to scale image width proportionally.
$height mixed specifies the thumbnail height. Use the 'auto' word to scale height width proportionally.
$as_jpeg boolean determines whether JPEG or PNG image will be created.
$params array a list of parameters.
{return} string returns the image URL relative to the website root.
Returns an URL of the manufacturer logo image thumbnail. The method returns NULL if the logo was not uploaded. Use this method for displaying a manufacturer logo. You can use exact integer values for the $width and $height parameters, or word 'auto' for automatic image scaling. The $as_jpeg parameter allows you to generate PNG images with transparency support. By default the parameter value is TRUE and the method generates a JPEG image. Pass the FALSE value to the parameter to generate a PNG image. The $params array allows to pass parameters to image processing modules (which handle the core:onProcessImage event). The following line of code outputs a thumbnail of the manufacturer logo. The thumbnail width is 100 pixels, and thumbnail height is calculated by LemonStand to keep the original aspect ratio.
<img src="<?= h($product->manufacturer->logo_url(100, 'auto')) ?>"/>