PHP code example of justbetter / laravel-magento-client
1. Go to this page and download the library: Download justbetter/laravel-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/ */
justbetter / laravel-magento-client example snippets
class Example
{
public function __construct(
protected \JustBetter\MagentoClient\Client\Magento $magento,
) {
}
public function retrieveProduct()
{
$response = $this->magento->get('products/1');
}
public function retrieveOrdersLazily()
{
$retrievedOrders = [];
$searchCriteria = \JustBetter\MagentoClient\Query\SearchCriteria::make()
->where('state', 'processing');
foreach ($this->magento->lazy('orders', $searchCriteria->get()) as $order) {
$retrievedOrders[] = $order['increment_id'];
}
}
public function multipleConnections()
{
$this->magento->connection('connection_one')->get('products/1');
$this->magento->connection('connection_two')->get('products/1');
}
}
'connection' => 'default',
'connections' => [
'default' => [
/* Base URL of Magento, for example: https://magento.test */
'base_url' => env('MAGENTO_BASE_URL'),
// Other settings
],
'another_connection' => [
'base_url' => env('ANOTHER_MAGENTO_BASE_URL'),
// Other settings
],
],