PHP code example of sition / shopware6-api-v1

1. Go to this page and download the library: Download sition/shopware6-api-v1 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/ */

    

sition / shopware6-api-v1 example snippets




use Sition\Shopware6\ShopwareClient;

$test = new ShopwareClient( 'http://www.shopwaredemo.nl', 'CLIENT_ID', 'CLIENT_SECRET' );

$response = $test->request( 'GET', 'product?filter[product.active]=1&filter[product.productNumber]=SWDEMO10007'); 

$body = json_decode($response->getBody()->getContents(), true);

var_dump($body);

$body = array(  "name" => "test cat" );

$response = $test->request('POST','category',$body);

$body = json_decode($response->getBody()->getContents(), true);

$jayParsedAry = [
    "total-count-mode" => 0,
    // "ids" => "640ae70d50704641af16592613aacc21",  // specifieke id.
    "page" => 1,
    "limit" => 25,
    "filter" => [
        [
            "type" => "equals",
            "field" => "stateId",
            "value" => "4c22d7bf1bcd40f1b74385fb28420056" // open orders
        ]
    ],
    "associations" => [
        "lineItems" => [
            "associations" => [
                "product" => [
                    "associations" => [
                        "tax" => [
                        ]
                    ]
                ]
            ]
        ],
        "currency" => [
        ],
        "orderCustomer" => [
        ],
        "language" => [
        ],
        "salesChannel" => [
        ],
        "addresses" => [
            "associations" => [
                "country" => [
                ],
                "countryState" => [
                ],
                "salutation" => [
                ]
            ]
        ],
        "deliveries" => [
            "associations" => [
                "shippingMethod" => [
                ],
                "shippingOrderAddress" => [
                    "associations" => [
                        "country" => [
                        ],
                        "countryState" => [
                        ],
                        "salutation" => [
                        ]
                    ],
                ]
            ]
        ],
        "transactions" => [
            "associations" => [
                "paymentMethod" => [
                ]
            ]
        ],
        "documents" => [
            "associations" => [
                "documentType" => [
                ]
            ]
        ],
        "tags" => [
        ]

    ],
    "aggregations" => [
        [
            "name" => "BillingAddress",
            "type" => "entity",
            "definition" => "order_address",
            "field" => "billingAddressId",
            // opmerking: CountrId is al opgehaald in Adresses array, evenals stateid en salutation.

        ],
    ]

];



$response = $test->request( 'POST', 'search/order', $jayParsedAry);
$body = json_decode($response->getBody()->getContents(), true);