PHP code example of erkineren / shopware-sdk

1. Go to this page and download the library: Download erkineren/shopware-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/ */

    

erkineren / shopware-sdk example snippets



    // Create a new client
    $client = new ShopwareClient('http://shopware.dev/api/', 'user', 'api_key');

    /**
     * set custom options for guzzle
     * the official guzzle documentation contains a list of valid options (http://docs.guzzlephp.org/en/latest/request-options.html) 
     */  
    //$client = new ShopwareClient('http://shopware.dev/api/', 'user', 'api_key', ['cert' => ['/path/server.pem']]);
    
    // Fetch all articles
    $articles = $client->getArticleQuery()->findAll();
    
    // NEW FEATURE Fetch all articles with filters
    $articles = $client->getArticleQuery()->findAll(
        [
            'filter' => [
                [
                    'property' => 'number',
                    'value' => 'SW0001'
                ]
            ]
        ]
    );
    
    // Fetch one article by id
    $article = $client->getArticleQuery()->findOne(1);
    
    // NEW FEATURE Fetch one article by articlenumber
    $article = $client->getArticleQuery()->findOne('SW0001', true);
    
    // Create an article
    $article = new Article();
    $article->setName("John product doe");
    $article->setDescription("Lorem ipsum");
    // ... <- more setters are