OpenCart

Upload and download products from OpenCart

OpenCart Connector installation and configuration

In this article, we will describe how you can install and configure the Wise2Sync connector extension for OpenCart. If you have not received the extension file - contact us by email: support@wise2sync.com.

Extension works and is tested on OpenCart version 3 together with PHP 7.1. But it could also work with other versions as well. Always test first on staging environment before moving this extension LIVE.

Requirements
Installation
  1. Upload contents of "public_hml" to location, where OC is installed
  2. Login to your ADMIN account and go to Extensions - Extensions - Modules - Wise2Sync Importer and click "Install"
  3. Enter configuration panel by clicking "Edit" on newly created extension

That's it - extension is installed.

Profile configuration

For security reasons, all profiles are disabled. To set up Profile #1, you need to do the following:

OpenCart import settings

If needed, repeat the following for Profile #2. More advanced configuration can be done in the code.

How import / update works?

OC product attribute "model" is used as a key, to identify whether product exists or not. If you change product "model" value in OC, then relation between Wise2Sync and that product will be lost. Most likely, a new product will be created automatically.

All products, that come from Wise2Sync will get a prefix (default is 'wsx-') to the product "model"
attribute in OC.

Create mode:

  1. System downloads the CSV file
  2. Checks if required attributes are present and converts it to Array
  3. Removes products from Array, that are already present in the DB (uses "model" DB field)
  4. Creates new Manufacturers (if they do not exist)
  5. Creates product and download images

By default, only 50 new products are created at a time. You can change this parameter in the code (see admin\model\extension\Wise2Sync\wsimporter.php constant CREATE_NEW_PRODUCTS_BATCH_SIZE).

Update mode:

  1. Downloads CSV, converts it to Array etc.
  2. Splits products in two groups: the ones that need an update, and others, that are missing from CSV
  3. Updates needed products: sets price, quantity and stock_status_id.
Running import profile manually

After profiles are enabled and configured, we can try running. After you logged in to your SSH, navigate to where your OC is installed.

Run the command:

php cli/index.php --path=/path/to/your/oc_store --context=admin --cmd=run:class --name=WisexmlClass --profile=1

Right a way an output would be put to screen. Something similar like:

Starting profile execution...
00:11:37 - Starting download of file.. -
00:11:37 - CSV File downloaded: vendor/Wise2Sync/wise_source_2019-08-16-01-11-37.csv -
00:11:37 - Starting CSV file parser and import... -
00:11:37 - Total of 884 rows found in CSV with attribute OC_SKU or SKU. -
00:11:47 - Finished successfully. New products created: 50. Exiting... -

These output messages are also accessible in OC "ADMIN" panel. On your left menu, navigate to Wise2Sync - Sync Results:

OpenCart import / update results

Once you are done testing and configuring - you can set up the CRON task to run the commands automatically for you.

Tips & Tricks

Sample CRON for CREATE mode could look like this (16 times at night):

*/15 1-4 * * * /usr/bin/php /path/to/oc/installation/cli/index.php --path=/path/to/oc/installation/ --context=admin --cmd=run:class --name=WisexmlClass --profile=1 >/dev/null 2>&1

Sample CRON for UPDATE mode could look like this:

10 5-24 * * * /usr/bin/php /path/to/oc/installation/cli/index.php --path=/path/to/oc/installation/ --context=admin --cmd=run:class --name=WisexmlClass --profile=2 >/dev/null 2>&1

 

Wise2Sync export profile configuration for OpenCart

This part is done in you account on https://app.wise2sync.com

OpenCart connector imports CSV file generated by Wise2Sync. After you do all attribute, categories etc. mapping, you can set up and export profile which generates a CSV file.

They key step for configuration is the export template (see "Template" tab when you open export profile in Wise2Sync app). There are some required columns, that need to be in the CSV:

You can add more columns (attributes) - correspondingly OC extension code will have to be modified to import those values.