heptacom / heptaconnect-package-shopware-6
HEPTAconnect package to work with Shopware 6 APIs
Requires
- php: >=7.4
- ext-json: *
- ext-mbstring: *
- heptacom/heptaconnect-dataset-base: >=0.9.4 <0.10
- psr/container: >=1 <3
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- psr/simple-cache: @stable
- psr/simple-cache-implementation: *
- symfony/dependency-injection: ^4.4 || ^5.0
- symfony/polyfill-php80: *
Requires (Dev)
- ext-zip: *
- infection/infection: >=0.21
- nyholm/psr7: ^1.5
- php-http/curl-client: >=2 <3
- php-http/discovery: ^1.11
- phpunit/phpunit: >=9.3 <10
- symfony/cache: >=5.4 <7
- voku/simple-cache: >=4 <5
Suggests
- heptacom/heptaconnect-portal-base: Add ability to act as HEPTAconnect package for good integration into portals https://heptaconnect.io/
- symfony/cache: psr/simple-cache implementation, that is likely already in your project
- voku/simple-cache: psr/simple-cache implementation without further dependencies
Conflicts
- nikic/php-parser: 4.7.0
This package is auto-updated.
Last update: 2024-11-29 00:51:38 UTC
README
This is part of HEPTACOM solutions for medium and large enterprises.
Description
This HEPTAconnect package is all about communicating to Shopware 6 APIs. You can use it in combination with the Shopware 6 Portal. Read more in the documentation (especially the package design decision) and have a look into the examples section.
Usage
Installation
composer require heptacom/heptaconnect-package-shopware-6
- Use guide for specific situation:
- Follow examples below
AdminAPI - EntityClient
<?php use Heptacom\HeptaConnect\Package\Shopware6\EntitySearch\Contract\Aggregation\TermsAggregation; use Heptacom\HeptaConnect\Package\Shopware6\EntitySearch\Contract\Filter\EqualsFilter; use Heptacom\HeptaConnect\Package\Shopware6\Http\AdminApi\Utility\EntityClient; /** @var $entityClient EntityClient */ $propertyGroupId = $entityClient->create('property_group', [ 'name' => 'Color', 'sortingType' => 'position', 'displayType' => 'color', 'options' => [[ 'position' => 1, 'name' => 'Red', 'colorHexCode' => '#aa0000', ], [ 'position' => 2, 'name' => 'Green', 'colorHexCode' => '#00aa00', ], [ 'position' => 3, 'name' => 'Blue', 'colorHexCode' => '#0000aa', ]], ]); $colorNamesByName = $entityClient->groupFieldByField( 'property_group_option', 'colorHexCode', 'name', new EqualsFilter('group.id', $propertyGroupId) ); var_export($colorNamesByName); // array ( // '#0000aa' => 'Blue', // '#00aa00' => 'Green', // '#aa0000' => 'Red', // ) // paginates automatically foreach ($entityClient->iterate('product') as $product) { // … } $countryIsos = $entityClient->aggregate('country', new TermsAggregation('countries', 'iso'))->buckets->getKeys(); var_export($countryIsos->asArray()); // array ( // 0 => 'AD', // 1 => 'AE', // 2 => 'AF', // 3 => 'AG', // 4 => 'AI', // …
AdminAPI - ExtensionClient
<?php use Heptacom\HeptaConnect\Package\Shopware6\Http\AdminApi\Utility\ExtensionClient; /** @var $extensionClient ExtensionClient */ // remote updating security plugin $extensionClient->upload('/path/to/SwagSecurityPlatform.zip'); $extensionClient->refresh(); $extensionClient->update('SwagSecurityPlatform'); if (!$extensionClient->isInstalled('SwagSecurityPlatform')) { $extensionClient->install('SwagSecurityPlatform'); } if (!$extensionClient->isActive('SwagSecurityPlatform')) { $extensionClient->activate('SwagSecurityPlatform'); }
AdminAPI - GenericClient
<?php use Heptacom\HeptaConnect\Package\Shopware6\Http\AdminApi\Utility\GenericClient; /** @var $client GenericClient */ // low amount of parameters var_export($client->get('_info/version')); // array ( // 'version' => '6.4.20.0', // ) // query parameters var_export($client->get('_action/system-config', [ 'domain' => 'core.update', ])); // array ( // 'core.update.apiUri' => 'https://update-api.shopware.com', // 'core.update.channel' => 'stable', // 'core.update.code' => '', // ) // JSON body $client->post('_action/system-config', [ 'key' => 'value', ]); // header support $client->post('_action/order/00000000000000000000000000000000/state/complete', [], [], [ // do not run flows to silently update order state 'sw-skip-trigger-flow' => 1, ]);
StoreAPI - GenericClient
<?php use Heptacom\HeptaConnect\Package\Shopware6\Http\StoreApi\Utility\GenericClient; /** @var $client GenericClient */ // low amount of parameters var_export($client->get('context')['token']); // 12c9a85D538b4795877A95aC908987db // different methods var_export(\array_column($client->post('country')['data'], 'iso')); // array ( // 0 => 'AD', // 1 => 'AE', // 2 => 'AF', // 3 => 'AG', // 4 => 'AI', // …
System requirements
- PHP 8.0 or above
Changelog
See the attached CHANGELOG.md file for a complete version history and release notes.
ADR
See the Architecture Decision Records to understand decisions made, that influence the structure of this project.
Additional development requirements
- Make
- Any debugging/coverage php extension like xdebug or pcov
- A running Shopware 6 instance
Contributing
Thank you for considering contributing to this package! Be sure to sign the CLA after creating the pull request.
Steps to contribute
- Fork the repository
git clone yourname/heptaconnect-package-shopware-6
- Make your changes to master branch
- Create your Pull-Request
Check your changes
- Compare your code against the project ADRs
- Check and fix code style
make cs-fix && make cs
- Setup Shopware 6 instance for testing. Checkout dockware.io for a Shopware 6 development instance
- Set
TEST_ADMIN_API_URL
,TEST_ADMIN_API_USERNAME
,TEST_ADMIN_API_PASSWORD
to point to your Shopware 6 instance - Optionally set
TEST_STORE_API_URL
,TEST_STORE_API_ACCESS_KEY
to point to your Shopware 6 instance. If not set the Admin API credentials will be used to create the data
- Set
- Check tests
make -e test
- Check whether test code coverage is same or higher
make -e coverage
- Check whether tests can find future obscurities
make -e infection
License
Copyright 2020 HEPTACOM GmbH
Dual licensed under the GNU Affero General Public License v3.0 (the "License") and proprietary license; you may not use this project except in compliance with the License. You may obtain a copy of the AGPL License at https://spdx.org/licenses/AGPL-3.0-or-later.html. Contact us on our website for further information about proprietary usage.