PHP code example of neta-io / shopware-sdk

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

    

neta-io / 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();
    
    // Fetch one article by id
    $article = $client->getArticleQuery()->findOne(1);
    $article->getName();
    $article->getDescription();
    $article->get('mainDetail.id'); // Nested fields
    $article->get('customField');
    
    // Create an article
    $article = new Article();
    $article->setName("John product doe");
    $article->setDescription("Lorem ipsum");
    // ... <- more setters are        'direction' => \Neta\Shopware\SDK\Util\Constants::ORDER_ASC
            ]
        ],
        'filter' => [
            [
                'property' => 'name',
                'expression' => 'LIKE',
                'value' => '%' . $term . '%'
            ],
            [
                'operator' => 'AND',
                'property' => 'number',
                'expression' => '>',
                'value' => '500'
            ]
        ]
    ]);