setono / sylius-pronavic-plugin
Official Sylius plugin for Pronavic
Installs: 2 934
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 2
Type:sylius-plugin
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
This is the official plugin for the Pronavic/Navision
Installation
Step 1: Install and enable 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-pronavic-plugin
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Add bundle to your config/bundles.php
:
<?php # config/bundles.php return [ // ... Setono\SyliusPronavicPlugin\SetonoSyliusPronavicPlugin::class => ['all' => true], // ... ];
Install additional plugins (optional)
To render additional fields at endpoints, install:
- https://github.com/loevgaard/SyliusBrandPlugin
- https://github.com/loevgaard/SyliusBarcodePlugin
- https://github.com/Setono/SyliusCostPricePlugin
Step 2: Import config and routing
Import application config & configure plugin
# .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)%'
Import routing
# config/routes/setono_sylius_pronavic.yaml setono_sylius_pronavic: resource: "@SetonoSyliusPronavicPlugin/Resources/config/routes.yaml"
Step 3: Override repositories
Like it was done at:
- tests/Application/Entity
- tests/Application/Repository
- tests/Application/config/packages/_sylius.yaml
Requests examples
Prerequisites
-
Install Curl CLI and JQ:
# OSX brew install curl brew install jq
-
Load default Sylius fixtures suite:
(cd tests/Application && bin/console sylius:fixtures:load default -n)
-
Run local server:
(cd tests/Application && symfony server:start --port=8000)
Auth
SYLIUS_HOST=http://localhost: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
Products paginated list endpoint
All products:
curl "$SYLIUS_HOST/api/v1/pronavic/products?limit=3" \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN"
Filtered by product's OR productVariant's updatedAt field:
(Don't forget to properly encode URL parameters: +
-> %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"
On hold product variants list enpoint
curl "$SYLIUS_HOST/api/v1/pronavic/product-variants/on-hold?limit=3" \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN"
On hand product variant force update
Updates variant's onHand
without checking 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}'