setono / sylius-pronavic-plugin
Pronavic 的官方 Sylius 插件
此软件包的官方仓库似乎已不存在,因此软件包已被冻结。
v0.1.11
2020-09-23 19:05 UTC
Requires
- php: ^7.4
- pagerfanta/doctrine-orm-adapter: ^2.4
- spatie/data-transfer-object: ^1.0 || ^2.0
- sylius/sylius: ^1.7
- symfony/config: ^4.4 || ^5.0
- symfony/http-client: ^5.1
- symfony/messenger: ^4.4 || ^5.0
- symfony/workflow: ^5.1
- thecodingmachine/safe: ^1.0
Requires (Dev)
- lchrusciel/api-test-case: ^4.1
- loevgaard/sylius-barcode-plugin: ^1.4
- loevgaard/sylius-brand-plugin: ^2.1
- matthiasnoback/symfony-config-test: ^4.2
- matthiasnoback/symfony-dependency-injection-test: ^4.1
- phpspec/phpspec: ^6.2
- phpunit/phpunit: ^8.5
- roave/security-advisories: dev-master
- setono/code-quality-pack: ^1.4
- setono/sylius-cost-price-plugin: ^1.0
- setono/sylius-gift-card-plugin: ^0.10
- setono/sylius-pickup-point-plugin: ^1.0@beta
- symfony/browser-kit: ^4.4 || ^5.0
- symfony/debug-bundle: ^5.1
- symfony/dotenv: ^5.1
- symfony/intl: ^4.4 || ^5.0
- symfony/web-profiler-bundle: ^5.0
Suggests
- loevgaard/sylius-barcode-plugin: To render barcode at endpoints
- loevgaard/sylius-brand-plugin: To render brand at endpoints
- setono/sylius-cost-price-plugin: To render cost price at endpoints
This package is auto-updated.
Last update: 2020-09-24 17:22:14 UTC
README
这是 Pronavic/Navision 的官方插件
安装
步骤 1:安装并启用插件
打开命令行控制台,进入您的项目目录,然后执行以下命令以下载此插件的最新稳定版本
$ composer require setono/sylius-pronavic-plugin
此命令要求您全局安装了 Composer,如 Composer 文档中的安装章节所述。
将包添加到您的 config/bundles.php
<?php # config/bundles.php return [ // ... Setono\SyliusPronavicPlugin\SetonoSyliusPronavicPlugin::class => ['all' => true], // ... ];
安装其他插件(可选)
为了在端点上渲染其他字段,请安装以下插件
- https://github.com/loevgaard/SyliusBrandPlugin
- https://github.com/loevgaard/SyliusBarcodePlugin
- https://github.com/Setono/SyliusCostPricePlugin
步骤 2:导入配置和路由
导入应用程序配置并配置插件
# .env
###> setono/sylius-pronavic-plugin ###
PRONAVIC_CHANNEL_CODE=FASHION_WEB
PRONAVIC_LOCALE=en_US
PRONAVIC_CURRENCY_CODE=USD
PRONAVIC_BUSINESS_CENTRAL_BASE_URI=https://api.businesscentral.dynamics.com/v1.0/account.onmicrosoft.com/sandbox/
PRONAVIC_BUSINESS_CENTRAL_USERNAME=UserName
PRONAVIC_BUSINESS_CENTRAL_PASSWORD=p4$$w0rd
PRONAVIC_BUSINESS_CENTRAL_COMPANY=TestCompany
###< setono/sylius-pronavic-plugin ###
# config/packages/setono_sylius_pronavic.yaml imports: - { resource: "@SetonoSyliusPronavicPlugin/Resources/config/app/config.yaml" } setono_sylius_pronavic: channel_code: '%env(PRONAVIC_CHANNEL_CODE)%' locale_code: '%env(PRONAVIC_LOCALE)%' currency_code: '%env(PRONAVIC_CURRENCY_CODE)%' business_central: base_uri: '%env(PRONAVIC_BUSINESS_CENTRAL_BASE_URI)%' username: '%env(PRONAVIC_BUSINESS_CENTRAL_USERNAME)%' password: '%env(PRONAVIC_BUSINESS_CENTRAL_PASSWORD)%' company: '%env(PRONAVIC_BUSINESS_CENTRAL_COMPANY)%'
导入路由
# config/routes/setono_sylius_pronavic.yaml setono_sylius_pronavic: resource: "@SetonoSyliusPronavicPlugin/Resources/config/routes.yaml"
步骤 3:覆盖仓库
像在
- tests/Application/Entity
- tests/Application/Repository
- tests/Application/config/packages/_sylius.yaml
请求示例
先决条件
-
安装 Curl CLI 和 JQ
# OSX brew install curl brew install jq
-
加载默认 Sylius 固件套件
(cd tests/Application && bin/console sylius:fixtures:load default -n)
-
运行本地服务器
(cd tests/Application && symfony server:start --port=8000)
身份验证
SYLIUS_HOST=https://:8000 SYLIUS_ADMIN_API_ACCESS_TOKEN=$(curl $SYLIUS_HOST/api/oauth/v2/token \ --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) echo $SYLIUS_ADMIN_API_ACCESS_TOKEN
产品分页列表端点
所有产品:
curl "$SYLIUS_HOST/api/v1/pronavic/products?limit=3" \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN"
按产品或产品变体的 updatedAt
字段过滤:
(不要忘记正确编码 URL 参数: +
-> %2B
)
curl "$SYLIUS_HOST/api/v1/pronavic/products?fromDateTime=2019-03-07T23:38:32%2B02:00&limit=3" \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN" curl "$SYLIUS_HOST/api/v1/pronavic/products?toDateTime=2019-03-07T23:38:34%2B02:00&limit=3" \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN" curl "$SYLIUS_HOST/api/v1/pronavic/products?fromDateTime=2019-03-07T23:38:31%2B02:00&toDateTime=2019-03-07T23:38:34%2B02:00&limit=3" \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN"
挂起产品变体列表端点
curl "$SYLIUS_HOST/api/v1/pronavic/product-variants/on-hold?limit=3" \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN"
库存产品变体强制更新
更新变体的 onHand
而不检查 onHold
。
SYLIUS_VARIANT_CODE=000F_office_grey_jeans-variant-0 curl "$SYLIUS_HOST/api/v1/pronavic/product-variants/$SYLIUS_VARIANT_CODE/on-hand/force" \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -X PUT \ --data '{"onHand": 3}'