ZenMagick 0.9.1


org.zenmagick.service.ZMProducts

Class ZMProducts

ZMObject
|
+--ZMProducts

public class ZMProducts
extends ZMObject

Product access.

Author:
mano
Version:
$Id: ZMProducts.php 1132 2008-05-27 02:50:57Z DerManoMann $

Constructor Summary

ZMProducts()

Create new instance.

Method Summary
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.

array

getProductIdsForCategoryId(int categoryId, boolean active, 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

getProducts(boolean active, int languageId)

Get all products.

array

getProductsForCategoryId(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.

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
backtrace, create, log, singleton

Constructor Detail

ZMProducts

public ZMProducts()

Create new instance. /


Method Detail

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.

getProductIdsForCategoryId

public array getProductIdsForCategoryId(int categoryId, boolean active, 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.
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.

getProducts

public array getProducts(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.

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.

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.

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 not all properties are supported!

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.1