heptacom/heptaconnect-package-shopware-6

HEPTAconnect 包,用于与 Shopware 6 API 一起工作

1.0.0-beta2 2023-05-21 03:32 UTC

This package is auto-updated.

Last update: 2024-08-29 00:24:57 UTC


README

这是 HEPTACOM 为中型和大企业提供解决方案的一部分。

描述

这个 HEPTAconnect 包主要是用于与 Shopware 6 API 进行通信。您可以使用它与 Shopware 6 门户结合使用。更多内容请参阅文档(特别是包设计决策)和示例部分

用法

安装

  1. composer require heptacom/heptaconnect-package-shopware-6
  2. 特定情况的使用指南
  3. 请参考以下示例

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',
//   …

系统要求

  • PHP 8.0 或更高版本

变更日志

请参阅附带的 CHANGELOG.md 文件,以获取完整的版本历史和发行说明。

ADR

请参阅架构决策记录,以了解影响此项目结构的决策。

其他开发要求

  • Make
  • 任何调试/覆盖率 PHP 扩展,如 xdebug 或 pcov
  • 一个运行的 Shopware 6 实例

贡献

感谢您考虑为这个包做出贡献!请在创建拉取请求后务必签署CLACLA assistant

贡献步骤

  1. 分支存储库
  2. git clone yourname/heptaconnect-package-shopware-6
  3. 在 master 分支上对您的更改
  4. 创建您的拉取请求

检查您的更改

  1. 将您的代码与 项目 ADR 进行比较
  2. 检查和修复代码风格 make cs-fix && make cs
  3. 为测试设置 Shopware 6 实例。查阅 dockware.io 获取 Shopware 6 开发实例
    • TEST_ADMIN_API_URLTEST_ADMIN_API_USERNAMETEST_ADMIN_API_PASSWORD 设置为指向您的 Shopware 6 实例
    • 可选地设置 TEST_STORE_API_URLTEST_STORE_API_ACCESS_KEY 指向您的 Shopware 6 实例。如果没有设置,将使用 Admin API 凭据创建数据
  4. 检查测试 make -e test
  5. 检查测试代码覆盖率是否相同或更高 make -e coverage
  6. 检查测试是否可以发现未来的问题 make -e infection

许可

版权所有 2020 HEPTACOM GmbH

本软件采用双重许可协议,受GNU Affero General Public License v3.0(“许可协议”)和专有许可协议的保护;除非遵守许可协议,否则不得使用此项目。您可以在https://spdx.org/licenses/AGPL-3.0-or-later.html获取AGPL许可证的副本。有关专有使用的更多信息,请访问我们的网站