• Welcome to KonaKart Community Forum. Please login or sign up.
 

How to filter products by multiple categories.

Started by ckool, February 18, 2008, 01:55:05 pm

Previous topic - Next topic

ckool

Hi, it's the first time I'm dealing with the konakart api and I'm experiencing some problems.

I'm trying to get a list of products filtered by price, manufacturer and categories. What I do is:
- Populate the fields of a ProductSearchIf (priceFrom, priceTo, manufacturer and one category).
- Pass the object to a ProductMgr and do the search. (searchForProducts)
- Filter the other categories with filterCurrentProdsByCategory(int categoryId)

The problem is that the search it's ok (returns n results) but the filterCurrentProdsByCategory always return 0 products.

I want also to get all the categories of a product but all i have using the getCategoryId it's the Id of one of the categories not all of them. (I.e. I have the categories "dress", "girl", "Laura", "Dark trend" and I only get "dress").

Hope you can help me. Thanks.


ryan

Quote
I'm trying to get a list of products filtered by price, manufacturer and categories. What I do is:
- Populate the fields of a ProductSearchIf (priceFrom, priceTo, manufacturer and one category).
- Pass the object to a ProductMgr and do the search. (searchForProducts)
- Filter the other categories with filterCurrentProdsByCategory(int categoryId)


I don't understand what you are trying to do by the last API call Filter the other categories with filterCurrentProdsByCategory(int categoryId) ? Normally that is used in the application when you search for products based on a manufacturer and then want to narrow them down based on a category. i.e. You search for all Sony products and then narrow down your search by choosing one of the categories applicable for Sony. i.e. TVs.

Quote
I want also to get all the categories of a product but all i have using the getCategoryId it's the Id of one of the categories not all of them. (I.e. I have the categories "dress", "girl", "Laura", "Dark trend" and I only get "dress").

The application API doesn't return an array of categories for a product. I'm curious to know why you need that functionality since normally you get to a product from one of its categories rather than the other way around ? If you need this functionality you must use the Admin API. There is a method called public AdminProduct getProduct(int productId) which will return a product with an array of AdminCategories.

-Ryan

ckool

Thanks for the quick answer, I didin't know about the Admin API.

I'm trying to do that because a product in my shop has N categories which are not related to the others.
(I.E.
Clothes
  - Dresses
  - Pants
  - ...
Genre
  - Boy
  - Girl
  - ...
Contestant
  - John
  - Mary
  - ...
Trend
  - Dark
  - New Age
  - ....
.....
- ....

In the shop the people can filter by the combinations of any of these filters (and anothers). I.e. I can filter by Genre and trend, by clothes and contestant, by clothes, trend and genre... and so on.

The client API search only allows me to filter for one category so the others must be done it after the search "manually". That was why I was using filterCurrentProdsByCategory (in the wrong way, for what I see). And that was why I need all the categories of a Product.

Thanks again. bye!