Empty Category Messages: Technical Details
Flow, plugin structure, custom fields, security and scope of the plugin: subscriber, service, Twig extension, template and lifecycle.
Technical Details
Package and plugin class
| Property | Value |
|---|---|
| Composer package | mmd/sw67-empty-category |
| Plugin class | Mmd\EmptyCategory\MmdEmptyCategory |
| Technical plugin name | MmdEmptyCategory |
| Namespace | Mmd\EmptyCategory |
Flow
graph TD
A["Category page requested"] --> B["NavigationPageLoadedEvent"]
B --> C["CategoryPageSubscriber loads parent chain and media"]
C --> D["Listing template: block element_product_listing_col_empty"]
D --> E["Twig function mmd_empty_category_message"]
E --> F["EmptyCategoryMessageService resolves the message"]
F --> G{"Message found?"}
G -->|"Yes"| H["Render custom message"]
G -->|"No"| I["Shopware default message"]
Building blocks
| Class / file | Purpose |
|---|---|
Subscriber\CategoryPageSubscriber |
Listens to NavigationPageLoadedEvent. Loads the parent categories (up to 10) only when inheritance is enabled on the category. Loads the media of the images as soon as a message, image or inheritance is set |
Service\EmptyCategoryMessageService |
Resolves the message: own message, otherwise inheritance upwards, otherwise empty. The search covers at most 10 levels including the category itself, so at most 9 parent categories are reached. Sanitizes CSS classes and select values |
Service\EmptyCategoryMessage |
Immutable value object with message, image URL, CSS classes, size and alignments |
Twig\EmptyCategoryExtension |
Registers the Twig function mmd_empty_category_message |
views/storefront/component/product/listing.html.twig |
Overrides the block element_product_listing_col_empty |
app/storefront/src/scss/base.scss |
Styles for the plugin classes |
MmdEmptyCategory |
Creates the custom field set, completes it on update and removes it on uninstall |
Custom fields
The set mmd_empty_category is assigned to the category entity and contains the fields listed under Configuration. The values are stored in the customFields field of the category.
Scope of the plugin
| Area | Status |
|---|---|
| Plugin settings (config.xml) | none |
| Own routes and API endpoints | none |
| Own database tables and migrations | none |
| Admin modules and permissions (ACL) | none, the fields appear in the existing category editor |
| Scheduled tasks and commands | none |
| External requests | none |
| Snippets | mmd.emptyCategory.imageAlt (de-DE, en-GB) |
Security
- The message is output through the
sw_sanitizefilter. - CSS classes are reduced to letters, digits, hyphens, underscores and spaces.
- Select field values are checked against the allowed values, otherwise the default applies.
- The image is resolved via the media manager and its URL is escaped as an HTML attribute.
- There are no inline styles, so the plugin is compatible with a strict Content Security Policy.
- The plugin does not process personal data.