PHP code example of logshub / ecommerce-synch

1. Go to this page and download the library: Download logshub/ecommerce-synch library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

logshub / ecommerce-synch example snippets



use Logshub\EcommerceSynch\Module\Registrar;

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


namespace MyStore\Module\Input;

class MyStoreCom extends \Logshub\EcommerceSynch\Module\Input\ModuleAbstract
{
    /**
     * @return Name that 
     */
    public function getName()
    {
        return 'my-store.com';
    }

    public function getProductsSql(\DateTime $time = null)
    {
        $sql = "SELECT 'id', 'name', 'url', 'url_image', 'price', 'price_old', 'currency', 'description', 'categories', 'sku'";
        // UNION
        // SELECT p.id, p.name, 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.id, c.name, 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 p.id FROM product AS p WHERE p.enabled = 1
        // UNION
        // SELECT c.id FROM categories AS c WHERE c.enabled = 1
    }
}

GRANT FILE ON *.* TO myuser;
FLUSH PRIVILEGES;

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