This is the official plugin for the Lagersystem.dk system.
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],
// ...
];
To render barcode for product variants at endpoints, install:
# config/routes/setono_sylius_lagersystem.yaml
setono_sylius_lagersystem:
resource: "@SetonoSyliusLagersystemPlugin/Resources/config/routes.yaml"
# config/packages/setono_sylius_lagersystem.yaml
imports:
- { resource: "@SetonoSyliusLagersystemPlugin/Resources/config/app/config.yaml" }
Like it was done at:
- 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
-
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)
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"[email protected] \
-d "password"=sylius-api | jq '.access_token' --raw-output)
echo $SYLIUS_ADMIN_API_ACCESS_TOKEN
curl "$SYLIUS_HOST/api/lagersystem/product-variants?locale=en_US&limit=3" \
-H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN"
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"
curl "$SYLIUS_HOST/api/lagersystem/orders?limit=3" \
-H "Authorization: Bearer $SYLIUS_ADMIN_API_ACCESS_TOKEN"