shopify-php-sdk
An easy to use Shopify PHP SDK., (*1)
, (*2)
Installation
Composer
composer require jeppos/shopify-php-sdk
Usage
Create a private app using the instructions found on Shopify's own documentation, to generate the required credentials., (*3)
<?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');
Properties
The ShopifySDK class has the following properties,, (*4)
Examples
Fetch single product
// Get a Product class
$product = $shopifySDK->products->getOne(123);
// Display the product title
echo $product->getTitle();
Fetch a list of custom collections
// 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;
}
Create a product
$product = new Product();
$product->setTitle('My new product');
$shopifySDK->products->createOne($product);