PrestaShop
Upload and download products from your PrestaShop store.
- Before you start
- Definitions
- Requirements and Installation
- Module Settings
- Import & Export Profiles
- Task Manager
- Using CLI Commands
- Troubleshooting
Before you start
We provide Wise2Sync Connector module for PrestaShop only after you signup with us. If you already have an account and do not have the module - contact us.
Before you start:
- Read minimum requirements page to make sure our module works on your PS;
- Read the PrestaShop connector module definitions section - it will be easier to use our knowledge base and understand how things work;
- Make a backup of your store before installing / using our extension. Ideally, try using it first on a testing environment to make sure it meets your needs and expectations;
- Make sure your server has enough storage space (especially if you are going to import products). Imports / exports will take faster if you have a faster server;
- If you notice a bug or have a feature request - let us know by email to support@wise2sync.com.
In short, to set up product sync between Wise2Sync App and your store, you will need make the following steps:
- Configure the export profile in app.wise2sync.com (product repricing, export filters, attribute / category mapping etc.);
- Install connector module on your PS;
- Configure the module;
- Create import / export profiles;
- Test and make adjustments to settings in Wise2Sync App or connector module if needed.
We've made our app and PS module the way that you could set up product sync yourself with no programming knowledge. However, if you do not feel confident - we have a setup service and can do this for you. Drop us an email to support@wise2sync.com to discuss this!
Definitions
API Access Token
You can get this key from your account at https://app.wise2sync.com ("API Access Tokens" item from the left side menu). Do not share it with third parties you do not trus - as this key is private and issued only to you.
CRON
Also known as cron job. It is a time-based job scheduler in Unix-like computer operating systems. Users that set up and maintain software environments use cron to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals.
Heartbeat CRON
Heartbeat is a script and acts like a scheduler - schedules and executes tasks. It does not import / export all products every time it is executed. Heartbeat command needs to be executed periodically by your server. If heartbeat is not working - no tasks are being executed.
Heartbeat Time-out
Determines the maximum duration of Heartbeat execution.
Batch
A sub-set of products to be exported / imported. For example if you are going to import 5000 products, than Heartbeat will process this task in batches of 500 (in total 10 Heartbeats to process all 5000 products).
Profile
This is where you would set up how and when you want to import / export your products. Import / export tasks are executed based on your preferences in profiles. You can have multiple profiles for import and export.
Task
Tasks are scheduled and executed by Heartbeat CRON. You can set how often import/export task needs to be executed in your Profile preferences.
Requirements and Installation
Requirements
- You need a shop with PrestaShop at least 1.7.6.9 and not higher than 8.1.7.
- Your server has to support CRON Jobs
- CLI access (not required, but highly recommended)
If you have older version than indicated above and you are interested only in product export from your shop, than contact our support for consultation - maybe we can find a solution.
All tasks (import and export) are performed from from server. Therefore your need to have possibility to execute CRON Jobs from your server. If you are not sure weather you have CRON on your server - contact your developer or hosting provider for more information.
CLI (command line interface) access is not required only if you are running a small PS shop and are going to export / import small amounts of products. Product Export or Upload is resource intensive - and it is best that these tasks are executed from CLI.
Installation
Installation is done the same way as with any other PS module. You can upload it to your store using module manager functionality or upload it directly to server with FTP.
Once you upload the module, you should see it under "Others" tab:
Thats it, you've installed the Wise2Sync Connector module. Continue to read this article about how to configure it and get started with import / export.
Setting up Heartbeat CRON
Heartbeat acts like a scheduler - schedules and executes tasks. It does not import / export all products every time it is executed.
There are two options how you may set a CRON. It might depend on your server or hosting provider. If you are not sure weather you can or how to set up CRON, consult your developer or hosting provider. Heartbeat CRON command has to be executed with a recommended frequency of 5 to 10 minutes (other intervals are also available, but might slow down / speed up task execution and might have negative affect on your general shop performance).
Option #1. Using CLI command is most safe and highly recommended. It is also faster. CRON command example:
*/5 * * * * php /path_to_prestashop/bin/console Wise2Sync:heartbeat --no-debug
If your CLI cron is working, you would see a green info box in module configuration page:
Last CLI Heartbeat was on 2021-03-06 12:39:28. That is 25 seconds ago.
Option #2. If you do not have CLI access or possibility to execute commands from the console, then you can use a HTTP based cron command. It will work if you do not have many products. It is also slower.
See your CRON Heartbeat URL in your module Configuration page (which will hold HASH as well). An example:
https://www.yourstore.com/index.php?fc=module&module=Wise2Sync&controller=heartbeat&hash={HASH}
If your HTTP Cron is working, you would see a green info box in module configuration page:
Last HTTP Heartbeat was on 2021-03-06 12:39:28. That is 25 seconds ago.
Thats it - you've installed and set up Wise2Sync Connector module. Now you can proceed with module settings.
Module Settings
Once you've installed the Connector, you can now configure it. Open module configuration page and you will see a form like this:
We've put all the explanations about what each field is meant for. Here are the most important:
Wise2Sync API Access Token
You can get this key from your account at https://app.wise2sync.com ("Access Token" item from the left side menu). Do not share it with third parties - as this key is private and issued only to you. Copy/paste this key into the module configuration field. After you save the config form, you should see a green notification message:
Wise2Sync API [200]: Your API Key is valid. License issued to [Name Surname]. Status: active.
If the access token is invalid - you will see a warning message:
Wise2Sync API [401]: The access token provided is invalid.
API Access Token can be invalid for several reasons:
- A mistype an API key (use copy/paste to avoid this);
- Your account at app.wise2sync.com is suspended/canceled.
Do not try to guess the API key. After several unsuccessful attempts, your server IP might be blocked for 1 hour for security reasons.
Product Reference Prefix
Only used for product import. All products, that will be imported from Wise2Sync will have this reference prefix. If you change this prefix after you import some products, old products will not be updated (the Wise2Sync Connector module will only update products with the prefix you set).
Using reference prefix allows you to have products on your store that are not synced with Wise2Sync.
Prefix length has to be between 2 and 10 characters long. Default value: "WSX-".
Heartbeat Time-out & Batch Size
These settings work together in combination with how often Heartbeat is executed.
As you know, Heartbeat acts like a scheduler - schedules and executes tasks in batches. It does not import/export all products every time it is executed. All tasks are executed in batches. For example, if you have 5000 products from Wise2Sync and you set the batch size to 100, then it would take ~50 Heartbeats to complete the task.
However, to prevent "very long" Heartbeats, we use the "Heartbeat Time-out" value to limit the duration. If you set the time-out value to 2 minutes, the Wise2Sync connector will stop processing the batch when it reaches those 2 minutes.
Heartbeat time-out value should not exceed Heartbeat CRON frequency. If you set your CRON to be executed every 5 minutes, the maximum value for time-out should be 5 minutes.
Batch Size depends on the speed of your server resources. If you are going to import products (especially with combinations), set this value to lower, f.e. 200. If you are going to only export product - then it can be and 500 or higher, as product export is in general faster.
Wise2Sync Connector uses the PHP Symfony framework native console mechanism to prevent executing multiple commands at the same time. Every time a server runs the Heartbeat script it checks whether there are no other instances of Heartbeat running.
Pre-defined Feature Values
Product features in PrestaShop can have Customized or Pre-defined values. If the feature value is individual per product (for example Part Number, MPN, location address, etc.) - then we recommend using those values as pre-defined.
Most often attribute labels in https://app.wise2sync.com will be imported as features. Add feature names that would use a pre-defined product value (for example: Product Type, Warranty, Color, Composition, County Of Origin etc.). Each feature per new line.
All other feature values that you do not write here will be created with "Customized values". See your attributes and attribute labels in your account at https://app.wise2sync.com to decide which of them could use a pre-defined value.
Report Email Address
Set email addresses (comma separated) to receive the report once the task becomes complete. Leave blank to disable email reporting.
Check and reimport broken images
If you notice some broken images use this feature to get them reimported during the upcoming update.
Images Index
Wise2Sync stores which images have been imported. Keeping the image index speeds up the import process - as only new images are uploaded to your store.
If you clear the images Index table, then the next time a product import task is run - it will re-upload all product images. Uploading images is resource-intensive task, therefore the task execution time will be longer.
Import & Export Profiles
Before you can start importing/exporting the products, you first need to create a profile and set some preferences.
In your PrestaShop back-end panel, navigate to Shop Parameters → Wise2Sync. Click on the Profiles tab at the top. In this article, we will explain in more detail how to set up profiles.
There are two types of profiles which are split into two grids:
- Product Import
- Product Export
Profile General Settings
Let's say are going to import products to your store. Click "New Import Profile" in the top right corner and a form will open:
Profile Active
Enable or disable this profile. Heartbeat will ignore inactive profiles and will not schedule tasks.
Name of the Profile
You can give this profile a name (f.e. Product Stock&Price update etc.). Use this for your own reference.
Profile execution Frequency
How often a Heartbeat should schedule tasks based on this Profile. If you are going to use multiple export/import profiles, make sure they have enough time between them. Heartbeat will not start new task if the previous is not finished yet.
Import Profile
If you are creating an Import Profile, you will need to set the following settings:
Product Source
Select the Product export profile from your account at https://app.wise2sync.com. If the list is empty, make sure to enter a valid API Access Token in the module configuration section and you have at least one PrestaShop-type export profile in https://app.wise2sync.com.
In the drop-down, you might see more items. Make sure you select the one with [PrestaShop Data Export] in the brackets.
Mode
There are several modes of how import can be done:
- Create New Products & Update Existing - would create products that are not in your shop. It would also update the stock & price of existing products, add images, and update combinations (slower). We recommend executing this at night.
- Create New Products & Update Only stock & price - would create products that are not in your shop. It would also update the stock & price of existing products. It is a faster option compared with the import mode mentioned above.
- Update Stock&Price - will only update the price and stock of existing products (faster). If needed, you can execute it during the day.
- Update Stock - will only update stock of the existing products. It is the fastest import mode.
Disable Missing Products
Once Heartbeat finishes processing all products, it will check if there are any products missing in the import with your reference prefix. Set this feature to YES, if you want to disable missing products (f.e. the supplier removed a product from their system or these products are not available anymore in your export profile in app.wise2sync.com). This will also set Quantity to 0 for missing combinations. If a previously missing product reappears in a subsequent import, its activity status will be updated according to the information found in the import file.
Import Limit
Set limit to how many products should be added to import queue. Leave blank or set to 0 to import all products available in app.wise2sync.com. This is useful for testing purposes, when you do not want to import all products but just certain number (limit).
Delete Missing Products
Select the time amount after which the old, not updated product will be deleted. This action will delete only Wise2Sync import products.
Export Profile
If you are creating an Export Profile, you will need to set the following settings:
Only Active
If set to yes, only products that are Active will be exported.
Product Visibility
Only products with selected visibility will be exported. The following options are:
- Everywhere
- Catalog Only
- Search Only
- Nowhere
Skip Products w/o Images
If set to yes, products that do not have any images will not be exported.
Only In Stock Products
If set to Yes, only products with Quantity > 0 will be exported.
Export Limit
Set a limit to how many products should be exported. Leave blank or set to 0 to export all products. This is useful for testing purposes when you do not want to export all products but just a fraction.
Profiles Grid
Once you've created some profiles, the profiles list will display some information. If the profile is Active, you can schedule it to be executed next time Heartbeat runs.
Task Manager
Task Manager can be reached from your PrestaShop admin: Shop Parameters → Wise2Sync. This section shows executed import/export tasks and allows to download some reports or logs.
We will explain what each column means and how you can use Task manager to identify to determine the results of import / export.
Status
Status indicates current task state. Most often the task statuses will be changed in the following order: Pending → Running → Completed. Here are the possible task statuses:
- Pending. Task is scheduled by Heartbeat and be picked up for execution when time comes (see Scheduled At column)
- Missed. Heartbeat schedule could not start the task because there was one already running.
- Killed. A task that had either status "Pending" or "Running" and was killed by a user.
- Running. Task is being executed by Heartbeat. So every heartbeat it processes a certain number of queued products based on batch size.
- Error. Heartbeat could not start a task because of a fatal error.
- Completed. Task was processed and finished.
Progress
When task is running, "Progress" column indicates how many queued products have been processed. If you hove your mouse over the Progress column, you would see a more detailed information:
- Pending. A remaining number of queued products that are not processed yet.
- Processed. Number of items already processed.
- Skipped. Number of items that were skipped (were not exported / imported / updated)
- Cancelled. If you kill a task, then Pending products will get this status.
- Error. Number of products that could not be imported/exported because of an error.
Scheduled At
Date and Time when Task is scheduled to be started.
Started At
Date and Time when task was started by Heartbeat (status changed to Running)
Finished At
Date and Time when task was finished (status changed to Completed).
Task Actions
- Delete. Deletes selected Task.
- Actions Log. Would download a text file which contains information about performed actions with the current task (updated products, batch duration, performance etc.).
- Report. Download a CSV type file with all queued products in the task. Would also show some information what data was updated or why the product was skipped.
- Kill Task. Cancel a planned or running task.
- Export File. Available on for Export Tasks. For debugging purposes, you can download a generated JSON file which will be imported to app.wise2sync.com
Using CLI Commands
If you have access to your server CLI console (usually available on VPS server), you can use multiple useful features, such as:
- Import/export all products with one command;
- Delete multiple products with specific product reference prefix;
- Start / Stop / Kill planned or running tasks etc.
CLI commands speed up the process when you are setting up new import/export. A progress bar shows the current status, estimated time remaining, memory usage, etc.
Wise2Sync:run
will be most useful when you are setting up the integration. You do not have to wait for the heartbeats to complete the task. This is faster and you can see progress in CLI window instantly.
We recommend to always add --no-debug parameter to disable warnings about missing PrestaShop translations etc.
Wise2Sync:heartbeat
You've already used this command when installing extension and setting up CRON. But in case you want to execute Heartbeat manually from your console, you can run this command:
$ php bin/console Wise2Sync:heartbeat --no-debug
Heartbeat command does not take any arguments or options.
Wise2Sync:run
There are multiple options this command takes:
Option | Example Parameter(s) | Explanation |
--id_profile |
--id_profile=5 | Runs profile (import or export) by selected profile ID. |
--kill |
no value | Kills any other running tasks before staring a new task. |
--delete |
--delete=tasks --delete=queues --delete=products |
Tasks - deletes all existing tasks ignoring their status. Queues - deletes (truncates) queue table Products - deletes all products with the reference prefix you set in module configuration section. |
You can run --help
argument see full list of options and arguments.
Below we will show you a few examples. Lets say you've configured a new product export profile and would like to run it. Your profile ID is 2.
$ php bin/console Wise2Sync:run --id_profile=3 --no-debug
[19:53:31] Loaded "All Products Export" profile with the following parameters:
+--------------+------------+
| Parameter | Value |
+--------------+------------+
| Type | Export |
| id_profile | 3 |
| skip_noimage | 0 |
| limit | 100 |
| visibility | Everywhere |
| only_active | 1 |
| in_stock | 0 |
| tax_included | 0 |
+--------------+------------+
[19:53:31] Continue with product Export? (y/n) y
[19:53:35] Creating New Task...
[19:53:36] Added 100 products to Export Queue (default: 20.00 MiB - 264 ms)
[19:53:36] Processing Queue of 100 products...
100/100 [============================] 100% 9 secs/9 secs 36.0 MiB
[OK] Export complete!
And for product import - the command would be very similar (note, that we delete any other existing tasks):
$ php bin/console Wise2Sync:run --id_profile=2 --delete=tasks --no-debug
[20:03:30] Found 1 task. Delete? (y/n) y
[20:03:32] All (1) tasks deleted successfully
[20:03:32] Loaded "Product Update #2" profile with the following parameters:
+-----------------+--------------------+
| Parameter | Value |
+-----------------+--------------------+
| Type | Import |
| id_profile | 2 |
| app_profile_id | 932 |
| mode | Update Stock&Price |
| limit | 100 |
| disable_missing | 0 |
+-----------------+--------------------+
[20:03:32] Continue with product Import? (y/n) y
[20:03:36] Creating New Task...
[20:03:37] Added 100 products to import Queue. Mode: Update Stock&Price
[20:03:37] Processing Queue of 100 products...
100/100 [============================] 100% 13 secs/13 secs 42.0 MiB
[OK] Import complete!
For security reasons we've disabled a possibility to run multiple instances of commands at the same time. You can not run two commands at the same time.
If you are confident and know what you are doing, you can set up Wise2Sync:run
command to be executed by CRON in desired intervals. Then no Heartbeat CRON is needed.
Troubleshooting
Error: Connection timed out after 120000 milliseconds
When opening module configuration page, you might bet a red warning with Wise2Sync API Error... "Connection timed out after 120000 milliseconds". This means, that when your website tried to validate the API Access Token, but did not get a reply from the app.wise2sync.com server after 12 seconds. Usually this happens when:
- You do not have CURL extension installed on your server
- Your hosting provider is blocking API calls to app.wise2sync.com
- Our servers are blocking your IP address
Possible solution: contact your hosting provide to make sure that your server can access https://app.wise2sync.com. For example, this URL https://app.wise2sync.com/api/users/check-status should return:
{"error":"access_denied","error_description":"OAuth2 authentication required"}
Slow import with big amount of products
Wise2Sync Connector module uses product reference to determine which product is which. If you have a large database of products (f.e. 50000+ products), adding Index on "reference" column could speed up import/update. This would speed up batch imports.
You can add index to "reference" column by running this SQL:
ALTER TABLE `ps_product` ADD INDEX(`reference`);
ALTER TABLE `ps_Wise2Sync_queue` ADD INDEX(`id_task`);
Please note that "ps_product" and "ps_Wise2Sync_queue" tables can be named differently in your DB.
Task is stuck at certain % and no products are being updated / imported
There could be various reasons for this. First place to look would be task actions log or your server logs. Most common problems:
- Allowed memory issue. Solution: add -d memory_limit=2048M parameter to your CRON command (2048M can be smaller or higher)
- Server ran out of disk space
- Other technical problems
Error: Allowed memory size
Your Heartbeat command returns similar error:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in ....
Most of the time this happens when Heartbeat tries to create a product and it runs out of memory. Chances are higher to get this error when not you are importing products with variations and your supplier provides high resolution images.
A solution for this would be to add extra parameter for your Heartbeat CRON command, so it would look like:
php -d memory_limit=2048M bin/console Wise2Sync:heartbeat --no-debug
Note the parameter -d memory_limit=2048M
.
HTTP Type Heartbeat (CRON) not working
If you are using HTTP type CRON, there could be multiple reasons. We first recommend checking the output but putting the CRON URL into your browser (use incognito window).
Look for the URL in your Wise2Sync module configuration page in PrestaShop. It will look similar to this:
https://domain.com/index.php?fc=module&module=Wise2Sync&controller=heartbeat&hash=XXXXXXXXXXX
This way you will "trigger" heartbeat manually. If your heartbeat was logged, then it must be the server settings. You can consult your hosting provider how to correctly set up CRON on your server.
Tip: if you have maintenance mode enabled in your PrestaShop - make sure you exclude your server IP address in Shop Parameters → General → Maintenance → Maintenance IP
Getting "500 Internal server error" (or similar) when clicking "Schedule Now" in PrestaShop import profile
Most often the cause of this error is that PHP runs out of available memory on your server. Your server error logs would show more information. But in general - the server your PrestaShop store is running should be able to process large files.
This error occurs usually when you are syncing a large number of products (for example import file is >10Mb). You might also encounter similar problems if you are using HTTP Type Heartbeat.
Possible solution #1
Use the Command Line to run profiles. Here is an example command to run the profile with included memory_limit
parameter. We highly recommend using the Command Line interface as it is quicker and more informative when setting up imports and testing things.
php -d memory_limit=512M bin/console Wise2Sync:run --id_profile=PROFILE_ID --no-debug
Possible solution #2
If the "500 error" is really caused because of memory limits, you can try increasing the memory_limit of PHP. You might need to contact your hosting / server provider to do so. For example:
memory_limit = 512MB
Possible solution #3
Reduce the amount of products you are exporting in app.wise2sync.com by adding more filters. Start with small catalog and then increase the size.