KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: ncister on October 17, 2007, 10:06:20 am

Title: Real time integration with external ERP ...
Post by: ncister on October 17, 2007, 10:06:20 am
Hi,
I'm valuating the possibility to integrate (at real time, without asynchronous updates or import/export processes ....) Konakart with an existing ERP solution.
For this issue I need to customize (at least) two Konakart sections using additional MySql tables:
1) Pricing policies
2) Checkout phase
3) Order state monitoring
My scenario could be:
- A lot of additional ERP tables are added to osCommerce 2.2 compatible database, so ERP can normally work using your data
- ERP manage its product / prices tables
- Konakart uses its product table for search functions
- Konakart manage orders using an alternative price policy, based on some additional ERP tables
- Konakart manage checkout phase, modified to transfer data to ERP tables (too)
- ERP manage other processes (delivery, billing, etc ...)
- Konakart allow to monitor the order state using its tables + ERP tables

What are your suggestions about this purpose ?
Are the source modules available to modify these process ?

Very Thanks.
Nicola.
Title: Re: Real time integration with external ERP ...
Post by: paolo on October 17, 2007, 10:49:13 am
Hi Nicola,

That's an interesting question. There are some features of KonaKart that help with integration (other than the obvious API). These are:


To answer some of your more specific questions:

Quote
- Konakart manage orders using an alternative price policy, based on some additional ERP tables

At the moment KonaKart uses it's own rules (promotion subsystem) which can be customized by introducing new OrderTotal Modules or Promotion modules. We provide source code examples of these modules. They are instantiated and called by KonaKart when the order is created during the checkout process. When called, they have access to the order object containing all of the product information and so you could build a custom one that figures out the total price based on your rules using your ERP tables.

Quote
- Konakart manage checkout phase, modified to transfer data to ERP tables (too)

When the order is saved or it's state is changed you can implement your own logic following these instructions http://www.konakart.com/configurationfaq.php#how_can_i_make_something_happen_when_an (http://www.konakart.com/configurationfaq.php#how_can_i_make_something_happen_when_an) .

Quote
- Konakart allow to monitor the order state using its tables + ERP tables

KonaKart allows you to monitor the state of an order at any time using the Admin App or the API. In order for the state to be accurate, it would have to be the responsibility of the ERP system to update the state for the processes that it controls.

Hope this helps,

Paolo
Title: Re: Real time integration with external ERP ...
Post by: ncister on October 17, 2007, 11:01:24 am
Hi Paolo, and thanks for your replay !

QuoteAt the moment KonaKart uses it's own rules (promotion subsystem) which can be customized by introducing new OrderTotal Modules or Promotion modules. We provide source code examples of these modules. They are instantiated and called by KonaKart when the order is created during the checkout process. When called, they have access to the order object containing all of the product information and so you could build a custom one that figures out the total price based on your rules using your ERP tables.

Only a precisation:
I need to display "my" price when the single product is displayed, in any Form (for example after a search ...) not at the end of order  ...

Thanks.
Nicola.
Title: Re: Real time integration with external ERP ...
Post by: paolo on October 17, 2007, 11:21:19 am
QuoteOnly a precisation:
I need to display "my" price when the single product is displayed, in any Form (for example after a search ...) not at the end of order  ...


The way that price works at the moment is that we pick up the product price or the special price (if it exists) and then tax is added to the price if applicable to the user that is logged in.

I assume that you want to add more rules other than tax, based on the logged in user ? If this is the case, my suggestion is to add logic to the relevant Action classes to post-process the prices before the data is displayed. Bear in mind that you must do the same post processing in the OrderTotal module and that some of the sorting etc. on the UI may not work properly if you alter the prices in a non uniform way. i.e. The data you see on the UI is sorted using database sorts, so if you modify the prices before displaying the products and the modificaction is not a simple percentage discount, then you may have to re-order the data before display.

-Paolo

Title: Re: Real time integration with external ERP ...
Post by: David on November 22, 2007, 04:01:03 pm
Hi,

i'm doing something like ncister, and I need to add more rules based on the logged in user.

If I don't understand you bad, you suggest to add the class EditCartForm.java and modify the prices here but I don't know how can I do that.

What I'm doing now is one java with a method that calculates the price from my client and I'm calling it from the jsp's. I don't know if that is a good idea, but it works  ;D

My problem now are the prices on the EditCartBody.jsp, I can't get the custom1 field from the product and I need it to calculate my price. ¿Any idea?

Regards

David
Title: Re: Real time integration with external ERP ...
Post by: paolo on November 22, 2007, 04:30:42 pm
Quote
My problem now are the prices on the EditCartBody.jsp, I can't get the custom1 field from the product and I need it to calculate my price. ¿Any idea?


I don't understand why you can't get it. Do you get an error ? Do you get null ? What does your code look like ?

-Paolo
Title: Re: Real time integration with external ERP ...
Post by: David on November 22, 2007, 04:52:15 pm
Thank you, I was posting my own answer right now.

I finally got it, the problem was because I don't know anything about jsp and struts. I finally did something very complicated to do something very easy, but again, it works:

This is my code on EditCartBody, just before printing the price. Final price with my own discounts is "precioFinal"

                                 <nested:link page="/SelectProd.do" paramId="prodId" paramName="item" paramProperty="prodId">
                                    
                                    <%
                                    kkEng.getBasketMgr().getBasketItemsPerCustomer();

                                    String idClienteElastic = currentCustomer.getCustom1();
                                    
                                    
                                    int j=0;
                                    boolean encontrado = false;
                                    while(j < currentCustomer.getBasketItems().length && !encontrado){
                                       System.out.println("j: " + j);
                                       if(currentCustomer.getBasketItems()[j].getProductId() == item.getProdId())
                                          encontrado = true;
                                       j++;
                                    }
                                    
                                    if(encontrado = true){
                                       String idArticuloElastic = currentCustomer.getBasketItems()[j-1].getProduct().getCustom1();
                                       
                                       int unidades = currentCustomer.getBasketItems()[j-1].getQuantity();
                                       String precioFinal = precio.getPrecioConFormato(idArticuloElastic, idClienteElastic, unidades);
                                    }
                                    %>
                                    
                                 </nested:link>

I supose that there is a simple way to get that field, but I couldn't find it

Anywhere thanks for all paolo
Title: Re: Real time integration with external ERP ...
Post by: paolo on November 22, 2007, 05:15:50 pm
Hi David,

If it works that is great !

Another way of doing it could have been for you modify EditCartForm to accept a list of MyCartItem objects where MyCartItem extends CartItem adding the extra attribute(s) that you need. Then in ShowCartItemsAction.java you would have needed to populate MyCartItem in a similar way that it works at the moment with CartItem.

Regards,

Paolo

Title: Re: Real time integration with external ERP ...
Post by: David on November 22, 2007, 05:48:05 pm
thanks for your answer.

I know I'm doing a bit mess changing all this things directly on the jsp, but actually I don't have much time to learn and think on the best way to do this.

I'm thinking that I'm going to start making things right and I'll do what you say, at least I'll try that ;)

Regards

David