Jump to content

Where we can put database Update code for stock quantity.


Recommended Posts

We have two prestashop websites.For example RetailWebsite.com and WholesaleWebsite.com. 

But we maintain one stock.It means that,somebody buy some merchandise in Retail website,So 

We need to update stock in wholesale as well.Both websites database sit on same sever.Simply We need to synchronize two databases every time update one database.(retail_db and wholesale_db)

 

I know we need to update ps_stock_available table in wholesale database when someone buy from retail.

Where are we going to put update code.I think we need to put update code in two places which are in back office and someone buy merchandise in shopping cart.

 

Can someone please explain step by step process of updating database.I have basic knowledge of PHP OOP and MySQL as well.Also I know basics of MVC architecture.I'm just confused Please help..

 

Thanks

Rainbow Station

 

Link to comment
Share on other sites

There are probably a few ways to accomplish this, but here are 2

 

1) You could create a module that 'listens' for new orders (register the actionValidateOrder hook).  Then each time there is a new order, the module would iterate through each product in that order, and then it would connect to the other store's database and update the stock for that other store

 

2) Instead of creating a module, you could edit or override the PaymentModule class, validateOrder function.  This is the function that creates new Orders in prestashop, and is also the function that executes that actionValidateOrder hook.  So instead of creating a module, you just edit this function, and perform the same database update that I described above.

Link to comment
Share on other sites

×
×
  • Create New...