setono / sylius-stock-movement-plugin
Plugin to handle stock related activities
Installs: 7 166
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 3
Open Issues: 13
Type:sylius-plugin
Requires
- php: ^7.2
- league/flysystem-bundle: ^1.1
- psr/event-dispatcher: ^1.0
- ramsey/uuid: ^3.8
- setono/cron-expression-bundle: ^1.0
- sylius/resource-bundle: ^1.6
- sylius/sylius: ^1.3
- symfony/event-dispatcher: ^4.3 || ^5.0
- symfony/messenger: ^4.3 || ^5.0
- thecodingmachine/safe: ^1.0
Requires (Dev)
- behat/behat: ^3.4
- behat/mink: ^1.7@dev
- behat/mink-browserkit-driver: ^1.3
- behat/mink-extension: ^2.2
- behat/mink-selenium2-driver: ^1.3
- ergebnis/composer-normalize: ^2.0
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.0
- friends-of-behat/variadic-extension: ^1.1
- lakion/mink-debug-extension: ^1.2.3
- lchrusciel/api-test-case: ^4.1
- phpspec/phpspec: ^5.0 || ^6.0
- phpstan/phpstan: ^0.11
- phpstan/phpstan-doctrine: ^0.11
- phpstan/phpstan-strict-rules: ^0.11
- phpstan/phpstan-webmozart-assert: ^0.11
- phpunit/phpunit: ^8.2
- roave/security-advisories: dev-master
- sensiolabs/security-checker: ^5.0
- sylius-labs/coding-standard: ^3.0
- symfony/browser-kit: ^3.4 || ^4.1
- symfony/debug-bundle: ^3.4 || ^4.1
- symfony/dotenv: ^4.2
- symfony/intl: ^3.4 || ^4.1
- symfony/web-profiler-bundle: ^3.4 || ^4.1
- symfony/web-server-bundle: ^3.4 || ^4.1
- thecodingmachine/phpstan-safe-rule: ^1.0@beta
- dev-master / 1.0.x-dev
- v0.3.1
- v0.3.0
- v0.2.0
- v0.1.1
- v0.1.0
- dev-renovate/configure
- dev-dependabot/composer/symfony/dotenv-tw-5.3
- dev-dependabot/composer/symfony/web-profiler-bundle-tw-5.0.11
- dev-dependabot/composer/symfony/debug-bundle-tw-5.1.11
- dev-dependabot/add-v2-config-file
- dev-dependabot/composer/league/flysystem-bundle-tw-2.0
- dev-dependabot/composer/lakion/mink-debug-extension-tw-2.0.0
- dev-dependabot/composer/lchrusciel/api-test-case-tw-5.0
- dev-dependabot/composer/sensiolabs/security-checker-tw-6.0
- dev-feature-improvements
This package is auto-updated.
Last update: 2024-11-15 16:45:50 UTC
README
Log all stock movements in your shop. You can use this to create very accurate reports of your inventory movements.
Installation
Step 1: Download the plugin
Open a command console, enter your project directory and execute the following command to download the latest stable version of this plugin:
$ composer require setono/sylius-stock-movement-plugin
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the plugin
Then, enable the plugin by adding it to the list of registered plugins/bundles
in the config/bundles.php
file of your project:
<?php return [ // ... League\FlysystemBundle\FlysystemBundle::class => ['all' => true], Setono\CronExpressionBundle\SetonoCronExpressionBundle::class => ['all' => true], Setono\SyliusStockMovementPlugin\SetonoSyliusStockMovementPlugin::class => ['all' => true], // It is important to add plugin before the grid bundle Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], // ... ];
NOTE that you must instantiate the plugin before the grid bundle, else you will see an exception like You have requested a non-existent parameter "setono_sylius_stock_movement.model.report_configuration.class".
Step 3: Import routing
# config/routes/setono_sylius_stock_movement.yaml setono_sylius_stock_movement: resource: "@SetonoSyliusStockMovementPlugin/Resources/config/routing.yaml"
Step 4: Configure plugin
# config/packages/setono_sylius_stock_movement.yaml imports: - { resource: "@SetonoSyliusStockMovementPlugin/Resources/config/app/config.yaml" } setono_sylius_stock_movement: templates: - label: Default template: "@SetonoSyliusStockMovementPlugin/Template/default.txt.twig"
Step 5: Update database schema
Use Doctrine migrations to create a migration file and update the database.
$ bin/console doctrine:migrations:diff $ bin/console doctrine:migrations:migrate
Step 6: Install assets
$ php bin/console assets:install
Step 7: Using asynchronous transport (optional, but recommended)
All commands in this plugin will extend the CommandInterface. Therefore you can route all commands easily by adding this to your Messenger config:
# config/packages/messenger.yaml framework: messenger: routing: # Route all command messages to the async transport # This presumes that you have already set up an 'async' transport # See docs on how to setup a transport like that: https://symfony.com/doc/current/messenger.html#transports-async-queued-messages 'Setono\SyliusStockMovementPlugin\Message\Command\CommandInterface': async
Step 8 (optional): Create or import fixtures
-
Import fixtures:
# config/packages/_sylius.yaml imports: # ... - { resource: "@SetonoSyliusStockMovementPlugin/Resources/config/app/fixtures.yaml" }
-
Or create your own:
# config/fixtures.yaml sylius_fixtures: suites: YOUR_SUITE: fixtures: setono_stock_movement: options: amount: 1000
API
Create a stock movement on the variant variant-code
with a quantity of 1:
brew install jq SYLIUS_HOST=http://127.0.0.1:8000 SYLIUS_ADMIN_API_ACCESS_TOKEN=$(curl $SYLIUS_HOST/api/oauth/v2/token \ --silent --show-error \ -d "client_id"=demo_client \ -d "client_secret"=secret_demo_client \ -d "grant_type"=password \ -d "username"=api@example.com \ -d "password"=sylius-api | jq '.access_token' --raw-output) SYLIUS_SOME_PRODUCT_CODE=$(curl $SYLIUS_HOST/api/v1/products/?limit=1 \ --silent --show-error \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN" \ -H "Accept: application/json" | jq '._embedded.items[0].code' --raw-output) echo "Some product code: $SYLIUS_SOME_PRODUCT_CODE" SYLIUS_SOME_PRODUCT_VARIANT_CODE=$(curl $SYLIUS_HOST/api/v1/products/$SYLIUS_SOME_PRODUCT_CODE/variants/?limit=1 \ --silent --show-error \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN" \ -H "Accept: application/json"| jq '._embedded.items[0].code' --raw-output) echo "Some product variant code: $SYLIUS_SOME_PRODUCT_VARIANT_CODE" curl $SYLIUS_HOST/api/v1/stock-movements/ \ -X POST \ -H 'Accept: application/json' \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN" \ -H 'Content-Type: application/json' \ -d "{ \"quantity\": 1, \"variant\": \"$SYLIUS_SOME_PRODUCT_VARIANT_CODE\" }"