1. Go to this page and download the library: Download vin-sw/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/ */
vin-sw / shopware-sdk example snippets
$grantType = new PasswordGrantType($username, $password);
$grantType = new ClientCredentialsGrantType($clientId, $clientSecret);
$grantType = new RefreshTokenGrantType($refreshToken);
$adminClient = new AdminAuthenticator($grantType, $shopUrl);
$accessToken = $adminClient->fetchAccessToken();
$context = new Context($shopUrl, $accessToken);
// Create the repository for the entity
$productRepository = RepositoryFactory::create(ProductDefinition::ENTITY_NAME);
// Create the criteria
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter('shippingFree', true));
// Using this criteria and the context object that you create from authentication step, you can retrieving the result
$products = $productRepository->search($criteria, $context);
public function register(ShopRepository $repository): RegistrationResponse
{
$authenticator = new WebhookAuthenticator();
$app = new App(config('sas_app.app_name'), config('sas_app.app_secret'));
$response = $authenticator->register($app);
// Save the response the database...
$repository->createShop($response->getShop());
$confirmationUrl = route('sas.app.auth.confirmation');
return new RegistrationResponse($response, $confirmationUrl);
}
public function confirm(Request $request, ShopRepository $shopRepository): Response
{
$shopId = $request->request->get('shopId');
$shopSecret = $shopRepository->getSecretByShopId($shopId);
if (!WebhookAuthenticator::authenticatePostRequest($shopSecret)) {
return new Response(null, 401);
}
$shopRepository->updateAccessKeysForShop(
$shopId,
$request->request->get('apiKey'),
$request->request->get('secretKey')
);
return new Response();
}
namespace Vin\ShopwareSdk\Data\Response;
/**
* @see Shopware\Core\Framework\App\ActionButton
*/
new EmptyResponse();
new ReloadDataResponse($shopSecret);
new OpenNewTabResponse($shopSecret, 'http://shopware.test');
new NotificationResponse($shopSecret, 'Success!', NotificationResponse::SUCCESS);
new NotificationResponse($shopSecret, 'Error!', NotificationResponse::ERROR);
new OpenModalResponse($shopSecret, $iframeUrl, OpenModalResponse::LARGE_SIZE, true);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.