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:

  • General Settings - Status: Enabled
  • Profile #1 - Profile Status: Enabled
  • Profile #1 - API key: copy your generated key from https://app.wise2sync.com/ in "Access tokens" section
  • Profile #2 - Profile ID: see https://app.wise2sync.com/ "Export Profiles" section
  • Import mode: Update existing products OR Create new product.

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
  • Make sure you have enough memory and server resources - syncing products requires resources
  • At the beginning, limit amount of SKUs Wise2Sync generates. Do not start with 20k products. Use product filtering by manufacturer, price or similar.
  • Always test things on any local copy of your store.
  • Move "cli" folder out of publicly accessible directory for security reasons.
  • Make Wise2Sync generate oc_sku attribute with some supplier identifier. We recommend a pattern like supplier_code-supplier_sku - this will ensure SKU is always the same.
  • Most of the import logic is done in WisexmlClass.php and wsimporter.php files - modify them if you need so.
  • Wise2Sync generated CSV file can also be accessed via URL: https://app.wise2sync.com/api/exporters/[PROFILE_ID]/results/latest?access_token=[API_KEY]. Read more here about downloading products and images manually.
  • Use one import Profile in OC for products update and another for creating products. It is recommended to update price/quantity during the day, and create new products at night.

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

 


Revision #6
Created Thu, Jul 23, 2020 8:50 AM by Liudas
Updated Sun, Mar 7, 2021 6:27 PM