Skip to content

This package contains some basic functions you need to connect php applications with your OroCommerce system.

Notifications You must be signed in to change notification settings

XTAIN/oro-api-php

 
 

Repository files navigation

OroCommerce API PHP Client

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".

Latest Stable Version Total Downloads

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

About

This package contains some basic functions you need to connect php applications with your OroCommerce system.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%