punktde/sylius-api

Sylius Shop Admin API Client for the Flow Framework

Installs: 13 066

Dependents: 2

Suggesters: 0

Security: 0

Stars: 2

Watchers: 6

Forks: 4

Open Issues: 1

Type:neos-package

2.0.5 2022-12-08 12:11 UTC

README

Latest Stable Version Total Downloads

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

Version compatibility:

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 current 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);
     }