setono/sylius-stock-movement-plugin
Composer 安装命令:
composer require setono/sylius-stock-movement-plugin
包简介
Plugin to handle stock related activities
README 文档
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\" }"
统计信息
- 总下载量: 7.17k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-06-12