PHP code example of digitalprint / oro-api-php

1. Go to this page and download the library: Download digitalprint/oro-api-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digitalprint / oro-api-php example snippets


$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, ['

$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' => [ ... ],
  ],
  '

$names = $oro->products->get(100)->delete();

composer