Disabling stock calculation

Since Shopware 6.5.4.0 it is possible to disable the internal stock calculation functions, enabling, for example, an ERP, to handle all stock calculations.

The following changes' effect is that Shopware itself no longer calculates any stock-related values - such as in the event of an order placed - which would have an effect on either the stock or available stock.

Presumably with the release of version 6.6 this will become the default handling. Until then, it is necessary to make both edits explained hereafter in the shop's configuration.
 

Edits in the shop's configuration

Edit in the .env


In the .env file, which can be found in your shop's main directory, the fundamental environment variables are defined. To deactivate Shopware's stock handling, first add the following line:
 

STOCK_HANDLING=1
With this, the new handling, which is used from version 6.6 onwards by default, will be activated. This is the basic requirement for the next step to work.
 

Edit in the shopware.yaml

Please note that this change should almost always be made in the z-shopware.yaml, because edits in the shopware.yaml will be overwritten in case of an update, resulting in the change losing effect. Edits in the z-shopware.yaml are unaffected by an update.

In the .yaml file, which you can find in the directory /config/packages/(z-)shopware.yaml, you can now add the following code:
 

shopware:
  stock:
    enable_stock_management: false
After the edit, the shop's cache should be cleared.

A product's stock values still exist after the change, but Shopware no longer adds or detracts stock values triggered by placed or delivered orders.

At this point, for example, an ERP can take the lead when it comes to stock values, without Shopware having any influence over them.

Was this article helpful?