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

Accessing store2 data using konakart api

Started by Raja Shekhar, January 15, 2016, 02:56:52 pm

Previous topic - Next topic

Raja Shekhar

Hi all,

     I am using konakart 8 Enterprise edition. I installed in multistore shared data base mode with only shared customers. I am using the following code to access


                EngineConfigIf eng= new EngineConfig();
      eng.setMode(2);
      eng.setStoreId("store1");
             eng.setCustomersShared(true);
      eng.setProductsShared(true);
      eng.setCategoriesShared(true);
      
      try {
         KKEngIf engine = new KKWSEng(eng);
         engine.setEndpoint("http://localhost:8780/konakart/services/KKWebServiceEng");
                        Category[] categories = kkEng.getCategoryTree(1, true);
         System.out.println(categories);
                        ---------------------------------------
                        --------------------------------------

When I am using store as store1, Iam getting the categories, but when i set store value as store2, I am getting the null.


NOTE: When i am trying to retrieve customers(shared), I am able to access them using both store1 and store2 

Please help me in resolving this issue.



Raja Shekhar

Quote from: Raja Shekhar on January 15, 2016, 02:56:52 pm
Hi all,

     I am using konakart 8 Enterprise edition. I installed in multistore shared data base mode with only shared customers. I am using the following code to access


                EngineConfigIf eng= new EngineConfig();
      eng.setMode(2);
      eng.setStoreId("store1");
             eng.setCustomersShared(true);
      eng.setProductsShared(false);
      eng.setCategoriesShared(false);
      
      try {
         KKEngIf engine = new KKWSEng(eng);
         engine.setEndpoint("http://localhost:8780/konakart/services/KKWebServiceEng");
                        Category[] categories = kkEng.getCategoryTree(1, true);
         System.out.println(categories);
                        ---------------------------------------
                        --------------------------------------

When I am using store as store1, Iam getting the categories, but when i set store value as store2, I am getting the null.


NOTE: When i am trying to retrieve customers(shared), I am able to access them using both store1 and store2 

Please help me in resolving this issue.

Raja Shekhar

while framing the question i mistakenly placed  productsShared and categoriesShared to true, They are false in my case , I updated the question in quote

Raja Shekhar

The solution for the above issue is:

The languageId of english is 1 for store1 and 5 for store2.

so we need to call CategoryIf[] categories = engine.getCategoryTree(5, true); to access store2 categories/products.
we can also use CategoryIf[] categories = engine.getCategoryTree(-1, true); to access store2 with default language.

Brian

I would recommend that you use the APIs to look up the language ids rather than hard-code them.

eg.  You could use:

getLanguagePerCode

LanguageIf getLanguagePerCode(java.lang.String code)
                              throws com.konakart.app.KKException
Retrieves the language object referenced by the two letter code (i.e. en, de, es)
Parameters:
code - The two letter language code such as en, de, es etc.
Returns:
Returns a language object
Throws:
com.konakart.app.KKException