setono / sylius-stock-movement-plugin
处理库存相关活动的插件
v0.3.1
2020-01-03 14:00 UTC
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-09-15 16:34:26 UTC
README
记录商店中所有库存变动。您可以使用此功能创建非常精确的库存变动报告。
安装
步骤 1: 下载插件
打开命令行,进入项目目录,执行以下命令以下载此插件的最新稳定版本
$ composer require setono/sylius-stock-movement-plugin
此命令要求您全局安装了Composer,具体说明请参阅Composer文档中的安装章节。
步骤 2: 启用插件
然后,将插件添加到项目 config/bundles.php
文件中注册的插件/包列表中,以启用该插件
<?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], // ... ];
注意:您必须在网格包之前实例化插件,否则您将看到类似 您请求了不存在的参数 "setono_sylius_stock_movement.model.report_configuration.class"。
的异常。
步骤 3: 导入路由
# config/routes/setono_sylius_stock_movement.yaml setono_sylius_stock_movement: resource: "@SetonoSyliusStockMovementPlugin/Resources/config/routing.yaml"
步骤 4: 配置插件
# 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"
步骤 5: 更新数据库模式
使用Doctrine迁移创建迁移文件并更新数据库。
$ bin/console doctrine:migrations:diff $ bin/console doctrine:migrations:migrate
步骤 6: 安装资源
$ php bin/console assets:install
步骤 7: 使用异步传输(可选,但推荐)
此插件中的所有命令都将扩展 CommandInterface。因此,您可以通过添加以下内容到您的 信使配置 来轻松路由所有命令。
# 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.cn/doc/current/messenger.html#transports-async-queued-messages 'Setono\SyliusStockMovementPlugin\Message\Command\CommandInterface': async
步骤 8(可选):创建或导入数据集
-
导入数据集
# config/packages/_sylius.yaml imports: # ... - { resource: "@SetonoSyliusStockMovementPlugin/Resources/config/app/fixtures.yaml" }
-
或创建自己的
# config/fixtures.yaml sylius_fixtures: suites: YOUR_SUITE: fixtures: setono_stock_movement: options: amount: 1000
API
在变体 variant-code
上创建一个库存变动,数量为 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\" }"