ZenMagick 0.9.6


org.zenmagick.service.ZMProducts

Class ZMProducts

ZMObject
|
+--ZMProducts
All Implemented Interfaces:
ZMSQLAware

public class ZMProducts
extends ZMObject

Product access.

Author:
DerManoMann
Version:
$Id: ZMProducts.php 2157 2009-04-14 23:31:34Z dermanomann $

Field Summary
final mixed

IMAGE_LARGE

final mixed

IMAGE_MEDIUM

final mixed

IMAGE_SMALL

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMProducts()

Create new instance.

Method Summary
array

getAllProducts(boolean active, int languageId)

Get all products.

protected ZMQueryDetails

getAllProductsQueryDetails(boolean active, int languageId)

Get all products.

array

getBestSellers(int categoryId, int max, int languageId)

Get best seller products.

array

getFeaturedProducts(int categoryId, int max, boolean includeChildren, int languageId)

Get random featured products.

array

getNewProducts(int categoryId, int max, int timeLimit, int languageId)

Get random new products.

ZMProduct

getProductForId(int productId, int languageId)

Get a product for the given product id.

ZMProduct

getProductForModel(string model, int languageId)

Get a product for the given model name.

private array

getProductIds(string sql, array args, mixed tables)

Execute the given SQL and extract the resulting product ids.

array

getProductIdsForCategoryId(int categoryId, boolean active, boolean includeChildren, int languageId)

Get list of all active product ids for a given category.

boolean

getProductTypeSetting(int productId, string field, mixed keyPprefix, string keySuffix, string fieldPrefix, string fieldSuffix, string keyPrefix)

Test if a given product type option is enabled for a given product.

array

getProductsForCategoryId(int categoryId, boolean active, int languageId)

Get all (active) products for the given category id.

protected array

getProductsForCategoryIdQueryDetails(int categoryId, boolean active, int languageId)

Get all (active) products for the given category id.

ZMProduct

getProductsForIds(array productIds, boolean preserveOrder, int languageId)

Load a list of products.

void

getProductsForManufacturerId(mixed manufacturerId, mixed active, mixed languageId)

array

getProductsForSQL(string sql, int languageId)

Execute the given SQL and return the resulting product.

void

getQueryDetails(mixed method, mixed args)

{@inheritDoc} /

private array

getRandomProductIds(string sql, int max, array args, mixed tables)

Get some random product ids.

array

getSpecials(int max, int languageId)

Get random products marked as specials.

static void

instance()

Get instance.

boolean

isQuantityAvailable(int productId, int quantity)

Check if a certain quantity of a given product is available.

ZMProduct

updateProduct(ZMProduct product)

Update an existing product.

void

updateViewCount(int productId, int languageId)

Update the view count for a product.

Methods inherited from org.zenmagick.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Field Detail

IMAGE_LARGE

public final mixed IMAGE_LARGE = 'large'

IMAGE_MEDIUM

public final mixed IMAGE_MEDIUM = 'medium'

IMAGE_SMALL

public final mixed IMAGE_SMALL = 'small'

Constructor Detail

ZMProducts

public ZMProducts()

Create new instance. /


Method Detail

getAllProducts

public array getAllProducts(boolean active, int languageId)

Get all products.

Parameters:
active - If true return only active products; default is true.
languageId - Optional language id; default is null for session language.
Returns:
A list of ZMProduct instances.

getAllProductsQueryDetails

protected ZMQueryDetails getAllProductsQueryDetails(boolean active, int languageId)

Get all products.

Parameters:
active - If true return only active products; default is true.
languageId - Optional language id; default is null for session language.
Returns:
Query details.

getBestSellers

public array getBestSellers(int categoryId, int max, int languageId)

Get best seller products.

Parameters:
categoryId - Optional category id to narrow down results; default is null for all.
max - The maximum number of results; default is null to use the setting maxBestSellers.
languageId - Optional language id; default is null for session language.
Returns:
A list of ZMProduct instances.

getFeaturedProducts

public array getFeaturedProducts(int categoryId, int max, boolean includeChildren, int languageId)

Get random featured products.

Parameters:
categoryId - Optional category id to narrow down results; default is null for all.
max - The maximum number of results; default is 0 for all.
includeChildren - Optional flag to include child categories in the search; default is false.
languageId - Optional language id; default is null for session language.
Returns:
A list of ZMProduct instances.

getNewProducts

public array getNewProducts(int categoryId, int max, int timeLimit, int languageId)

Get random new products.

Parameters:
categoryId - Optional category id to narrow down results; default is null for all.
max - The maximum number of results; default is 0 for all.
timeLimit - Optional time limit in days (or first of month for using 1null to use the setting 'maxNewProducts'.
languageId - Optional language id; default is null for session language.
Returns:
A list of ZMProduct instances.

getProductForId

public ZMProduct getProductForId(int productId, int languageId)

Get a product for the given product id.

Parameters:
productId - The product id.
languageId - Optional language id; default is null for session language.
Returns:
The product or null.

getProductForModel

public ZMProduct getProductForModel(string model, int languageId)

Get a product for the given model name.

Parameters:
model - The model name.
languageId - Optional language id; default is null for session language.
Returns:
The product or null.

getProductIds

private array getProductIds(string sql, array args, mixed tables)

Execute the given SQL and extract the resulting product ids.

Parameters:
sql - Some SQL.
args - Optional query args; default is an empty array.
tables - Optional list of mapping table(s); default is TABLE_PRODUCTS.
Returns:
A list of product ids.

getProductIdsForCategoryId

public array getProductIdsForCategoryId(int categoryId, boolean active, boolean includeChildren, int languageId)

Get list of all active product ids for a given category.

This is a faster version of getProductsForCategoryId(int). In addition, this will ignore language preferences.

Parameters:
categoryId - The category id.
active - If true return only active products; default is true.
includeChildren - Optional flag to include subcategories; default is false.
languageId - Optional language id; default is null for session language.
Returns:
A list of product ids.

getProductTypeSetting

public boolean getProductTypeSetting(int productId, string field, mixed keyPprefix, string keySuffix, string fieldPrefix, string fieldSuffix, string keyPrefix)

Test if a given product type option is enabled for a given product.

Parameters:
productId - The product id.
field - The option name.
keyPrefix - Optional key prefix; default is _INFO.
keySuffix - Optional key suffix; default is SHOW_.
fieldPrefix - Optional field prefix; default is _.
fieldSuffix - Optional field suffix; default is an empty string.
Returns:
true if the specified type option is enabled, false if not.

getProductsForCategoryId

public array getProductsForCategoryId(int categoryId, boolean active, int languageId)

Get all (active) products for the given category id.

Parameters:
categoryId - The category id.
active - If true return only active products; default is true.
languageId - Optional language id; default is null for session language.
Returns:
A list of ZMProduct instances.

getProductsForCategoryIdQueryDetails

protected array getProductsForCategoryIdQueryDetails(int categoryId, boolean active, int languageId)

Get all (active) products for the given category id.

Parameters:
categoryId - The category id.
active - If true return only active products; default is true.
languageId - Optional language id; default is null for session language.
Returns:
A list of ZMProduct instances.

getProductsForIds

public ZMProduct getProductsForIds(array productIds, boolean preserveOrder, int languageId)

Load a list of products.

Parameters:
productIds - A list of (int) product ids.
preserveOrder - Optional flag to return the products in the order of the given id list, rather * than using the default product sort order; default is false.
languageId - Optional language id; default is null for session language.
Returns:
The product or null.

getProductsForManufacturerId

public void getProductsForManufacturerId(mixed manufacturerId, mixed active, mixed languageId)

getProductsForSQL

public array getProductsForSQL(string sql, int languageId)

Execute the given SQL and return the resulting product.

Parameters:
sql - Some SQL.
languageId - Optional language id; default is null for session language.
Returns:
A list of ZMProduct instances.

getQueryDetails

public void getQueryDetails(mixed method, mixed args)

/


getRandomProductIds

private array getRandomProductIds(string sql, int max, array args, mixed tables)

Get some random product ids.

Parameters:
sql - Some SQL.
max - The maximum number of results; default is 0 for all.
args - Optional query args; default is an empty array.
tables - Optional list of mapping table(s); default is TABLE_PRODUCTS.
Returns:
A list of product ids.

getSpecials

public array getSpecials(int max, int languageId)

Get random products marked as specials.

Parameters:
max - The maximum number of results; default is null to use the setting maxSpecialProducts.
languageId - Optional language id; default is null for session language.
Returns:
A list of ZMProduct instances.

instance

public static void instance()

Get instance. /


isQuantityAvailable

public boolean isQuantityAvailable(int productId, int quantity)

Check if a certain quantity of a given product is available.

Parameters:
productId - The product id.
quantity - The desired quantity.
Returns:
true if the requested quantity is available, false if not.

updateProduct

public ZMProduct updateProduct(ZMProduct product)

Update an existing product.

NOTE: Currently only the products table is updated!

Parameters:
product - The product.
Returns:
The updated product.

updateViewCount

public void updateViewCount(int productId, int languageId)

Update the view count for a product.

Parameters:
productId - The product id.
languageId - Optional language id; default is null for session language.

ZenMagick 0.9.6