Code to Activate or Deactivate a Product
Normally, catalog data is visible to users as soon as it is placed in the Product Catalog System. It is possible to activate or deactivate a product in a catalog, that is to make it visible or hide it from users, by adding an additional property to that product, and then filtering on that property.
Use the following steps to implement this scenario:
- Define a new property of type number and call it IsActive. Set the AssignToAll attribute to True and the DisplayOnSite attribute to False. Set the default value to either 0 (not available) or 1 (available).
- When creating or editing products, a value can be specified for this property, either 0 (not available) or 1 (available).
- Filter any recordsets of products, such as those returned from the Category.Products, Category.Search, CatalogManager.Query, CatalogManager.FreeTextSearch, CatalogManager.Search, ProductCatalog.GuaranteedSpecificationSearch, or ProductCatalog.PerformSpecificationSearch methods by specifying an ActiveX Data Objects (ADO) filter on the recordset as "IsActive=1".
For example, wherever you have code similar to the following:
rsProducts = oCatalog.GetCategory(strCategoryName).Products
You need to follow it with:
rsProducts.filter = "IsActive=1"
- Caching of HTML can prevent products from appearing on the Web site until the cache is flushed.
All rights reserved.