1. Go to this page and download the library: Download jivochat/shopify-api 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/ */
namespace App\Providers;
use App;
use ShopifyApi\Manager;
use ShopifyApi\Models\Product;
use ShopifyApi\Providers\ShopifyServiceProvider as BaseServiceProvider;
/**
* Class ShopifyServiceProvider
*/
class ShopifyServiceProvider extends BaseServiceProvider
{
/**
* Register the application services.
*
* @return void
*/
public function register()
{
parent::register();
/** @var Manager $shopify */
$shopify = app('shopify');
$shopify->setApiCache(Product::class, function($client, $params = null) {
// No caching for collections.
if (is_array($params)) {
// Returning falsy will result in the default api behavior.
return null;
}
$key = "shopify_product_".((string) $params);
// Assuming you Cache::put($key, $product->getData()); elsewhere
// If the cache is empty, the resource will be fetched from the api
// as normal.
$data = Cache::get($key);
return $data ? new Product($client, $data) : null;
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.