"Automate inventory update" (SimpleStockUpdate)

Purpose of this plugin

This plugin helps you to keep your stock information up-to-date by providing a cronjob to automate importing CSV files. In example in case you sell on multiple platforms and want to sync your stock with your ERP.

The plugins cronjob checks in given intervals if the configured file has changed and imports it in case it has.

(Un-)Install

By using the plugin manager, see Shopware documentation for details.

Please clear Shopwares cache after installing, otherwise it could happen that components can't be found. You should be asked to do so after installing.

Usage

How you invoke the cronjob, doesn't matter. You can do so by using your browser, your servers crontab or bin/console. For details please see the Shopware documentation https://en-community.shopware.com/_detail_1103.html#Setting_up_a_cronjob. To adjust the import interval, you can edit the cronjobs interval.

The "action name" for usage by bin/console is Shopware_CronJob_pixe2SimpleStockUpdateCron, so the whole command is bin/console sw:cron:run Shopware_CronJob_pixe2SimpleStockUpdateCron.

Depending on the amount of articles, the import runtime could be quite high. Because of that the execution by browser is unsuited.

Configuration

The plugin has options to adjust the process. Set this options like you need them, then activate the cronjob. Please note that Shopwares own plugin "Cron" must be active for this plugin to work.

Filepath

Enter the name of the import file here. The plugin assumes that this file resides in the plugin directory. Plugin directory means <yourshop>/custom/plugins/pixe2SimpleStockUpdate. But you can also enter relatives paths, as long as that path is readable for the user account under which the webserver/PHP is running. For relative paths to work, they must be relative to the plugin directory. In example, if the file is located in the root of your shop, the path would be ../../../file.csv. Keep in mind that not only the path itself, but also the file needs to be readable.

You can also give an HTTP(S), SFTP or FTP URL here, the file will be fetched and deleted again after importing.

Verify remote files

Files coming from an HTTP(S), SFTP or FTP source will be downloaded multiple times if activated. After each download a sha1 checksum will be calculated. The plugin will assume that the file is being actively modified right now f the checksum doesn't match. In that case the plugin will reschedule the job to be executed again in 5 minutes.

Attention: this introduces at least 10 seconds of artificial delay into the process.

Ignore SSL errors

If active SSL errors while fetching a remote file, in example caused by a self-signed cert, will be ignored.

Column separator

Enter the column separator here. You can use any sequence of characters, in example "," or ";". To use [TAB] as separator please enter "\t" here.

Identity column

Numerical index of the column holding the identity value (Note: count starts at 0!)

Value column

Numerical index of the column containing the new stock value (Note: count starts at 0!)

Skip first line

If the first line of the import file contains column headers, you can activate this option to ignore it at import time.

Return value

Here you can configure how the result is handled. You can set it to return it in either plain text, JSON or serialized. Alternatively you can set it to echo'ing instead of returning, or disable it at all.

Debug-Logging

When activated the plugin will write debugging information to the plugin log. You can view the log directly in the Backend.

Please note that Shopware shows only errors in the default configuration, so all information will be logged as error - even if it isn't an error - just to show up in backend.

(De-)activate articles

Will de-/activate articles based on the imported stock amount being positive or not.

Always activate imported articles

If activated imported articles will always be activated, ignoring the stock given in the file.

Attention: If combined with "(De-)activate articles" that option will override this one.

Identityfield

Allows you to choose the property used to match the import data onto articles. By default, the ordernumber will be used.

Disable locking

By default the plugin will create a file called ".lockfile" in the plugin directory when starting the import. This file is used to prevent multiple imports from running at the same time. If the last import was terminated early, most likely because of execution by browser and max_execution_time, the file will not be deleted and prevent further runs to properly start. You can use this option to disable this check without deleting ".lockfile".

IMPORTANT: This option is intended as workaround, not for permanent use. If the lockfile still exists after the job is run, it wasn't finished properly!

Disable check for changes

Normally the plugin will only start importing, when the import file has changed since the last run. By enabling this option you can disable this check and force the import to be executed no matter the "last modified" timestamp of the importfile.

Normalize linebreaks

In case your importfile uses "\r" linebreaks, or some mix, you can activate a workaround with this option.

Deactivate articles not in importfile

If activated articles not contained in the importfile will be deactivated. To narrow this you can use the option ""not in importfile" prefix - inclusion". There is also an option for an exclusion filter.

Note: this only works when using the ordernumber as identityfield! Additionally variants needs to follow the standard scheme for ordernumbers, to be concrete: their ordernumber must be based on the main article ordernumber (i.e main article = SW10001, variants SW10001.2 SW10001.3 etc).

"not in importfile" prefix - inclusion

With this option you can INCLUDE articles not contained in the import file for the deactivation / stock clearing. The value will be used as prefix. So if you enter "DS" here, every article which ordernumber starts with "DS" and which wasn't contained in the import file will be deactivated / cleared. If this option isn't set ALL articles will be deactivated / cleared.

"not in importfile" prefix - exclusion

With this option you can EXCLUDE articles not contained in the import file from the deactivation / stock clearing. The value will be used as prefix. So if you enter "DS" here, every article which ordernumber starts with "DS" will NOT be deactivated/cleared even if not contained in the import file. If this option is not set, all articles matching the option '"not in importfile" prefix - inclusion' will be deactivated/cleared.

Delete stock of articles not in importfile

If activated, the stock of articles not imported will be set to 0.

Pickware support

If activated, stock changes will be imported "native" into Pickware instead of simply changing the articles inStock attribute.

Important notice if you used this plugin in combination with Pickware without this option

In case you used this plugin im combination with Pickware before this option existed, all stock changes were executed directly on the "reserved stock". With this option activated all changes will be executed on the "physical stock" instead. Because of this it's possible that the resulting stock is incorrect, or doubled after importing the first time with this option activated. So please make sure to check the stock of affected articles afterwards!

Pickware support: relative import

If the import file contains relative values instead of totals, activate this option. Without this option the file is expected to contain total values.

Pickware support: Target warehouse

Enter the target warehouse name here.

Pickware support: Target bin location

With this option you can give the bin location for the imported stock (default: pickware_null_bin_location).

Minimum stock to import

In case you want to update your stock only if the imported value is larger then X, you can set this option to X. Articles in the import file having a new stock value lower then X wont be updated then.

Stock values are graduation units

If activated the imported stock values will be interpreted as "graduation containers" and multiplied accordingly. An example: you offer some softdrink in cans but the supplier is offering it only in sixpacks. So you set the article to have a minimum order and graduation amount of 6. The stock given by the supplier in the import file is specifying sixpacks, not cans so it needs to be multiplied by the graduation amount.

Remarks

Non existing articles will be logged as error, but import of the file will be continued nonetheless.

In case there is a non-numeric inventory value in the file for some article, the affected article will have an inStock value of 0 after import.

The results of the import can be viewed in the configured format, in the cronjob configuration. Same applies to errors that maybe occurred. You could also redirect the output into a file.

All columns except the ones for articlenumber and stock will be ignored. But keep in mind that they need to be loaded into memory anyway. Depending on filesize it can make sense to reduce the file before.