1. Go to this page and download the library: Download smalot/magento-client 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/ */
smalot / magento-client example snippets
// Include composer's autoloader mecanism
d/shop-folder/';
$apiUser = 'username';
$apiKey = 'xxxxxxxxxxxxxxxxxxx';
// Create remote adapter which wrap soapclient
$adapter = new \Smalot\Magento\RemoteAdapter($path, $apiUser, $apiKey);
// Call any module's class
$categoryManager = new \Smalot\Magento\Catalog\Category($adapter);
$tree = $categoryManager->getTree()->execute();
var_dump($tree);
// Include composer's autoloader mecanism
d/shop-folder/';
$apiUser = 'username';
$apiKey = 'xxxxxxxxxxxxxxxxxxx';
// Create remote adapter which wrap soapclient
$adapter = new \Smalot\Magento\RemoteAdapter($path, $apiUser, $apiKey);
// Build the queue for multicall
$queue = new \Smalot\Magento\MultiCallQueue($adapter);
// Call any module's class
$productManager = new \Smalot\Magento\Catalog\Product($adapter);
$productManager->getInfo(10)->addToQueue($queue);
$productManager->getInfo(11)->addToQueue($queue);
$productManager->getInfo(12)->addToQueue($queue);
// Request in one multicall information of 3 products (#10, #11, #12)
$products = $queue->execute();
var_dump($products);
// Include composer's autoloader mecanism
d/shop-folder/';
$apiUser = 'username';
$apiKey = 'xxxxxxxxxxxxxxxxxxx';
// Create remote adapter which wrap soapclient
$adapter = new \Smalot\Magento\RemoteAdapter($path, $apiUser, $apiKey);
// Build the queue for multicall
$queue = new \Smalot\Magento\MultiCallQueue($adapter);
// Local catalog adapter
$localAdapter = new LocalAdapter(....);
// Store categories
$categoryManager = new \Smalot\Magento\Catalog\Category($adapter);
$categoryManager->getTree()->addToQueue($queue, array($localAdapter, 'updateCategories'));
// Store products into local catalog
$productManager = new \Smalot\Magento\Catalog\Product($adapter);
$productManager->getInfo(10)->addToQueue($queue, array($localAdapter, 'updateProduct'));
$productManager->getInfo(11)->addToQueue($queue, array($localAdapter, 'updateProduct'));
$productManager->getInfo(12)->addToQueue($queue, array($localAdapter, 'updateProduct'));
// Update local catalog
$products = $queue->execute();