Each KonaKart product object has 4 price fields that can be used to store 4 different prices. For example, these may be retail price, wholesale price, MRP, employee price etc.
The prices may be stored just for reporting purposes since whenever a product is added to an Order and an OrderProduct object is created which becomes an attribute of the Order object, this OrderProduct contains all of the product prices. This means that whenever documentation is generated from the order, you can show customers information such as the discount from the MRP etc.
The prices may also be used to display different prices to different customers based on what customer group they belong to.
In order to have an unlimited number of prices, they may be stored in a separate database table and referenced by a catalog id. The database table is called kk_product_prices. In order to pick up the external prices, the Application Engine must be configured with the correct catalog id. The catalog id can be calculated in a number of ways and is application specific. For example, it may depend on the country that the customer is accessing from, or the URL or the type of customer etc. One way of configuring the application engine 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 UseExternalPrice attribute must be set to true. Note that when using the application API directly, this functionality is available on all of the 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_product_prices table may be loaded in various ways:
Using the Generate Catalog Prices panel of the Admin App (see the panel online help) or programmatically using the createCatalogPricesFromRules() Admin App API call which provides the same functionality as the panel. This API call generates product prices based on rules at the category level. Before generating the prices you have to insert a number of rules for categories using the addCatalogRules() API call. For each category and its sub categories you can define whether to include or exclude products. When a product is excluded, the product will not be visible on the storefront when that catalog id is selected. When a category is included you can add a calculation to the rule to provide a percentage price adjustment (up or down) or a fixed price for all products in the category. The rules are hierarchical, which means that if a category is not assigned a rule, it inherits the rule of its parent or grandparent etc.
In order to add exceptions at the product level, you must add the product to an invisible category to which you have added an exception rule. For example, you could have invisible categories for 20%, 30%, 40% discounts etc. If a product is in multiple categories, it will always pick up the rules from the invisible category assuming one of the categories is invisible. If a product is in multiple visible categories with different rules, the algorithm doesn't guarantee which rule will be used.
Using the Admin App insertProductWithOptions() or editProductWithOptions() API calls . The AdminProductMgrOptions object must be set with the correct catalogId and configured to use external prices. When the call is made, the product and product attribute prices (or variant prices if enabled) are written to the kk_product_prices table rather than to the standard product tables.
Directly using the appropriate database tools. This may be the most convenient way if the prices already exist in the database in other tables.
Once the product prices have been generated or inserted, the Admin App may also be used to maintain the external product prices for individual products. 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 prices, attribute prices (or variant prices, if enabled) and tier prices are all written to the kk_product_prices table rather than to the standard tables. When inserting a product, the prices are written both to the kk_product_prices table as well as the standard tables.
Note that if a catalog is defined but the product does not have entries in the kk_product_prices table, then it will not be displayed in the Products Panel after a search. In order to add the prices to the kk_product_prices table you must take the following steps:
Select "No Catalog" from the catalog drop list.
Click the Edit button for the selected product.
Modify the prices for that product.
Select the catalog from the drop list.
Click the Save button to save the prices in the kk_product_prices table for the chosen catalog.
Note that the API calls using the kk_product_prices table are only available when either the Business or Enterprise Editions are installed.