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

Search for products in the KKAdmin

Started by Alexandra, August 25, 2015, 10:15:29 am

Previous topic - Next topic

Alexandra

Hello,

I am a newby in the Konakart world, and I would need some help.
I am trying to search for products on the Admin part, and I can not get any of my Products. Only when I look for the inactive products, a get results.

I have a product, which has a custom property "test", but with the following code I can't find it.
                        AdminDataDescriptor descriptor = new AdminDataDescriptor();
         AdminProductSearch adminProductSearch = new AdminProductSearch();
         
         //adminProductSearch.setSearchText("Pluto");
         adminProductSearch.setCategoryId(-100);
         adminProductSearch.setWhereToSearch(-100);
         adminProductSearch.setManufacturerId(-100);
         adminProductSearch.setPromotionId(-100);
         adminProductSearch.setProductType(-100);

         descriptor.setOffset(0);
         descriptor.setLimit(100);
         descriptor.setShowInvisible(true);
         descriptor.setCustom1("test");
         AdminProducts adminProducts = port.searchForProducts(sessionId, descriptor, adminProductSearch, -1);

On the other side, when I try the same thing directly on the store like this:
                        DataDescriptor dataDesc = new DataDescriptor();
         dataDesc.setOffset(0);
         dataDesc.setLimit(100);
         dataDesc.setShowInvisible(true);
                        dataDesc.setCustom1("test");
         

         ProductSearch prodSearch = new ProductSearch();
         //prodSearch.setSearchText("Pluto");
         prodSearch.setManufacturerId(-100); // -100 == Search all
         prodSearch.setCategoryId(-100); // -100 == Search all
         prodSearch.setSearchInSubCats(true);
         prodSearch.setSearchAllStores(false);
         prodSearch.setProductType(-1); // -1 == Not Set

         Products products = port.searchForProducts(sessionId, dataDesc,prodSearch, -1);

=> it works.

Can some one help my understand how these things work and how can I do a search on the admin page?

p.s: I also have problems searching for the name of the product. I've tried all the given examples but somehow I still don't get any products back.

Thank a lot!
Alexandra

julie

When you instantiate objects like AdminProductSearch, default values are set so that you have no constraints. You just have to add the constraints that you want. e.g. To search for pluto you just need:

AdminProductSearch adminProductSearch = new AdminProductSearch();
adminProductSearch.setSearchText("Pluto");

Alexandra

Hi Julie,

Thanks for your reply.

I've tried only with the search text, but still I get no products back.

How come it works on the store side, when I do the search on the KKWSEngIf, but on the Admin side not? From what I understood, the search on the admin side is even more powerfull, and should find even more products.

Thanks again,
Alexandra

julie

I would enable DB logging and take a look at the search query being sent to the database.

Alexandra

Thanks a lot, that really help! Enabling the logging on the DB helped me figure out what is missing.   :)

Now it works! I had to add some new parameters to the ProductSearch object.

If anyone else has this problem, in my case I've "decorated" the ProductSearch object with the following attributes:

ProductSearch prodSearch = new ProductSearch();
         prodSearch.setSearchText("Pluto");
         prodSearch.setSearchTextRule(3);// KKConstants.SEARCH_ADD_WILDCARD_BEFORE_AND_AFTER
         prodSearch.setWhereToSearch(0);
         prodSearch.setManufacturerId(-100);
         prodSearch.setCategoryId(-100);
         prodSearch.setSearchInSubCats(true);

Similar the AdminProductSearch looks like:

         AdminProductSearch adminProductSearch = new AdminProductSearch();
         adminProductSearch.setSearchText("Pluto");
         adminProductSearch.setSearchTextRule(3);
         adminProductSearch.setCategoryId(-100);
         adminProductSearch.setWhereToSearch(0);
         adminProductSearch.setManufacturerId(-100);
         adminProductSearch.setPromotionId(-100);
         adminProductSearch.setPaymentScheduleId(-100);

I hope this is helpful also for someone else.

julie

For AdminProductSearch and ProductSearch you'll see that all of those -100 etc. are defaulted so you don't need to set them. You only need to set the search text and the rule depending on whether you want an exact or wildcard search.

Alexandra

You are right! thanks again for your help! :)