Markus Michalski FAQ

Empty Category Messages: Technical Details

Flow, plugin structure, custom fields, security and scope of the plugin: subscriber, service, Twig extension, template and lifecycle.

Deutsche Version

Back to overview

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