How to update products stock from an external PHP file

Hi,
in Magento 1.x I could just load the Mage Class and update my product information / stock level from an external php file without the need of writing an extension.

How is this done now?

Thx.

Why is not the standard backend import sufficient for the task?

because I automatically process a XML file with stock information. The file is uploaded to a specific folder by an ERP software and in Magento 1.x I can just loop through the xml objects and update the stock level of each product…I wouldn’t wanna do this manually via import :slight_smile:

Why do not you want create an extension for the task?
I recommend this approach because it is official, reliable, ans sustainable way to extend Magento.

If the import need to be executed regularly by a schedule, then I recommend to follow the instruction How can an extension schedule a cron job with a crontab.xml file?

If you need an ability to execute the import not only by a schedule, but by a manual console command too, then you can place your import cron job into a custom execution group and then you can run cron for the single execution group.

Also, an extension can add a custom console command and handle it.

In the most complex scenarios you can setup Magento 2 as an OAuth server and use a web api to update the store’s stock.

ok that would be possible but writing an extension takes 10 times more time than a little script file. I also use those external scripts to get some shop statistics, product information and so one…and more each of that I would need to write an extension instead of my single script file.