KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: michaelwechner on December 22, 2010, 03:32:26 pm

Title: Assign product to multiple stores via the SOAP interface
Post by: michaelwechner on December 22, 2010, 03:32:26 pm
Hi

We are using the multi-store with a single DB with shared products

If one creates a product, then one can assign this product to multiple stores within konakart admin (top right tab called something like "Shops/Stores").

I would like to do this via the SOAP API, hence I thought one can do this using

http://www.konakart.com/javadoc/admin/com/konakartadmin/appif/KKAdminIf.html

somehow, but I cannot really find the methods/classes to do this for a specific product ID  and specific store ID.

Any pointers are very welcome

Thanks

Michael
Title: Re: Assign product to multiple stores via the SOAP interface
Post by: julie on December 23, 2010, 10:45:36 am
You should use the Admin API calls:

getProductsToStores()
insertProductsToStores()
removeProductsToStores()
Title: Re: Assign product to multiple stores via the SOAP interface
Post by: michaelwechner on December 23, 2010, 12:26:46 pm
Hi Julie

Thanks very much for these pointers. I will give

http://www.konakart.com/javadoc/admin/com/konakartadmin/appif/KKAdminIf.html#insertProductsToStores%28java.lang.String,%20com.konakartadmin.app.AdminProductToStore[]%29

a try shortly and keep you posted on my progress.

Thanks and have a merry Xmas

Michael
Title: Re: Assign product to multiple stores via the SOAP interface
Post by: michaelwechner on January 05, 2011, 01:47:27 pm
Hi

After many trials and errors we are patching now the database directly with something like

        dispatchOrder(OrderIf order) {
            String storeId = "my-store"; // This should be retrieved from the DB lookup above

            BasePeer.executeStatement("update orders set store_id='" + storeId + "' where orders_id=" + order.getId());

            BasePeer.executeStatement("update orders_products set store_id='" + storeId + "' where orders_id=" + order.getId());

            BasePeer.executeStatement("update orders_products_attributes set store_id='" + storeId + "' where orders_id=" + order.getId());

            BasePeer.executeStatement("update orders_status_history set store_id='" + storeId + "' where orders_id=" + order.getId());

            BasePeer.executeStatement("update orders_total set store_id='" + storeId + "' where orders_id=" + order.getId());
        }

and this works :-)

Nevertheless I think it would be nice to improve KonaKart that something like this could be done via the SOAP API ;-)

Thanks

Michael
Title: Re: Assign product to multiple stores via the SOAP interface
Post by: julie on January 05, 2011, 01:55:50 pm
The admin app uses the APIs so if you can do it through the admin app you can also do it through the APIs using the API calls that I posted.

Looking at your SQL it seems that you are assigning an order to a store and not a product, which is the subject of the thread.
Title: Re: Assign product to multiple stores via the SOAP interface
Post by: michaelwechner on January 05, 2011, 02:11:15 pm
Hi Julie

The reason behind the products were the orders (my bad that I didn't make that clear from the beginning).

Just to explain: In order to create orders for different stores based on different customer ZIP codes I understood
that the requirements are that the products are all shared, are all assigned to each store and are assigned to a category for each store, because otherwise the order creation for a specific store didn't work, but rather generated a NullPointerException.

HTH

Michael