punktde / sylius-api
Sylius Shop Admin API Client for the Flow Framework
Installs: 12 980
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 6
Forks: 4
Open Issues: 1
Type:neos-package
Requires
- eljam/guzzle-jwt-middleware: ^0.7 || ^1.0
- neos/flow: ^5.0 || ^6.0 || ^7.0 || ^8.0
- symfony/property-access: ^4.1
- symfony/serializer: ^4.0
Requires (Dev)
- phpunit/phpunit: ^9.5
README
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); }