PHP code example of clickandmortar / magento-php-api-client
1. Go to this page and download the library: Download clickandmortar/magento-php-api-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/ */
clickandmortar / magento-php-api-client example snippets
lickAndMortar\MagentoApiClient\ClientBuilder;
use ClickAndMortar\MagentoApiClient\SearchCriteria\SearchCriteriaBuilder;
$clientBuilder = new ClientBuilder('https://magento.hostname.com/');
$client = $clientBuilder->buildAuthenticatedByOauth(
'<consumer-key>>',
'<consumer-secret>',
'<access-token>',
'<access-token-secret>'
);
// Fetch all products
$searchCriteriaBuilder = new SearchCriteriaBuilder();
$searchCriteriaBuilder->addFilter('type_id', 'simple');
$searchCriteriaBuilder->setPageSize(10);
foreach ($client->products->all($searchCriteriaBuilder->create()) as $product) {
echo $product->sku . ' - ' . $product->name . PHP_EOL;
}
// Fetch a single product
$product = $client->products->get('24-MB01');