Skip to content

Repository files navigation

Sylius Lagersystem Plugin

Latest Version Latest Unstable Version Software License Build Status Quality Score

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 of 1 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"

About

This is the official Sylius plugin for the lagersystem.dk system

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages