V
V
Viktor Vsk2015-02-01 20:19:55
PHP
Viktor Vsk, 2015-02-01 20:19:55

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']));

But, as I understand it, it just won't work.
Also, there are some import plugins - but they need to be configured. Everything is different. There are paid ones, there are free ones.
Also, taking into account the fact that you need to synchronize constantly and as often as possible, the question arises, from which side should the request go? From Opencart or from the application? Should opencart try to get the data, or should the database try to import it?
The best solution is one that requires less action on OpenCart.
There was a suggestion to upload JSON via FTP, and opencart will add products from it via cron (update prices)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Kirill Arutyunov, 2015-02-01
@arutyunov

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.

I
index0h, 2015-02-01
@index0h

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.

U
ustasby, 2015-02-28
@ustasby

A separate script that is launched by the crown and implements a record in the database, there is nothing particularly complicated there, the number of goods does not matter, and the load can be distributed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question