Answer the question
In order to leave comments, you need to log in
How would you organize the synchronization of an external database with OpenCart?
There is an application with its own database. The other server has OpenCart 2.0.
Regularly (for example, once an hour) you need to create products that are in the first application, but are not available in OpenCart, as well as do a partial update of existing ones (for example, only the price).
How would you best implement this process? In terms of maximum simplicity on the part of OpenCart. We believe that the application is not particularly limited by anything, and OpenCart is located on a shared hosting (not necessary, but as an option)
What pitfalls can there be?
UPD :
I will clarify that it is not difficult to make any changes from the side of the application with the main base. REST is already in principle, adding a time field is not a problem. Dump to do - too.
The main question is how best to proceed, with the least intervention in Opencart.
For example, it would be cool if there was a reference to a method like:
Product->create(array('name' => $json['name'], 'description' => $json['description']));
Product->getByName($json['name'])->update(array('price' => $json['price']));
Answer the question
In order to leave comments, you need to log in
Depends on the number of goods. If there are not very many of them, then you can simply update the crown.
If there are a lot of goods, then you need to look for other ways - for example, update in parts.
How often does the application change the data that needs to be uploaded to the site?
Well, because Since Opencart does not have a normal api, it will be necessary to write some layer that will search / update / add products. There are models there, of course, but it was extremely inconvenient for me to work with them when writing a module for importing goods - it was too inconvenient to submit data there.
var 1: where the database is - make a REST service for products
var 2: in the database, specify the time of creation / editing of the product, and if synchronization is necessary - dump the products created / updated after the last synchronization.
var 3: allow read access to the database from opencart.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question