PHP code example of it-bens / shopware-sdk

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

    

it-bens / shopware-sdk example snippets


use Vin\ShopwareSdk\Context\ContextBuilder;
use Vin\ShopwareSdk\Auth\AccessTokenProvider;

$shopwareUrl = 'https://shopware.local';
/** @var AccessTokenProvider $accessTokenProvider */
$contextBuilder = new ContextBuilder($shopwareUrl, $accessTokenProvider);

$contextBuilder->withLanguageId('188208f3609a43d1a493698363fa3cce')
    ->withAdditionalHeader('indexing-behavior', 'disable-indexing');
$context = $contextBuilder->build();

use Vin\ShopwareSdk\Repository\RepositoryProviderInterface;
use Vin\ShopwareSdk\Data\Entity\v0000\Product\ProductDefinition;
use Vin\ShopwareSdk\Data\Criteria;
use Vin\ShopwareSdk\Data\Filter\EqualsFilter;

/** @var RepositoryProviderInterface $repositoryProvider */
$productRepository = $repositoryProvider->getRepository(ProductDefinition::class);

$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter('shippingFree', true));

$products = $productRepository->search($criteria); // the formerly