Coder Social home page Coder Social logo

magento-client-php's Introduction

Magento Client Library For PHP

Build Status Coverage Status Total Downloads Latest Stable Version

Provides a client library to make REST and XMLRPC calls to a Magento instance.

Installation

Magento Client Library For PHP can be installed with Composer by adding it as a dependency to your project's composer.json file.

{
    "require": {
        "cpliakas/magento-client-php": "*"
    }
}

After running php composer.phar update on the command line, include the autoloader in your PHP scripts so that the SDK classes are made available.

require_once 'vendor/autoload.php';

Please refer to Composer's documentation for more detailed installation and usage instructions.

Usage

XMLRPC

The following example returns a list of products with SKUs that start with "123":

use Magento\Client\Xmlrpc\MagentoXmlrpcClient;

$client = MagentoXmlrpcClient::factory(array(
    'base_url' => 'http://magentohost',
    'api_user' => 'api.user',
    'api_key'  => 'some.private.key',
));

$filters = array(
    'sku' => array('like' => '123%'),
);

$result = $client->call('catalog_product.list', array($filters));

Rest

The following example returns a list of products:

use Magento\Client\Rest\MagentoRestClient;

$client = MagentoRestClient::factory(array(
    'base_url'        => 'http://magentohost',
    'consumer_key'    => 'abc123...',
    'consumer_secret' => 'def456...',
    'token'           => 'ghi789...',
    'token_secret'    => 'jkl012...',
));

$result = $client->get('/api/rest/products')->send()->json();

Refer to Guzzle's documentation for more information on sending requests to the server.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.