Jump to content

Connection to external DB


Recommended Posts

Hello!

As i am new to prestashop i hope i am at the right section.

A client asked if he can connect his prestashop website with central database of a company.

He wants his products to be updated automatically (prices, description etc.) when the "mother" company makes changes to the products.

Or if the "mother" company exports files from the database, how they can be used for an update of the local store.

 

Thank you

Link to comment
Share on other sites

One common way of interacting with other sites is the "mother" site to export the data regularly as XML, JSON or CSV and your site to access the specific link via cron job and make the respective alterations.

If there is no such option, there is another (overkill) way of web scraping. This way you can get any information on a website that is available publicly (such as image, product name, product price etc). Not recommended, but keep it in mind, in case there is not an alternative.

Link to comment
Share on other sites

  • 11 months later...
On 9/11/2018 at 9:28 AM, tapanda.gr said:

One common way of interacting with other sites is the "mother" site to export the data regularly as XML, JSON or CSV and your site to access the specific link via cron job and make the respective alterations.

Hi

Could you please tell me how to do this via Cron Jobs. My supplier gives me the information via JSON through their API which looks like this,

$goods_sn = 'DDFF0001'; //单字符串 //$goods_sn = 'DDFF0001,DDFF0002';//多字符串 //$goods_sn = array('DDFF0001','DDFF0002'); //数组 $post_data = array( 'token' => 'your access token', 'goods_sn' => json_encode($goods_sn), 'start_date' => '2016-11-11 00:00:00', 'end_date' => '2016-11-11 23:59:59', ); $curl = curl_init($api_url); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data); $result = curl_exec($curl); //返回结果 curl_close($curl);

but I want to know firstly how do I use this code, and where do I put it to get that information from their API, and then secondly how to put it all together, so that I can update my store's stock via Cron Jobs.

Please let me know.

Thank You 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...