Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The OneStock magento connector is an open source connector. It has been developped in partnership with Smile.
Smile is the European leader of Open Source and also a four-times Europe Partner of the the Year (2010-2014), two-times Spirit of Excellence (2015-2016), Global Elite Partner (2017-now), and Regional Commercial Partner (2018) awarded by Magento.

2. Installation

2.1.

...

With composer

The connector is available on packagist : https://packagist.org/packages/onestock/onestock-magento-connector

...

Info

The connector has an internal CRON that will look for available stock files either locally or on a remote SFTP. It doesn’t trigger the stock export.

Panel
panelIconIdatlassian-warning
panelIcon:warning:
bgColor#FFFAE6

The FTP User must have the permissions to create files, to move files and to create folders on the ftp. The connector will create this folder if it doesn’t exist, then move the processed stock files on it. If the user doesn’t have the correct permissions, the files will not be consumed.

  • Import/export folder path : the root directory where the stock files are saved on your magento server.

Info

You can also change the folder with an absolute path in Store Configuration. It is required if magento runs in folders managed by symlinks toward release.

/var/www/vhosts/www/.../curent/var/importexport/onestock/...

  • Unified Stock : file pattern for FULL : file patterns to import for your unified full stock file. You can use an asterix for files exported from OneStock with a date.

  • Unified Stock : file pattern for DIFF : file patterns to import for your unified delta stock file. You can use an asterix for files exported from OneStock with a date.

  • Fetch file on remote FTP : if yes, it will retrieve the stock file from the remote FTP configured bellow

  • Remote FTP Username

  • Remote FTP Password

  • Remote FTP Hostname or IP-Address

  • Remote FTP Custom Path : root folder under which the stocks files will be stored on the FTP

  • Remote cleanup file after import :

    • Do nothing : will do nothing

    • Remove : will remove the file from the SFTP

    • Archive : will move the file to an archive folder on the same directory as the custom path.

...

  • Enabled : if true, it will display the delivery promise on top of the magento delivery blocs

  • Guest postcode : default postcode to use to display the delivery promise

  • Guest country : default country to use to display the delivery promise

  • Greenest option : display a leaf icon for the greenest delivery option

...

4. How to

...

extend the connector

Even though the module onestock/onestock-magento-connector is designed to be plug and play, here is some common customisation.

...

  • For example, to export a new value as the onestock order field sign_on_collect, the following php source code can be used

    Code Block
    languagephp
    <?php
    
    
    class SignOnCollect implements ObserverInterface
    {
    
    
       public function execute(Observer $observer): void
       {
           $order = $observer->getSource();
           $target = $observer->getTarget();
           $target['sign_on_collect'] =  true;
       }
    }
  • Half a dozen observers in the module onestock/onestock-magento-connector can also be used as an example and overridden to match your specific requirement.

  • To export a new value as the onestock order fielddelivery.endpoint_id, the following php source code can be used

    Code Block
    languagephp
    <?php
    
    
    class ClickAndCollect implements ObserverInterface
    {
    
    
       public function execute(Observer $observer): void
       {
           $order = $observer->getSource();
           $target = $observer->getTarget();
           $target['delivery']['endpoint_id'] =  'TOULOUSE';
       }
    }

4.4. Trigger a stock import (full or delta)

Using n98-magerun you can trigger the jobs with the following commands:

Code Block
languagebash
$di->create('Smile\Onestock\Cron\StockFull')->start();
$di->create('Smile\Onestock\Cron\StockDiff')->start();

5. Troubleshoot

5.1. OneStock does not receive any order from magento

The module uses the "message queue framework" an high level interface of message queue which does not require RabbitMQ.

In app/etc/env.php the instruction bloc cron_consumers_runner is not exclusive to Adobe Commerce Cloud. If configured, cron:run will launch automatically the command queue:consumers:start without the need to launch it manually. Most magento instance rely on cron:run (in particular Adobe Commerce Cloud launch it by defaut) so cron_consumers_runner is the easy option. Nevertheless, if you manage cron in an other manner, you must launch the queue:consumers:start demon yourself in order to consume magento messages.

If rabbitmq is not configured, messages will be stored in mysql and will be visible in a table queue_message. Their status will be stored in queue_message_status. A figure stands for the status (MESSAGE_STATUS_NEW = 2, MESSAGE_STATUS_IN_PROGRESS = 3, MESSAGE_STATUS_COMPLETE= 4). If you are rabbitmq instead, you can monitor if the messages are being created and consumed in the RabbitMQ management plugin.

When an order is invoiced (placed depending on your configuration), a message_queue async.smile.onestock.api.orderexportinterface.export.post will be created. Messages are also added to a specific log file var/log/onestock.log to understand what is going on.

5.2. Magento does not create a shipment even if OneStock calls the webhook. We cannot create an empty shipment

If enabled, a specific log file var/log/onestock.log to understand what is going on will log the onestock order. The onestock order must reference a parcel (and parcel_id), each element of the line_item_groups must be in the state fulfilled or claimed.

5.3. Magento does not import the unified stock

Unified stock file must be a CSV with the first line dedicated to CSV title item_id and quantity. This CSV must be coma separated. Item_id column is the equivalent of sku in magento.

By default this csv file must be stored in magento filesystem in the relative var folder with a valid filename pattern, for example var/importexport/onestock/in/unified_stock/stock_unified_sc0_full_202309111111.csv

Full stock import file and differencial stock import file are to be stored in the same folder, only file pattern changes.

You can also change the folder with an absolute path in Store Configuration. It is required if magento runs in folders managed by symlinks toward release.

...

You can also change the file pattern in Store Configuration.

You can also use n98 sys:cron:run to run the cron onestock_full_stock_import or the cron onestock_diff_stock_import outside schedule and reproduce your problem.