setono / sylius-lagersystem-plugin
Official Sylius plugin for the Lagersystem.dk system
Installs: 1 540
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 2
Type:sylius-plugin
Requires
- php: ^7.2
- sylius/sylius: ^1.7
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.2
- 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
- korbeil/phpstan-generic-rules: ^0.2.4
- lakion/mink-debug-extension: ^1.2.3
- lchrusciel/api-test-case: ^4.0
- loevgaard/sylius-barcode-plugin: ^1.4
- matthiasnoback/symfony-config-test: ^4.0
- matthiasnoback/symfony-dependency-injection-test: ^4.0
- phpspec/phpspec: ^6.1
- phpstan/phpstan: ^0.12
- phpstan/phpstan-doctrine: ^0.12
- phpstan/phpstan-strict-rules: ^0.12
- phpstan/phpstan-webmozart-assert: ^0.12
- phpunit/phpunit: ^8.0
- sensiolabs/security-checker: ^5.0
- sylius-labs/coding-standard: ^3.1
- symfony/browser-kit: ^3.4 || ^4.3 || ^5.0
- symfony/debug-bundle: ^3.4 || ^4.3 || ^5.0
- symfony/dotenv: ^4.3 || ^5.0
- symfony/intl: ^3.4 || ^4.3 || ^5.0
- symfony/web-profiler-bundle: ^4.3 || ^5.0
- symfony/web-server-bundle: ^4.3 || ^5.0
- thecodingmachine/phpstan-safe-rule: ^1.0
Suggests
- loevgaard/sylius-barcode-plugin: To render barcode at product variant endpoint
This package is auto-updated.
Last update: 2024-12-15 20:02:36 UTC
README
This is the official plugin for the Lagersystem.dk system.
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-lagersystem-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\SyliusLagersystemPlugin\SetonoSyliusLagersystemPlugin::class => ['all' => true], // ... ];
Install additional plugins (optional)
To render barcode for product variants at endpoints, install:
Step 2: Import routing and configs
Import routing
# config/routes/setono_sylius_lagersystem.yaml setono_sylius_lagersystem: resource: "@SetonoSyliusLagersystemPlugin/Resources/config/routes.yaml"
Import application config
# config/packages/setono_sylius_lagersystem.yaml imports: - { resource: "@SetonoSyliusLagersystemPlugin/Resources/config/app/config.yaml" }
Step 3: Override repositories
Like it was done at:
Notes
- We assume that product variant's shipping weight stored in kilos at database.
- Lagersystem API returns its weight in grams
- Product variants that are not tracked will have an
onHand
value of1
in the API response
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
Product variant list endpoint
curl "$SYLIUS_HOST/api/lagersystem/product-variants?locale=en_US&limit=3" \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN"
Product variant show endpoint
SYLIUS_SOME_PRODUCT_VARIANT_CODE=$(curl "$SYLIUS_HOST/api/lagersystem/product-variants?locale=en_US&limit=1" \ --show-error \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN" \ -H "Accept: application/json" | jq '.items[0].code' --raw-output) echo "Some product code: $SYLIUS_SOME_PRODUCT_VARIANT_CODE" curl "$SYLIUS_HOST/api/lagersystem/product-variants/$SYLIUS_SOME_PRODUCT_VARIANT_CODE?locale=en_US" \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN"
Order list enpoint
curl "$SYLIUS_HOST/api/lagersystem/orders?limit=3" \ -H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN"