Multiple Quantities for Products

Each KonaKart product object has a quantity field that can be used to store the quantity of the product in stock. There is also an availability date used to store the date that the product will become available if it is out of stock. Configurable products (i.e. red shirt, size medium) have separate quantity and available date attributes for each configuration.

As is the case for product prices, a product may be associated with multiple quantities and available dates. This quantity data is stored in a separate database table called kk_catalog_quantity and the key that determines which quantity data is actually used is the catalogId.

One way of configuring the application engine to use external quantity data is in the KKAppEngCallouts class as shown below:


/**
 * Callouts to add custom code to the KKAppEng
 */
public class KKAppEngCallouts
{
    /**
     * Called at the start of startup
     * 
     * @param eng
     */
    public void beforeStartup(KKAppEng eng)
    {
        System.out.println("Set product options for current customer");
        FetchProductOptionsIf fpo = new FetchProductOptions();
        fpo.setCatalogId("cat1");
        fpo.setUseExternalPrice(true);
        fpo.setUseExternalQuantity(true);
        eng.setFetchProdOptions(fpo);
    }

    /**
     * Called at the end of startup
     * 
     * @param eng
     */
    public void afterStartup(KKAppEng eng)
    {
    }

The catalogId must be set to the id of a valid catalog and the the UseExternalQuantity attribute must be set to true. Note that when using the API directly, this functionality is available on all of the application API calls that accept an Options object such as FetchProductOptions or AddToBasketOptions. The Options object for each API call must be configured in a similar way as shown above.

The kk_catalog_quantity table may be loaded directly using the appropriate database tools or it may be loaded and read through the Admin App API using various API calls:

When any of the above calls are made with the options object configured to use external quantities, the quantity data is written to and read from the kk_catalog_quantity table rather than the standard product tables.

The Admin App may also be used to maintain the external product quantities. The Catalog must first be defined using the Catalogs panel. Once defined, it appears in a drop list in the panel header. When selected in the drop list, all product related API calls made by the admin app attempt to use the catalog. i.e. If you edit a product, the quantities are all written to the kk_catalog_quantity table rather than to the standard tables. When inserting a product, the quantities are written both to the kk_catalog_quantity table as well as the standard tables.

Note that if a catalog is defined but the product does not have entries in the kk_catalog_quantity table, then it will not be displayed in the Products Panel after a search. In order to add the quantities to the kk_catalog_quantity table you must take the following steps:

Note that the API calls using the kk_catalog_quantity table are only available when either the Business or Enterprise Editions are installed. Also note that special price functionality is not supported when using catalog prices.