This Flow package provides a programmable interface to the Sylius Shop admin API.
The following Endpoints are currently implemented, see the admin API documentation for details:
- Cart
- CartItem
- Checkout
- Country
- Customer
- Product
- ProductVariant
- Order
- User
- Zone
The installation is done with composer:
composer require punktde/sylius-api
- Create a new API user in Sylius.
- Configure URL and client credentials in your settings.
/**
* @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);
}
/**
* @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);
}