An easy to use Shopify PHP SDK.
composer require jeppos/shopify-php-sdk
Create a private app using the instructions found on Shopify's own documentation, to generate the required credentials.
<?php
include __DIR__ . '/vendor/autoload.php';
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');
$shopifySDK = new \Jeppos\ShopifySDK\ShopifySDK('your-store-name.myshopify.com', 'api-key', 'api-secret');
The ShopifySDK class has the following properties,
- products - Returns an instance of ProductService
- collects - Returns an instance of CollectService
- customCollections - Returns an instance of CustomCollectionService
- productImages - Returns an instance of ProductImageService
- productVariants - Returns an instance of ProductVariantService
// Get a Product class
$product = $shopifySDK->products->getOne(123);
// Display the product title
echo $product->getTitle();
// Get an array of CustomCollection classes
$customCollections = $shopifySDK->customCollections->getList();
// Display the title of each custom collection on a new line
foreach ($customCollections as $customCollection) {
echo $customCollection->getTitle() . PHP_EOL;
}
$product = new Product();
$product->setTitle('My new product');
$shopifySDK->products->createOne($product);