digitalprint / oro-api-php
OroCommerce API client for PHP applications.
v1.2.0
2022-04-07 09:39 UTC
Requires
- php: >=8.0.2
- ext-curl: *
- ext-json: *
- ext-openssl: *
- composer/ca-bundle: ^1.2
Requires (Dev)
- eloquent/liberator: ^2.0
- friendsofphp/php-cs-fixer: ^3.7
- guzzlehttp/guzzle: ^6.3 || ^7.0
- phpunit/phpunit: ^5.7 || ^6.5 || ^7.1 || ^8.5 || ^9.5
README
Thank you for using the "OroCommerce Api PHP Client" (Digitalprint_Oro-Api-PHP).
This package contains some basic functions you need to connect php applications with your OroCommerce system.
This package contains only a few endpoints. If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
1. Documentation
2. How to install
Install via composer (recommend)
Run the following command in your root folder:
composer require digitalprint/oro-api-php
3. User Guide
This package integrates OroCommerce API functions into your php application.
3.1 Getting started
Initializing the OroCommerce API client.
$oro = new \Digitalprint\Oro\Api\OroApiClient(); $oro->setApiEndpoint('YOUR_ORO_API_ENDPOINT'); $oro->setUser('YOUR_ORO_API_USER'); $res = $oro->authorization->create([ 'client_id' => 'YOUR_CLIENT_ID', 'client_secret' => 'YOUR_CLIENT_SECRET', ]); $oro->setAccessToken($res->access_token);
3.2 Product Examples
Get a single product
$product = $oro->products->get(100);
Get a single product with related entities included
$oro->products->get(1, ['include' => 'names,descriptions']);
Get a list of products
$products = $oro->products->page();
Get a list of featured products
$products = $oro->products->page(1, 10, ['featured' => true]);
Get names of a product
$names = $oro->products->get(100)->names();
Update an existing product
$product = $oro->products->get(100); $res = $product->update([ 'data' => [ 'meta' => [ 'update' => true, ], 'type' => 'products', 'id' => $product->id, 'attributes' => [ 'status' => ($product->attributes->status === 'disabled' ? "enabled" : "disabled"), ], ], ]);
Create a new product
$product = $oro->products->create([ 'data' => [ 'type' => 'products', 'attributes' => [ 'sku' => 'test-api-' . strtotime('now'), 'status' => 'enabled', 'variantFields' => [], 'productType' => 'simple', 'featured' => true, 'newArrival' => false, 'availability_date' => '2018-01-01', ], 'relationships' => [ ... ], ], 'included' => [ ... ], ]);
Delete a single product
$names = $oro->products->get(100)->delete();
3.3 More Examples
More examples are in the examples folder