Documentation

Product
in package

Product as available in the Shop.

Includes access methods and data layer. Do not, I repeat, do not access private fields, or even try to access the database directly!

Tags
version
3.0.0
subpackage

module_shop

copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Reto Kohli reto.kohli@comvation.com

Table of Contents

Constants

TEXT_ADDITIONAL_DETAILS  = 'additional_details'
TEXT_CODE  = 'product_code'
TEXT_DELIVERY_TIME  = 'product_delivery_time'
TEXT_KEYS  = 'product_keys'
TEXT_LONG  = 'product_long'
TEXT_NAME  = 'product_name'
Text keys
TEXT_SHORT  = 'product_short'
TEXT_URI  = 'product_uri'

Properties

$additionalDetails  : string
The additional details
$deliveryTime  : string
The delivery time
$active  : bool
The status is either active (true), or inactive (false).
$arrRelations  : array<string|int, mixed>
$article_id  : int
The article group ID
$b2b  : bool
$b2c  : bool
$category_id  : string
$code  : string
$date_end  : string
$date_start  : string
$discount_active  : bool
$discountprice  : float
$distribution  : Distribution
$flags  : string
The Product flags
$group_id  : int
The count type discount group ID
$id  : int
$keywords  : string
The list of keywords
$long  : string
$manufacturer_id  : int
$minimum_order_quantity  : int
Is defined, when a minimum order quantity should be checked
$name  : string
$ord  : int
$pictures  : string
$price  : float
$resellerprice  : float
$short  : string
$stock  : int
$stock_visible  : bool
$uri  : string
$usergroup_ids  : string
The assigned (frontend) user group IDs
$vat_id  : int
$weight  : int

Methods

__construct()  : Product
Create a Product
active()  : bool
The active status
addAttribute()  : bool
Add the given Product Attribute value ID to this object.
addFlag()  : bool
Add a flag
additionalDetails()  : string
The additional details
article_id()  : string
The article group ID
b2b()  : bool
The B2B flag
b2c()  : bool
The B2C flag
category_id()  : string
The Category ID
clearAttributes()  : bool
Remove all Product Attribute value IDs from this object.
code()  : string
The Product code
date_end()  : string
The end date
date_start()  : string
The start date
decreaseStock()  : bool
Decrease the Product stock count
delete()  : bool
Delete this Product from the database.
deleteAttribute()  : bool
Remove the given Product Attribute value ID from this object.
deliveryTime()  : string
The delivery time
discount_active()  : bool
The special offer flag
discountprice()  : float
The discount price
distribution()  : string
The Distribution type
errorHandler()  : bool
Handles database errors
flags()  : string
The Product flags
get_custom_price()  : float
Returns a product price in the active currency, depending on the Customer and special offer status.
getActiveByScheduledPublishing()  : bool
Get the status of the product based on the scheduled publishing Note: This function does not check whether the product is in scheduled publishing, So make sure the product is in scheduled before calling this method
getById()  : Product|bool
Return the Product with the given ID
getCustomerPrice()  : float
Return the correct Product price for any Customer and Product.
getDiscountedPrice()  : mixed
Return the current discounted price for any Product, if applicable.
getOutletDiscountRate()  : int
Return the discount rate for any Product in the virtual "Outlet" Category.
getStatus()  : bool
Return product status based on the product stock and active settings
group_id()  : int
The count type discount group ID
has_discount()  : bool
Returns boolean true if this Product has any kind of discount.
id()  : int
The ID
insert()  : bool
Insert this Product into the database.
is_outlet()  : bool
Returns boolean true if this Product is flagged as "Outlet"
keywords()  : string
The keywords
long()  : string
The long description
makeClone()  : void
Clone the Product
manufacturer_id()  : int
The Manufacturer ID
minimum_order_quantity()  : int
The minimum order quantity
name()  : string
The Product name
ord()  : int
The Product ordinal value
pictures()  : string
The pictures
price()  : float
The Product price
recordExists()  : bool
Test whether a record with the ID of this object is already present in the database.
removeFlag()  : bool
Remove a flag
resellerprice()  : float
The reseller price
short()  : string
The short description
shown_on_startpage()  : bool
The visibility of the Product on the start page
stock()  : int
The stock
stock_visible()  : bool
The stock visibility
store()  : bool
Stores the Product object in the database.
testFlag()  : bool
Test for a match with the Product flags.
update()  : bool
Update this Product in the database.
uri()  : string
The external link
usergroup_ids()  : string
The assigned Usergroups
vat_id()  : string
The VAT ID
weight()  : string
The weight

Constants

TEXT_ADDITIONAL_DETAILS

public mixed TEXT_ADDITIONAL_DETAILS = 'additional_details'

TEXT_DELIVERY_TIME

public mixed TEXT_DELIVERY_TIME = 'product_delivery_time'

Properties

$additionalDetails

The additional details

protected string $additionalDetails = ''

$deliveryTime

The delivery time

protected string $deliveryTime = ''

$active

The status is either active (true), or inactive (false).

private bool $active = true

Product active status

Tags
access

private

$arrRelations

private array<string|int, mixed> $arrRelations = null

The relation array

Tags
access

private

$article_id

The article group ID

private int $article_id = 0

$b2b

private bool $b2b = true

Product available for b2b

Tags
access

private

$b2c

private bool $b2c = true

Product available for b2c

Tags
access

private

$category_id

private string $category_id = ''

ShopCategory ID or IDs of the Product

Tags
access

private

$code

private string $code = null

Product code

Tags
access

private

$date_end

private string $date_end = null

Product end date

Tags
access

private

$date_start

private string $date_start = null

Product start date

Tags
access

private

$discount_active

private bool $discount_active = false

Product is special offer

Tags
access

private

$discountprice

private float $discountprice = 0.0

Product discount price

Tags
access

private

$group_id

The count type discount group ID

private int $group_id = 0

$id

private int $id = null

The Product ID

Tags
access

private

$keywords

The list of keywords

private string $keywords = null

$long

private string $long = null

Product long description

Tags
access

private

$manufacturer_id

private int $manufacturer_id = 0

Product manufacturer ID

Tags
access

private

$minimum_order_quantity

Is defined, when a minimum order quantity should be checked

private int $minimum_order_quantity = null

$name

private string $name = null

Product name

Tags
access

private

$ord

private int $ord = 1

Sorting order of the Product

Tags
access

private

$pictures

private string $pictures = null

Product pictures

Tags
access

private

$price

private float $price = 0.0

Product price

Tags
access

private

$resellerprice

private float $resellerprice = 0.0

Product price for resellers

Tags
access

private

$short

private string $short = null

Product short description

Tags
access

private

$stock

private int $stock = 10

Product stock

Tags
access

private

$stock_visible

private bool $stock_visible = false

Product stock visibility

Tags
access

private

$uri

private string $uri = null

Product external link

Tags
access

private

$usergroup_ids

The assigned (frontend) user group IDs

private string $usergroup_ids = null

Comma separated list

$vat_id

private int $vat_id = 0

Product VAT ID

Tags
access

private

$weight

private int $weight = 0

Product weight (in grams)

Tags
access

private

Methods

__construct()

Create a Product

public __construct(string $code, string $category_id, string $name, string $distribution, float $price, int $active, int $ord, int $weight[, int $id = 0 ]) : Product

If the optional argument $id is set, the corresponding Product is updated, if it exists. Otherwise, a new Product is created. Set the remaining object variables by calling the appropriate access methods.

Parameters
$code : string

The Product code

$category_id : string

The ShopCategory ID or IDs of the Product (comma separated)

$name : string

The Product name

$distribution : string

The Distribution type

$price : float

The Product price

$active : int

The active status

$ord : int

The sorting order

$weight : int

The Product weight

$id : int = 0

The optional Product ID to be updated

Tags
access

public

author

Reto Kohli reto.kohli@comvation.com

Return values
Product

The Product

active()

The active status

public active([bool $active = null ]) : bool
Parameters
$active : bool = null

The optional active status

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

The active status

addAttribute()

Add the given Product Attribute value ID to this object.

public addAttribute(int $value_id, int $ord) : bool

Note that the relation is is only permanently created after the object is store()d.

Parameters
$value_id : int

The Product Attribute value ID

$ord : int

The sorting order value

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True. Always.

addFlag()

Add a flag

public addFlag(string $flag) : bool

If the flag is already present, nothing is changed. Note that the match is case sensitive.

Parameters
$flag : string

The flag to be added

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

Always true for the time being

additionalDetails()

The additional details

public additionalDetails([string $additionalDetails = null ]) : string
Parameters
$additionalDetails : string = null

The optional additional details of the product

Return values
string

The additional details of the product

article_id()

The article group ID

public article_id([int $article_id = null ]) : string
Parameters
$article_id : int = null

The optional article group ID

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The article group ID

b2b()

The B2B flag

public b2b([bool $b2b = null ]) : bool
Parameters
$b2b : bool = null

The optional B2B flag

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

The B2B flag

b2c()

The B2C flag

public b2c([bool $b2c = null ]) : bool
Parameters
$b2c : bool = null

The optional B2C flag

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

The B2C flag

category_id()

The Category ID

public category_id([string $category_id = null ]) : string
Parameters
$category_id : string = null

The optional Category ID or comma separated list of IDs

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The Category ID or comma separated list of IDs

clearAttributes()

Remove all Product Attribute value IDs from this object.

public clearAttributes() : bool

Note that the relations are only permanently destroyed after the object is store()d.

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

code()

The Product code

public code([string $code = null ]) : string
Parameters
$code : string = null

The optional Product code

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The Product code

date_end()

The end date

public date_end([string $date_end = null ]) : string
Parameters
$date_end : string = null

The optional end date

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The end date

date_start()

The start date

public date_start([string $date_start = null ]) : string
Parameters
$date_start : string = null

The optional start date

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The start date

decreaseStock()

Decrease the Product stock count

public decreaseStock(int $quantity) : bool

This applies to "real", shipped goods only. These have "delivery" set as their "distribution" field value.

Parameters
$quantity : int

The quantity to subtract from the stock

Return values
bool

True on success, false otherwise

delete()

Delete this Product from the database.

public delete([mixed $flagDeleteImages = false ]) : bool

Associated Attributes and pictures are deleted with it.

Parameters
$flagDeleteImages : mixed = false
Tags
global

ADONewConnection $objDatabase Database connection object

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

deleteAttribute()

Remove the given Product Attribute value ID from this object.

public deleteAttribute(int $value_id) : bool

Note that the relation is is only permanently destroyed after the object is store()d. Also note that this method always returns true. It cannot fail. :)

Parameters
$value_id : int

The Product Attribute value ID

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True. Always.

deliveryTime()

The delivery time

public deliveryTime([string $deliveryTime = null ]) : string
Parameters
$deliveryTime : string = null

The optional delivery time of the product

Return values
string

The delivery time of the product

discount_active()

The special offer flag

public discount_active([bool $discount_active = null ]) : bool
Parameters
$discount_active : bool = null

The optional special offer flag

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

The special offer flag

discountprice()

The discount price

public discountprice([float $discountprice = null ]) : float
Parameters
$discountprice : float = null

The optional discount price

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
float

The discount price

distribution()

The Distribution type

public distribution([string $distribution = null ]) : string
Parameters
$distribution : string = null

The optional distribution type

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The distribution type

errorHandler()

Handles database errors

public static errorHandler() : bool

Also migrates text fields to the new structure

Tags
static
throws
Update_DatabaseException
Return values
bool

False. Always.

flags()

The Product flags

public flags([string $flags = null ]) : string
Parameters
$flags : string = null

The optional Product flags

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The Product flags

get_custom_price()

Returns a product price in the active currency, depending on the Customer and special offer status.

public get_custom_price([Customer $objCustomer = null ][, float $price_options = 0 ][, int $count = 1 ][, bool $ignore_special_offer = false ]) : float
Parameters
$objCustomer : Customer = null

The Customer, or null

$price_options : float = 0

The price for Attributes, if any, or 0 (zero)

$count : int = 1

The number of products, defaults to 1 (one)

$ignore_special_offer : bool = false

If true, special offers are ignored. This is needed to actually determine both prices in the products view. Defaults to false.

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
float

The price converted to the active currency

getActiveByScheduledPublishing()

Get the status of the product based on the scheduled publishing Note: This function does not check whether the product is in scheduled publishing, So make sure the product is in scheduled before calling this method

public getActiveByScheduledPublishing() : bool
Return values
bool

TRUE|FALSE True when product is active by scheduled publishing

getById()

Return the Product with the given ID

public static getById(int $id[, int $langId = 0 ]) : Product|bool
Parameters
$id : int

The Product ID

$langId : int = 0

Defaults to FRONTEND_LANG_ID

Tags
global

\ADOConnection $objDatabase

author

Reto Kohli reto.kohli@comvation.com

Return values
Product|bool

The Product object on success, false otherwise

getCustomerPrice()

Return the correct Product price for any Customer and Product.

public getCustomerPrice([Customer &$objCustomer = false ]) : float

Returns the reseller price if a valid Customer object is provided and if this is of the type "reseller". If this method is called without a valid Customer object, the reseller price will never be returned.

Parameters
$objCustomer : Customer = false

The optional Customer object.

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
float

The Product price

getDiscountedPrice()

Return the current discounted price for any Product, if applicable.

public getDiscountedPrice() : mixed
Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
mixed

The Product discount price, or null if there is no discount.

getOutletDiscountRate()

Return the discount rate for any Product in the virtual "Outlet" Category.

public getOutletDiscountRate() : int

The rules for the discount are: 21% at the first date of the month, plus an additional 1% per day, for a maximum rate of 51% on the 31st. Note that this is an example extension only.

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
int

The current Outlet discount rate

getStatus()

Return product status based on the product stock and active settings

public getStatus() : bool
Return values
bool

True when product is active, false otherwise

group_id()

The count type discount group ID

public group_id([int $group_id = null ]) : int
Parameters
$group_id : int = null

The optional group ID

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
int

The group ID

has_discount()

Returns boolean true if this Product has any kind of discount.

public has_discount() : bool

This may either be the regular discount price if discount_active is true, or the "Outlet" discount, or both. Use to get the correct discount price.

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True if there is a discount, false otherwise.

insert()

Insert this Product into the database.

public insert() : bool

Note that associated Text records are not changed here, use store() to do that.

Tags
global

ADONewConnection

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

is_outlet()

Returns boolean true if this Product is flagged as "Outlet"

public is_outlet() : bool

Note that this is an example extension only.

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True if this is "Outlet", false otherwise.

keywords()

The keywords

public keywords([string $keywords = null ]) : string
Parameters
$keywords : string = null

The optional product keywords

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The product keywords

long()

The long description

public long([string $long = null ]) : string
Parameters
$long : string = null

The optional long description

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The long description

makeClone()

Clone the Product

public makeClone() : void

Note that this does NOT create a copy in any way, but simply clears the Product ID. Upon storing this Product, a new ID is created. Also note that all Attributes MUST be link()ed after every insert() in order for this to work properly!

Tags
author

Reto Kohli reto.kohli@comvation.com

manufacturer_id()

The Manufacturer ID

public manufacturer_id([mixed $manufacturer_id = null ]) : int
Parameters
$manufacturer_id : mixed = null
Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
int

The Manufacturer ID

minimum_order_quantity()

The minimum order quantity

public minimum_order_quantity([string $minimum_order_quantity = null ]) : int
Parameters
$minimum_order_quantity : string = null

The optional minimum order quantity

Tags
author

Kaleb Tschbaold kaleb.tschabold@comvation.com

Return values
int

minimum order quanity

name()

The Product name

public name([string $name = null ]) : string
Parameters
$name : string = null

The optional Product name

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The Product name

ord()

The Product ordinal value

public ord([int $ord = null ]) : int
Parameters
$ord : int = null

The optional ordinal value

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
int

The ordinal value

pictures()

The pictures

public pictures([string $pictures = null ]) : string
Parameters
$pictures : string = null

The optional encoded picture string

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The Encoded picture string

price()

The Product price

public price([float $price = null ]) : float
Parameters
$price : float = null

The optional Product price

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
float

The Product price

recordExists()

Test whether a record with the ID of this object is already present in the database.

public recordExists() : bool
Tags
global

ADONewConnection $objDatabase Database connection object

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True if it exists, false otherwise

removeFlag()

Remove a flag

public removeFlag(string $flag) : bool

If the flag is not present, nothing is changed. Note that the match is case insensitive.

Parameters
$flag : string

The flag to be removed

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

Always true for the time being

resellerprice()

The reseller price

public resellerprice([float $resellerprice = null ]) : float
Parameters
$resellerprice : float = null

The optional reseller price

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
float

The reseller price

short()

The short description

public short([string $short = null ]) : string
Parameters
$short : string = null

The optional short description

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The short description

shown_on_startpage()

The visibility of the Product on the start page

public shown_on_startpage([bool $shown_on_startpage = null ]) : bool
Parameters
$shown_on_startpage : bool = null

The optional visibility flag

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

The visibility flag

stock()

The stock

public stock([int $stock = null ]) : int
Parameters
$stock : int = null

The optional stock

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
int

The stock

stock_visible()

The stock visibility

public stock_visible([bool $stock_visible = null ]) : bool
Parameters
$stock_visible : bool = null

The optional stock visibility

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

The stock visibility

store()

Stores the Product object in the database.

public store([int $localeId = 0 ]) : bool

Either updates or inserts the object, depending on the outcome of the call to . Also stores associated Text records.

Parameters
$localeId : int = 0

Optional locale ID. If not set FRONTEND_LANG_ID will be used.

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

testFlag()

Test for a match with the Product flags.

public testFlag(string $flag) : bool

Note that the match is case sensitive.

Parameters
$flag : string

The Product flag to test

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

Boolean true if the flag is present, false otherwise.

update()

Update this Product in the database.

public update() : bool

Note that associated Text records are not changed here, use store() to do that.

Tags
global

ADONewConnection $objDatabase Database connection object

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

uri()

The external link

public uri([string $uri = null ]) : string
Parameters
$uri : string = null

The optional external link

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The external link

usergroup_ids()

The assigned Usergroups

public usergroup_ids([string $usergroup_ids = null ]) : string
Parameters
$usergroup_ids : string = null

The optional comma separated list of assigned user groups

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The comma separated list of assigned user groups

vat_id()

The VAT ID

public vat_id([string $vat_id = null ]) : string
Parameters
$vat_id : string = null

The optional VAT ID

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The VAT ID

weight()

The weight

public weight([string $weight = null ]) : string
Parameters
$weight : string = null

The optional weight

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The weight


        
On this page

Search results