setono/sylius-pronavic-plugin

Official Sylius plugin for Pronavic

This package's canonical repository appears to be gone and the package has been frozen as a result.

Installs: 2 934

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 2

Type:sylius-plugin


README

Latest Version Latest Unstable Version Software License Build Status

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:

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:

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}'