PHP code example of signifly / shopify-php-sdk

1. Go to this page and download the library: Download signifly/shopify-php-sdk 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/ */

    

signifly / shopify-php-sdk example snippets


use Signifly\Shopify\Shopify;
use Signifly\Shopify\Profiles\CredentialsProfile;

$shopify = new Shopify(
    new CredentialsProfile(
        env('SHOPIFY_API_KEY'),
        env('SHOPIFY_PASSWORD'),
        env('SHOPIFY_DOMAIN'),
        env('SHOPIFY_API_VERSION')
    )
);

// Retrieve a list of products
$shopify->products()->all(); // returns a collection of ProductResource

// Count all products
$shopify->products()->count();

// Find a product
$resource = $shopify->products()->find($id); // returns a ProductResource

// Update a product
$shopify->products()->update($id, $data); // returns a ProductResource

// Delete a product
$shopify->products()->destroy($id);

$shopify->products()->all([
    'page' => 1,
    'limit' => 250,
]);

// returns a collection of ProductResource

$shopify->products()->count(); // returns an integer

$shopify->products()->find(123456789); // returns a ProductResource

$shopify->products()->create([
    'title' => 'Burton Custom Freestyle 151',
    'body_html' => '<strong>Good snowboard!</strong>',
    'vendor' => 'Burton',
    'product_type' => 'Snowboard',
    'tags' => 'Barnes & Noble, John\'s Fav, "Big Air"',
]);

// returns a ProductResource

$shopify->products()->update(123456789, [
    'title' => 'An updated title',
]);

// returns a ProductResource

$shopify->products()->destroy(123456789); // returns void
bash
$ composer