Skip to content
Synchronize ANY ecommerce platfrom with search service by database & cron.
PHP Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

eCommerce Synch


This is NOT a plugin to any of eCommerce platform. This is standalone application that process data from store's database (by modules for specific platform) into other system eg. search service.

Supported eCommerce platforms

  • Magento 1 ( -
  • Magento 2 (2.2 - 2.3.0)
  • WooCommerce (5.1.1)
  • PrestaShop ( -
  • OpenCart ( - X)
  • osCommerce ( - 2.4.2)
  • Sylius (1.4.3)

Other versions might work as well, but was not tested.

How does it work

Cron executes synchronization command. It takes configuration file, determine what is input module. It executes its SQL SELECT statements and saves result into CSV files (products and categories). Output module push CSV data into remote system eg. search service.


Installation (easy)

That way is OK for small and medium stores. It is easier to setup, but little bit less optimal, as CSV files will be generated by PHP code insetad of database itself.

  1. composer require logshub/ecommerce-synch
  2. cp ecommerce-synch/config.example.ini ecommerce-synch/config.ini
  3. Setup your ecommerce-synch/config.ini: logshub credentials, input module and database connection. Set generate_csv_by_database = 0 (easy configuration).
  4. Add into your cron: php vendor/bin/ecommerce-synch synch -c config.ini. Frequency depends on configuration (see check_update_dates).


cd /var/www/
mkdir ecommerce-synch
cd ecommerce-synch/
composer require logshub/ecommerce-synch
cp vendor/logshub/ecommerce-synch/config.example.ini config.ini
# setup credentials + input module
nano config.ini
# test synchronization
php /var/www/ecommerce-synch/vendor/bin/ecommerce-synch synch -c /var/www/ecommerce-synch/config.ini
# setup cron
crontab -e
# paste similar to the following:
5 * * * * php /var/www/ecommerce-synch/vendor/bin/ecommerce-synch synch -c /var/www/ecommerce-synch/config.ini > /tmp/ecommerce-synch.log

Installation (experimental, advanced)

It is more advanced setup, but more optimal, as CSV files will be generated by database itself insetad of PHP code.

  1. Make sure you run this code on the same server with database - access to /var/lib/mysql-files/ needed.
  2. Your DB user must have FILE privilege in database (see below).
  3. Process with the "easy" installation steps with this exception: generate_csv_by_database = 1.

AD 2

GRANT FILE ON *.* TO myuser;

How to create input module?

There could be cases when your database structure is little bit different then the standard ones. You can create your own module, that match your database structre.

composer require logshub/ecommerce-synch
# setup files like below...
composer dump-autoload

Example project structure

├── composer.json
├── modules.php
└── src
    └── Module
        └── Input
            └── MyStoreCom.php

Content of composer.json

    "require": {
        "logshub/ecommerce-synch": "dev-master"
    "autoload": {
        "files": [
        "psr-4": {
            "MyStore\\": "src"

Content of modules.php, that is loaded automatically by composer.

use Logshub\EcommerceSynch\Module\Registrar;

Registrar::registerInput(new \MyStore\Module\Input\MyStoreCom());

Content of src/Module/Input/MyStoreCom.php file with your custom module.

namespace MyStore\Module\Input;

class MyStoreCom extends \Logshub\EcommerceSynch\Module\Input\ModuleAbstract
     * @return Name that 
    public function getName()
        return '';

    public function getProductsSql(\DateTime $time = null)
        $sql = "SELECT 'id', 'name', 'url', 'url_image', 'price', 'price_old', 'currency', 'description', 'categories', 'sku'";
        // UNION
        // SELECT,, p.url, p.url_image, p.price, p.price_old, p.currency, p.description, p.categories, p.sku FROM product AS p WHERE p.enabled = 1

        // if (!empty($time)) {
        //     $sql .= " AND p.updated_at >= '".$time->format('Y-m-d H:i:s')."' ";
        // }

        return $sql;

    public function getCategoriesSql(\DateTime $time = null)
        $sql = "SELECT 'id', 'name', 'url', 'url_image'";
        // UNION
        // SELECT,, c.url, c.url_image FROM categories AS c WHERE c.enabled = 1

        // if (!empty($time)) {
        //     $sql .= " AND c.updated_at >= '".$time->format('Y-m-d H:i:s')."' ";
        // }

        return $sql;

    public function getCurrentIdsSql()
        return 'SELECT 1';
        // SELECT FROM product AS p WHERE p.enabled = 1
        // UNION
        // SELECT FROM categories AS c WHERE c.enabled = 1

Now, you can configure input.module in config.ini file to use your custom module (from MyStoreCom::getName).

module = ""

How to change data before synchronizing?

Create getProductCsvRowCallback method in your custom module. See src/Module/Input/OpenCart.php file for example: OpenCart::getProductCsvRowCallback, OpenCart::onCsvRow.


  • Last updated time is not calculated correctly? Make sure timezone is the same on the PHP and database side


  • clear old CSV files (new command)
  • callback for database dump

Input modules to do

You can’t perform that action at this time.