Problem: The problem is when product is associated with two categories it is always fetching from primary parent category .
Example :
when product associated with two categories A and category B .It always fetch from category A even though we request for category B product .
If you don't have much knowledge on Commerce server API then get from knowledge from here.....
Runtime Commerce Server APIs (those that are used to retrieve info for use in a e-commerce website)
* ProductCatalog: Getting products from a catalog along with its child products
* CatalogContext.GetCatalogs: Getting a set of catalogs from the current context
* CatalogContext.GetCategory: Getting the details of a category including child categories
* CatalogContext.GetProduct: Getting the details of a product and product family including the variants
* CatalogSearch: Searching the catalog with the basic properties specified
Here is the code for Fetching product based on product id and Category
/// <summary>
/// Method:GetProduct
/// Description: This method is used to get the Product Information based on productId and CategoryName .
/// </summary>
/// <returns>datatable</returns>
public static DataTable GetProductByCategory(string currentCatalog, string categoryName, string productId, string language)
{
ProductCatalog virtualCatalog = CommerceContext.Current.CatalogSystem.GetCatalog(currentCatalog);
Category virtualCatalogCategory = virtualCatalog.GetCategory(categoryName);
DataSet dsProducts = virtualCatalogCategory.GetProducts();
DataView dvFilteredProducts = dsProducts.Tables[0].DefaultView;
dvFilteredProducts.RowFilter = "ProductId='" + productId + "'";
return dvFilteredProducts.ToTable();
}
What is the best way to use cs API
ReplyDeleteweb service or class library .Can u
explain me .I don't know which is better .If you know please explain
it .Thank you ...
Web Service is the best way .Distributed application always improves the performance.Mail me if you need any more clarification on it .
ReplyDelete