Logo Shopware Services

Shopware Services

Cộng đồng
alpham8
shopware-services

Dùng khi kết nối các dịch vụ backend của Shopware 6 — event subscriber, route Store API, mẫu trang trí dịch vụ bằng abstract class, tác vụ theo lịch và cấu hình plugin qua config.xml. Kích hoạt khi có EventSubscriberInterface, AbstractRoute, getDecorated, ScheduledTaskHandler hoặc biểu mẫu cấu hình plugin.

Add to TypingMind

Tổng quan

Nhà phát hànhalpham8
Kho mãagentic-webdev
Tên kỹ năngshopware-services
Sao
4
Bản fork
0
Tệp đi kèm
Chỉ có hướng dẫn
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được alpham8 công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Shopware Services trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/alpham8/agentic-webdev/tree/master/skills/shopware-services
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/alpham8/agentic-webdev.git /tmp/agentic-webdev
mkdir -p .claude/skills
cp -r /tmp/agentic-webdev/skills/shopware-services .claude/skills/shopware-services
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Shopware Services trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Shopware Services ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Shopware Services với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Shopware 6 — Services, Events and Configuration

PHP conventions come from rules/, not from this skill. See the shopware skill for the map of Shopware skills.

Event System

php
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\Content\Product\ProductEvents;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;

class MySubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            ProductEvents::PRODUCT_LOADED_EVENT => 'onProductsLoaded',
            'product.written'                   => 'onProductWritten',
        ];
    }

    public function onProductsLoaded(EntityLoadedEvent $event): void
    {
        foreach ($event->getEntities() as $product) {
            // ...
        }
    }
}

Register with tag kernel.event_subscriber in services.xml.

Important event families:

  • EntityWrittenEvent — after DAL writes (product.written, order.written, …)
  • SalesChannelContextCreatedEvent — storefront context built
  • PageLoadedEvent subtypes — page data assembled (add data here, not in controller)
  • Business events (flow builder) — order placed, customer registered, etc.

Versioned entities note: Some entities (orders, products) are versioned. Some events are only triggered on the "live" version.

Custom Events

Implement one of these interfaces:

InterfaceWhen to use
ShopwareEventBasic event with Context
ShopwareSalesChannelEventExtends ShopwareEvent, adds SalesChannelContext
SalesChannelAwareProvides getSalesChannelId()

Dispatch via injected EventDispatcherInterface (event_dispatcher service ID):

php
$this->eventDispatcher->dispatch(new MyCustomEvent($entity, $context));

Store API Route Pattern

Store API routes must follow the abstract/concrete/decorator pattern so third parties can decorate them.

php
// AbstractExampleRoute.php
abstract class AbstractExampleRoute
{
    abstract public function getDecorated(): AbstractExampleRoute;
    abstract public function load(Criteria $criteria, SalesChannelContext $context): ExampleRouteResponse;
}
php
// ExampleRoute.php
#[Route(defaults: [PlatformRequest::ATTRIBUTE_ROUTE_SCOPE => [StoreApiRouteScope::ID]])]
class ExampleRoute extends AbstractExampleRoute
{
    public function __construct(private readonly EntityRepository $repository) {}

    public function getDecorated(): AbstractExampleRoute
    {
        throw new DecorationPatternException(self::class);
    }

    #[Route(path: '/store-api/example', name: 'store-api.example.search', methods: ['GET', 'POST'], defaults: ['_entity' => 'swag_example'])]
    public function load(Criteria $criteria, SalesChannelContext $context): ExampleRouteResponse
    {
        return new ExampleRouteResponse($this->repository->search($criteria, $context->getContext()));
    }
}
php
// ExampleRouteResponse.php — extends StoreApiResponse
/** @property EntitySearchResult<ExampleCollection> $object */
class ExampleRouteResponse extends StoreApiResponse
{
    public function getExamples(): ExampleCollection
    {
        return $this->object->getEntities();
    }
}

The DecorationPatternException is thrown from getDecorated() when there is no decorator yet. Inject AbstractExampleRoute (not the concrete class) into dependents so decorators are used transparently.


Service Decoration Pattern

Full abstract base + concrete + decorator:

php
// AbstractExampleService.php
abstract class AbstractExampleService
{
    abstract public function getDecorated(): AbstractExampleService;
    abstract public function doSomething(): string;

    // Add new methods as non-abstract first, delegating to getDecorated()
    // Only make abstract after all decorators are updated
    public function doSomethingNew(): string
    {
        return $this->getDecorated()->doSomethingNew();
    }
}
php
// ExampleService.php — concrete (throws DecorationPatternException)
class ExampleService extends AbstractExampleService
{
    public function getDecorated(): AbstractExampleService
    {
        throw new DecorationPatternException(self::class);
    }

    public function doSomething(): string { return 'original'; }
}
php
// ExampleServiceDecorator.php
class ExampleServiceDecorator extends AbstractExampleService
{
    public function __construct(private readonly AbstractExampleService $decorated) {}

    public function getDecorated(): AbstractExampleService
    {
        return $this->decorated;
    }

    public function doSomething(): string
    {
        return $this->decorated->doSomething() . ' decorated';
    }
}

DI registration (services.php):

php
$services->set(ExampleServiceDecorator::class)
    ->decorate(ExampleService::class)
    ->args([service('.inner')]);

Tag inheritance pitfall: Decorating a service with kernel.event_subscriber automatically inherits that tag. Your decorator must then also implement EventSubscriberInterface. inherit-tags="false" is not valid XML in Symfony's schema. Solution: do not decorate event-subscriber-tagged services; use a separate subscriber instead.


Plugin Configuration (config.xml)

Creates a settings form in the Administration without custom Vue components.

xml
<!-- src/Resources/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/System/SystemConfig/Schema/config.xsd">

    <card>
        <title>Basic Configuration</title>
        <title lang="de-DE">Grundeinstellungen</title>

        <input-field>
            <name>myTextValue</name>
            <label>Label EN</label>
            <label lang="de-DE">Label DE</label>
            <helpText>Help text EN</helpText>
            <defaultValue>default</defaultValue>
        </input-field>

        <input-field type="single-select">
            <name>mailMethod</name>
            <options>
                <option><id>smtp</id><name>SMTP</name></option>
                <option><id>pop3</id><name>POP3</name></option>
            </options>
            <defaultValue>smtp</defaultValue>
            <label>Mail method</label>
        </input-field>

        <input-field type="bool">
            <name>enabled</name>
            <defaultValue>true</defaultValue>
            <label>Enabled</label>
        </input-field>
    </card>
</config>

Available field types: text, textarea, text-editor, url, password, int, float, bool, checkbox, datetime, colorpicker, single-select, multi-select, media-selection.

Reading config in PHP:

php
// Inject: Shopware\Core\System\SystemConfig\SystemConfigService
$this->systemConfigService->get('SwagExample.config.myTextValue');
$this->systemConfigService->getString('SwagExample.config.myTextValue');
$this->systemConfigService->getBool('SwagExample.config.enabled');
$this->systemConfigService->getInt('SwagExample.config.myIntValue');

Scheduled Tasks

php
// src/Service/ScheduledTask/ExampleTask.php
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask;

class ExampleTask extends ScheduledTask
{
    public static function getTaskName(): string { return 'swag.example_task'; }
    public static function getDefaultInterval(): int { return 300; } // seconds
}
php
// src/Service/ScheduledTask/ExampleTaskHandler.php — 6.6+ syntax
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler(handles: ExampleTask::class)]
class ExampleTaskHandler extends ScheduledTaskHandler
{
    public function run(): void
    {
        // task logic
    }
}

6.6 breaking change: getHandledMessages() static method removed from ScheduledTaskHandler. Use #[AsMessageHandler(handles: MyTask::class)] attribute.

Register both with tags (services.php):

php
$services->set(ExampleTask::class)->tag('shopware.scheduled.task');
$services->set(ExampleTaskHandler::class)->tag('messenger.message_handler');

Câu hỏi thường gặp

Kỹ năng AI Shopware Services làm được gì?

Dùng khi kết nối các dịch vụ backend của Shopware 6 — event subscriber, route Store API, mẫu trang trí dịch vụ bằng abstract class, tác vụ theo lịch và cấu hình plugin qua config.xml. Kích hoạt khi có EventSubscriberInterface, AbstractRoute, getDecorated, ScheduledTaskHandler hoặc biểu mẫu cấu hình plugin.

Vì sao nên dùng Shopware Services trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Shopware Services là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Shopware Services trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/alpham8/agentic-webdev/tree/master/skills/shopware-services. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Shopware Services?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Shopware Services với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Shopware Services với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Shopware Services có miễn phí không?

Kỹ năng này được alpham8 phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇