Products

Access, create, update and delete the products in your online catalogue.

Class Methods

The following methods can be invoked on instances of this class.

fieldsGetPrimaryKey()

Returns the primary key

fieldsGetCreatedAt()

fieldsGetModifiedAt()

getOrder()

dbGetTableName()

dbGetAssociatedTables()

fieldsGetPrefix()

fieldsGetAllImages()

fieldsGetAllHTML()

fieldsGetOffline()

fieldsGetAllNoHistory()

optionShouldRecordChanges()

eventGetHandlers()

alterEntity(array arrEntity)

Applies taxes and discounts

alterEntityApplyDiscounts(array arrEntity)

Applies discounts to products

alterEntityApplyTaxes(array arrEntity)

alterEntityURI(array arrEntity)

Adds the uri field to an entity

alterEntityVisibility(array arrEntity)

Alter the visibility of the product against the currently logged in contact

get(mixed strKey)

getNoAlterEntity(mixed strKey)

Returns an entity

getNoDiscounts(mixed strKey)

Returns an entity without discounts being applied

getByProductTitle(mixed strTitle)

Returns an entity

getByProductCode(mixed strCode)

Returns an entity

checkProductVisibilityForContact(mixed arrProduct, int iContactId)

Check if the contact belongs to a visible group of the product

discountAppliesToProduct(mixed arrProduct, array arrDiscountEntities)

Determines if a discount applies to a specific product

getConsole(mixed strKey)

Returns an entity

getColumn(mixed strKey, string strColumn)

Returns a single column of an entity

getAll(mixed arrProperties)

getAllConsole(mixed arrProperties)

Returns all entities in the database

getCountForCategoryAndBrandConsole(mixed iCategoryId, mixed iBrandId, mixed arrProperties)

getAllForCategoryAndBrandConsole(mixed iCategoryId, mixed iBrandId, mixed arrProperties)

getCountForCategoryAndBrand(mixed iCategoryId, int iBrandId)

Returns the number of products in a category and brand

getAllForCategoryAndBrand(mixed iCategoryId, int iBrandId, mixed arrProperties)

Returns all products for a given category and brand

getAllForCategoryAndBrandRecursive(mixed iCategoryId, int iBrandId, mixed arrProperties)

Returns all products for a given category and brand

getAllForInventoryItem(int iInventoryId)

Returns all products for a given Inventory Item

getCountInvalidShipping(mixed bRequiresWeight, mixed bRequiresDimensions)

Returns the number of products with invalid shipping options

feedInjectLinks(int iCategoryId)

Injects RSS and Atom feed links within the document <head>

feedInjectPriceAndPictureIntoContent(array arrEntity)

Injects the product price and picture into its content

feedGetData(mixed bGoogleShopping)

Returns the data required for a feed

feedGetGoogleAtom()

Renders the Google Shopping Atom feed

feedGetAtom(bool bGoogleShopping)

Renders the Atom or Google Shopping Atom feed

feedGetGoogleRss()

Renders the Google Shopping RSS feed

feedGetRss(bool bGoogleShopping)

Renders the RSS or Google Shopping RSS feed

feedGetXml()

Renders the Synergy8 XML feed

feedGetJson()

Renders the Synergy8 JSON feed

search(mixed strSearch, array arrProperties)

Performs a search

_save(mixed arrEntity, string strReason)

Saves an entity

uriSuffixGenerate(mixed arrEntity)

Generates the page URI suffix (SEO slug URI for the category)

uriSuffixIsAvailable(array arrEntity)

Determines if a URIsuffix for a given entity is available

getFromPageURI(string strPageURI)

Retrieves a product from its page URI suffix
$strPageURI may be the full URL or just the suffix

changeBrands(mixed iBrandId, int iNewBrandId)

Changes all products that have brand $iBrandId to have brand $iNewBrandId

_cloneEntity(mixed strOldKey, mixed strNewKey, bool bCloneMedia)

Clones an entity, resaving it with a new key value

_delete(string strKeyValue, mixed bDeleteMedia, mixed strReason)

Deletes a product

productTaxesSave(mixed iProductId, mixed arrTax, mixed arrTaxAmount)

productTaxesDeleteAllForProduct(mixed iProductId)

productTaxesGetConsole(mixed arrEntity)

productTaxesGet(int iProductId)

Retrieves and arrange the current tax rate for a specific product

determinePriceWithOrderOptions(mixed iProductId, mixed arrOrderOptionsPost)

renderPrice(mixed iProductPrice, mixed strTags)

renderDiscountPrice(mixed arrProduct, mixed strColor, mixed bShortDisplay)

renderAdmin(mixed arrEntity, mixed bAllowOverride)

isStoreClosed()

Returns whether or not the store is currently closed for vacation

getUnorderableMessage(array arrProduct)

Returns the text reason why a product is unorderable

getLabelForOrderOptionValue(mixed arrOptionValue)

Returns a formatted label for an option value

orderOptionsRequireRepost(mixed arrOptionValues)

fieldsGetPrimaryKeyIsTextual()

Defines if the component uses textual primary keys or not

fieldsGetOrder()

Returns the name of the field which allows for manual ordering

fieldsGetParentId()

Returns the name of the field which holds the parent id for tree like tables

changePush(array arrChange)

Pushes a group of changes for the current component

changePop()

Pops the last group of changes

changeRecord(mixed strEntityId, mixed arrEntity, mixed strChangeType, string strReason)

Records a history entry

dbGetJoins()

Returns an array of the table joins
Example syntax: // LEFT JOIN commerce_sales USING(contact_id) $arrJoins = array(array('commerce_sales', 'contact_id')) // LEFT JOIN commerce_sales ON (customers_contacts.contact_id = commerce_sales.contact_id) $arrJoins = array(array('commerce_sales', array('contact_id', 'contact_id'))) // LEFT JOIN foreign_table2 ON (foreign_table1.foreign_field1 = foreign_table2.foreign_field2) $arrJoins = array(array('foreign_table2', array('foreign_table1.foreign_field1', 'foreign_field2')))

dbQueryBuild(array arrProperties)

Returns the query corresponding to an $arrProperties

dbQueryBuildSelect(mixed arrColumns)

Returns the SELECT clause from a set of columns

dbQueryBuildFrom(array arrJoins)

Returns the from clause inclusive of " FROM "
Example syntax: // LEFT JOIN commerce_sales USING(contact_id) $arrJoins = array(array('commerce_sales', 'contact_id')) // LEFT JOIN commerce_sales ON (customers_contacts.contact_id = commerce_sales.contact_id) $arrJoins = array(array('commerce_sales', array('contact_id', 'contact_id'))) // LEFT JOIN foreign_table2 ON (foreign_table1.foreign_field1 = foreign_table2.foreign_field2) $arrJoins = array(array('foreign_table2', array('foreign_table1.foreign_field1', 'foreign_field2')))

dbQueryBuildWhereHelper(array arrFilter)

Recursively converts array filters to SQL filters
$arrFilter = array( array('contact_postcode', '>', 4000), 'AND', array('contact_postcode', '<', 5000) )

dbQueryBuildWhere(array arrFilter)

Returns the WHERE clause inclusive of " WHERE "

dbQueryBuildGroupBy(mixed arrGroupBy)

dbQueryBuildOrderBy(array arrOrder, mixed bNoDefault)

Returns a complete order by clause including the "ORDER BY" statement
Note: This static function can be overridden if the user wishes to make a tricky order by clause.

dbQueryBuildHaving(array arrFilter)

Returns a HAVING clause

dbQueryBuildLimit(mixed iStart, int iLimit)

Returns a LIMIT clause

dbQueryBuildSetStatement(mixed arrEntity, bool bIncludeKey)

Generates a SET statement for SQL

dbQueryInsertOrReplace()

Returns whether to INSERT or REPLACE when save()ing

dbOptimiseTable()

Optimizes the database table

dbIsSystemTable()

dbDropTable(mixed bAllowDropSystem)

Drops a custom table

dbAlterField(array arrField, mixed strAfter)

Modifies a database field

dbDropField(string strField)

Drops a custom field

dbAddIndex(mixed strField, string strIndex, mixed strIndexName)

Adds an index on a field

dbDropIndex(mixed strIndexKey, mixed bAllowDropSystem)

Drops an index

dbGetSystemFields(mixed strTableName)

Get the system fields for the table associated to this component

dbGetSystemFieldsList()

Get a list of the system fields

dbIndexesRebuild()

dbIndexesRebuildFullText()

Recreates the fulltext index for the entire table
TODO: move this to custom fields

dbSave(mixed arrEntity)

Saves an entity

dbSaveColumn(mixed strKeyValue, mixed strColumn, mixed strValue)

fieldsGetAllNoExport()

Returns an array of fields which are excluded from export

indexesGetAll()

Returns all the indexes in the table

fieldsGetAll(mixed bCached)

Returns all the columns this component supports

fieldsIsEditable(string strField)

Determines if a specific field was tagged as editable in the JSON shema

fieldsGetAllEditable()

Returns all the fields which were tagged as editable in the JSON schema

fieldsGetAllFlat(mixed bCached)

Returns a linear array of the columns that this dataadapter support.

fieldsGet(string strField)

Retrieves a single column

fieldsGetAllForcedAsStrings()

Returns fields that must be treated as strings when writing to the database

fieldsGetAllSearchable()

Returns fields to be used via search()

fieldsCustomGetAll()

Returns all the columns in the custom fields table

fieldsCustomGetAllExt(mixed bPublic, mixed bShowInLists, mixed bSearchable, mixed arrCustomFilter)

Returns all the columns in the custom fields table

fieldsCustomGetIsCustom(string strField)

Check if the field is customisable or not

securityOperationsGetAll()

getSchema()

Returns the JSON schema of the component primary table

getNext(string|int mixedId)

Returns the next entity from an id, based on its primary key

getPrevious(string|int mixedId)

Returns the next entity from an id, based on its primary key

getExistingEntity(mixed arrEntity, mixed bUseComponentOwnScope)

getIsNewEntity(mixed arrEntity, mixed bUseComponentLogic)

dbGet(mixed strKeyValue)

Returns an entity without a filesystem fallback

dbDeleteWithFilter(mixed arrFilter)

getWithFilter(array arrFilter)

Returns an entity without a filesystem fallback

getAllLocal(array arrProperties)

Returns a collection of entities

getCount(array arrFilter)

Returns a count of all rows in the data adapter

getAllIds()

Returns a linear array of all ids of enities in the data adapter

getAutoIncrementId(mixed arrEntity)

Returns the last inserted id

getFirst(array arrProperties)

Retrieves the first entity from a collection of entities

moveToPosition(mixed iEntityId, mixed iParentId, int iPosition)

Inserts an existing entity at a specific location

optionCanRollbackChanges()

Determines if changes on the component can be rollbacked

optionHasMedia()

Returns whether or not this data adapter should create media folders

mediaUrlGet(mixed strKey, string strFileName)

Returns the URL for a specific media/entity couple

mediaFolderGet(mixed strKey)

Returns the media folder for this data adapter

mediaFolderCreate(string strKey)

Creates the media folder for an entity

nullifyIfNotSet(mixed arrEntity, string strField)

Nullifies $arrEntity[$strField] if its not set

nullifyIfEmpty(mixed arrEntity, string strField)

Nullifies $arrEntity[$strField] is an empty string

saveHandleArrayField(mixed arrEntity, string strField)

Nullifies $arrEntity[$strField] if its an empty array, or serializes it

getHandleArrayField(mixed arrEntity, mixed strField)

securityHasCustomOperations()

If this method returns true, the default security settings will not be applied to
the save and delete methods.

securityOperationsValidate(string strOperationId)

Throws ExceptionSecurity if the operation is not valid for the current user

securityOperationsIsValid(string strOperationId)

Returns whether or not a security operation is valid

securityOperationsIsSet(string strOperationId)

Returns whether or not a security operation has been set / defined

getTotalSize()

Returns the size of the table

saveColumn(mixed strKeyValue, mixed strColumn, mixed strValue, string strReason)

Changes a column of an existing entity
Supports primary keys spanning on several columns if passing $strKeyValue as an associative arry

save(mixed arrEntity, string strReason)

Saves an entity and triggers the pre/post component events

saveWriteImages(array arrEntity)

Writes the image to the filesystem and updates $arrEntity

saveCleanHTMLFields(array arrEntity)

Cleans all html fields specified by fieldsGetAllHTML()

saveCleanHTMLField(string strHTML)

Cleans a single html field

saveCleanHTMLFieldCbFixURL(mixed strURL)

saveCleanHTMLFieldCbFixLinks(array arrMatches)

Ensures that any hyperlinks to pages have correct slashes

saveCleanHTMLFieldCbFixImages(array arrMatches)

Ensures that any images are correctly resized and that static remote images are
downloaded to the local media folder

saveMultiple(array arrEntities)

Saves multiple entities

baseMove(mixed strKeyValue, string strKeyValueNew)

Moves / renames the resources associated to an entity
Expensive! Use only for textual ids such as page ids

baseSaveRequirePrimaryKey(mixed arrEntity)

baseSave(mixed arrEntity, string strReason)

Saves an entity

baseDelete(mixed strKeyValue, bool bDeleteMedia)

Deletes the resources associated to an entity

delete(mixed strKeyValue, bool bDeleteMedia, mixed strReason)

Deletes an entity and triggers the pre/post component events

deleteWithFilter(array arrFilter)

Deletes entities using a filter

_move(mixed strKeyValue, string strKeyValueNew)

Moves / renames an entity

move(mixed strKeyValue, string strKeyValueNew)

Moves / renames an entity and triggers the pre/post component events

cloneEntity(mixed strOldKey, mixed strNewKey, bool bCloneMedia)

Clones an entity and triggers the pre/post component events

analyticsGetDateField()

Returns the name of the date field which analytics are based off

analyticsGetDateFilter(mixed strDateStart, string strDateEnd)

Returns a data filter for a date range

analyticsGetAll(mixed strDateStart, mixed strDateEnd, mixed arrProperties)

analyticsGetCount(mixed strDateStart, mixed strDateEnd, array arrProperties)

Returns the total number of records for a period

analyticsGetCounts(mixed strDateStart, mixed strDateEnd, mixed strInterval, array arrProperties)

Returns the number of records over a period

analyticsGetMetric(mixed strMetricName, mixed strDateStart, mixed strDateEnd, array arrProperties)

Retrieves a metric defined for the current component

analyticsGetSum(mixed strColumn, mixed strDateStart, mixed strDateEnd, array arrProperties)

Returns the sum of a column for a period

analyticsGetSums(mixed strColumn, mixed strDateStart, mixed strDateEnd, mixed strInterval, array arrProperties)

Returns the sums of a column over a period

analyticsGetTypes(mixed strTypeColumn, mixed strDateStart, mixed strDateEnd, mixed arrProperties)

cacheIsSet(mixed mixedKey)

cacheGet(mixed mixedKey)

cacheKeyFromKey(mixed mixedKey)

Returns a key for the query cache array from the value of a primary key

cacheKeyFromEntity(array arrEntity)

Returns a key for the query cache array for a particular entity

cacheSavePartial(array arrEntity)

Updates the cache with an entity to be saved

cacheSaveFull(mixed mixedKeyValue, array arrEntity)

Updates the cache with a full entity fetched from the db

cacheSaveColumn(mixed mixedKeyValue, mixed strColumn, string strValue)

Updates the cache with a column value to be saved

cacheDelete(string mixedKeyValue)

Deletes an item, setting its cache to null

cacheFlush()

Flushes / clears the cache

cacheFlushAll()

Flushes / clears the cache for all components

install()

uninstall()

classGetFolderSystemFields()

Returns the folder where the class's fields exist

componentIsInstalled()

Determines if a specific component is installed

componentGetEntityType(mixed arrEntity)

Returns the type of entity handled by the component

componentGetEntityIcon()

Retrieves the default icon path for the component entities

eventTrigger(mixed strEvent, array arrEventParams)

Triggers a component event

configGetAll(array arrProperties)

Retrieves all config items for the component

configGetAllValues(array arrProperties)

Retrieves all config items for the component in a item_id => item_value fashion

configGetValue(string strConfigId)

Retrieves the value of a config item for the current component

configSaveValue(mixed strConfigId, mixed strValue, string strReason)

Saves the value of a config item for the current component

uiGetActions(mixed bInList, bool bInEdit)

Returns an array of user interface actions for the component

__call(mixed strName, array arrArguments)

Magic function to trap calls to undefined functions and throw an exception rather than
a fatal error.

__callStatic(mixed strName, array arrArguments)

Magic function to trap static calls to undefined functions and throw an exception rather
than a fatal error.

classGetFolder()

Returns the folder where the class exists

__set_state(mixed arrValues)

classGetFolderResources()

Returns the folder where the class's resources exist

classGetSrcFile()

Returns the folder where the class exists

classGetSrcHash()

Returns the folder where the class exists

classGetReflection()

Returns the reflection data for the current class

classGetReflectionAnnotation(string strField)

Returns a specific class annotation for the current class

Fields

The following fields are used when retrieving and saving entities.

product_id  - int unsigned (10)

product_title  - varchar (127)

product_price_base  - decimal unsigned (8,2)  | Default value: 0.00

product_icon  - varchar (127)

product_order  - int (11)

product_content  - longtext

product_order_form  - longtext

product_created_datetime  - datetime

product_modified_datetime  - datetime

product_is_offline  - tinyint (1)

product_is_unorderable  - tinyint unsigned (1)

product_is_orderable_for_someone_else  - tinyint unsigned (1)

product_disables_guest_checkout  - tinyint (1)

product_code  - varchar (63)

product_barcode  - varchar (31)

product_sales_description  - varchar (255)

product_order_options  - text

product_is_shipping_required  - tinyint unsigned (1)  | Default value: 1

product_shipping_width_mm  - int unsigned (10)

product_shipping_height_mm  - int unsigned (10)

product_shipping_depth_mm  - int unsigned (10)

product_shipping_weight_g  - int unsigned (10)

product_inventory_level  - int unsigned (10)

product_inventory_is_public  - tinyint unsigned (1)

product_inventory_is_unorderable_sold_out  - tinyint unsigned (1)

product_inventory_purchase_cost  - decimal unsigned (8,2)

product_brand_id  - int unsigned (10)

product_group_pricing_visibility  - text

product_group_pricing_adjustments_base  - text

product_group_pricing_show_adjustments  - text

product_group_pricing_show_normal  - text

product_group_pricing_show_adjustments_labels  - text

product_group_pricing_show_normal_labels  - text

product_max_quantity  - int unsigned (10)

product_min_quantity  - int unsigned (10)

product_uri_suffix  - varchar (255)

product_uri_suffix_is_overriden  - tinyint unsigned (1)

product_search_keywords  - varchar (255)

product_search_keywords_is_overriden  - tinyint unsigned (1)

product_search_description  - varchar (255)

product_search_description_is_overriden  - tinyint unsigned (1)

product_xero_account  - varchar (255)

product_is_recurring  - int (11)

recurring_sale_schedule_interval  - enum ('','weekly','fortnightly','monthly','quarterly','yearly')  | Default value: monthly

recurring_sale_amount  - decimal unsigned (10,4)

recurring_sale_requires_creditcard  - tinyint (4)

Product Brands
Access, create, update and delete the brands of products that you sell online.

Product Categories
Access, create, update and delete the categories of products that you sell online.

Inventory
Access, create, update and delete your inventory items.

Inventory
How inventory items relate to products. Eg - a product can consist of several inventory
items.