actualizer / stock-importer
Import stock levels from CSV files
Package info
github.com/actualizer/ActStockImporter
Type:shopware-platform-plugin
pkg:composer/actualizer/stock-importer
Requires
- php: >=8.4
- phpseclib/phpseclib: ^3.0
- shopware/core: >=6.7 <6.8
README
A Shopware 6 plugin that automatically imports stock levels from CSV files, supporting both local file processing and SFTP integration for automated stock management.
Features
- Import stock levels from CSV files
- Support for both local directory and SFTP server as data source
- Scheduled automatic imports with configurable intervals
- Manual import via console command
- Product activation/deactivation based on stock status
- Two stock update methods: absolute and normal
- Automatic file backup with configurable retention
- Stock aggregation for duplicate product numbers
- Change detection: only products whose stock or active status actually changed are written
- Comprehensive logging and error handling
- Compatible with Shopware 6.7
Requirements
- Shopware 6.7 or higher
- PHP 8.4 or higher
- phpseclib/phpseclib ^3.0 (for SFTP functionality)
Installation
Via Composer (recommended)
composer require actualizer/stock-importer bin/console plugin:refresh bin/console plugin:install --activate ActStockImporter bin/console cache:clear
Manual
- Download or clone this plugin into your
custom/plugins/directory - Install and activate the plugin via CLI:
bin/console plugin:refresh bin/console plugin:install --activate ActStockImporter bin/console cache:clear
Configuration
- Go to Admin Panel → Settings → System → Plugins
- Find "Actualize: Stock Importer" and click on the three dots
- Click "Config" to access plugin settings
Configuration Options
- Import Method: Choose between local directory or SFTP server
- Stock Update Method:
normal: Updates only stock fieldabsolute: Updates both stock and availableStock fields
- Scheduled Import: Enable/disable automatic imports
- Import Interval: Set interval in minutes for automatic imports
- Backup Retention: Number of days to keep backup files
- SFTP Settings (if using SFTP method):
- Host, Port, Username, Password
- Remote directory path
CSV File Format
The plugin expects CSV files with semicolon (;) as delimiter and the following structure:
Product Number;Stock;Active
ABC-123;50;1
XYZ-456;0;0
DEF-789;25;1
Columns:
Product Number: The product's article number in ShopwareStock: Stock quantity (integer)Active: Product activation status (1 = active, 0 = inactive)
How it works
Local Directory Method
- File Placement: Place CSV files in the
_act_stockimporterdirectory in your project root - Processing: Files are processed in order of modification time (oldest first)
- Backup: Processed files are moved to
_act_stockimporter/backupwith timestamp prefix - Cleanup: Old backup files are automatically deleted based on retention settings
SFTP Method
- File Download: Plugin connects to SFTP server and downloads CSV files
- Processing: Downloaded files are processed locally
- Cleanup: Files are deleted from SFTP server after successful download
- Backup: Same local backup process as directory method
Stock Processing
- Aggregation: If multiple rows exist for the same product number, stock quantities are summed
- Activation: If any row for a product is marked as active, the product remains active
- Change detection: The current stock and active status are compared against the imported values. Rows that match the current state are skipped, so a file that repeats unchanged stock levels causes no writes at all
- Update: Only the remaining products are written with new stock levels and activation status
- Logging: Changed products are logged individually with their previous values, followed by a per-file summary (checked, updated, unchanged, not found)
Manual Import
You can trigger imports manually using the console command:
bin/console act:stock:import
Technical Details
Events and Scheduling
- Uses Shopware's scheduled task system for automatic imports
- Task interval is dynamically configurable through admin settings
- Supports both immediate execution and scheduled processing
File Processing
- CSV parsing with semicolon delimiter
- Automatic header row detection and skipping
- Error handling for malformed files
- Support for different file encodings
Stock Update Methods
- Normal: Updates only the
stockfield - Absolute: Updates both
stockandavailableStockfields for complete inventory control availableStockis not part of the change detection, because Shopware maintains it itself (open orders reserve stock). It is written along with every real change, but a differingavailableStockalone does not trigger an update
Backup and Retention
- Automatic backup of processed files with timestamp
- Configurable retention period (default: 30 days)
- Automatic cleanup of old backup files
Development
Building/Testing
After making changes:
bin/console cache:clear bin/console scheduled-task:run
Debugging
- Check log files for import operations and errors
- Enable Shopware's debug mode for detailed error information
- Use the manual import command for testing
Example Usage
-
Local Directory Setup:
- Enable local directory import method
- Place CSV files in
_act_stockimporter/ - Files are processed automatically or manually
-
SFTP Integration:
- Configure SFTP connection details
- Set up automated file upload to SFTP server
- Plugin downloads and processes files automatically
-
Scheduled Processing:
- Enable scheduled imports
- Set appropriate interval (e.g., 5 minutes)
- Monitor logs for successful operations
Compatibility
- Shopware Version: 6.7
- PHP Version: 8.4+
- Dependencies: phpseclib/phpseclib ^3.0
- Template Compatibility: Uses Shopware 6.7 plugin structure
Support
For issues and feature requests, please use the GitHub issue tracker.
License
This plugin is licensed under the MIT License - see the LICENSE file for details.
Credits
Developed by Actualize
Made with ❤️ for the Shopware Community