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

This package is auto-updated.

Last update: 2024-11-15 19:45:22 UTC


README

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"