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".
Run the following command in your root folder:
composer require digitalprint/oro-api-php
This package integrates OroCommerce API functions into your php application.
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);
$product = $oro->products->get(100);
$oro->products->get(1, ['include' => 'names,descriptions']);
$products = $oro->products->page();
$products = $oro->products->page(1, 10, ['featured' => true]);
$names = $oro->products->get(100)->names();
$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"),
],
],
]);
$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' => [ ... ],
]);
$names = $oro->products->get(100)->delete();
More examples are in the examples folder