punktde/sylius-api

Last activity on 3 March 2021
  • 1
  • 2
  • 716
composer require punktde/sylius-api

Sylius Shop Admin API Client for the Flow Framework

Sylius Shop Admin API Client for the Flow Framework

Latest Stable Version Total Downloads

This Flow package provides a programmable interface to the Sylius Shop admin API.

Implemented Endpoints

The following Endpoints are currently implemented, see the admin API documentation for details:

  • Cart
  • CartItem
  • Checkout
  • Country
  • Customer
  • Product
  • ProductVariant
  • Order
  • User
  • Zone

Setup

Installation

The installation is done with composer:

composer require punktde/sylius-api

Configuration

  • Create a new API user in Sylius.
  • Configure URL and client credentials in your settings.

Usage Examples

Find a single product by its identifier

/**
 * @Flow\Inject
 * @var PunktDe\Sylius\Api\Resource\ProductResource
 */
protected $products;

/**
 * @param string $identifier
 * @return PunktDe\Sylius\Api\Dto\Product
 */
private function findOneProductByIdentifier(string $identifier): PunktDe\Sylius\Api\Dto\Product {
    $this->products->get($identifier);
}

Find an existing cart of the currrent logged in user

/**
 * @Flow\Inject
 * @var PunktDe\Sylius\Api\Resource\CartResource
 */
protected $cartResource;

/**
 * @return Cart|null
 */
private function retrieveExistingCartByCustomerMail(): ?PunktDe\Sylius\Api\Dto\Cart
{
    $cartCollection = $this->getCartResource()->getAll([
        'customer' => [
            'searchOption' => 'equal',
            'searchPhrase' => $this->getLoggedInUserEmail()
        ]
    ]);
    
    return current($cartCollection);
 }
The content of the readme is provided by Github
The same vendor provides 30 package(s).