Custom rule conditions
The plugin adds three rule conditions of its own and accepts a curated subset of Shopware’s stock conditions. Anything not on this page is silently skipped when a rule is evaluated for layout selection.
Plugin-specific conditions
Section titled “Plugin-specific conditions”Is homepage [P2Lab Layouts Assigner]
Section titled “Is homepage [P2Lab Layouts Assigner]”- Type id:
p2labCmsAssignRulesIsHomepageRule - Class:
Rule\IsHomepageRule - Scope: category pages only. Returns
falseon product and landing-page scopes.
True when the visitor is on the navigation root of the active sales channel — i.e. categoryId === salesChannel.navigationCategoryId. False on every subcategory, every product page, every landing page.
Field:
- Is homepage — boolean toggle.
Common pitfall: combining this with Sales Channel in an AND container. The combination matches only on the channel’s homepage. See the multi-sales-channel pitfall.
Item in category [P2Lab Layouts Assigner]
Section titled “Item in category [P2Lab Layouts Assigner]”- Type id:
p2labCmsAssignRulesInCategoryRule - Class:
Rule\InCategoryRule - Scope: product and category pages.
True when the product (or category being viewed) is directly assigned to one of the listed categories.
Fields:
- Operator —
is one of/is none of/is empty. - Categories — multi-select.
For a product, the check runs against product.categoryIds. For a category page, the check runs against [categoryId]. The condition does not look at the category tree — descendants of a listed category do not match. Use the next condition for tree-aware matching.
Item in category with children [P2Lab Layouts Assigner]
Section titled “Item in category with children [P2Lab Layouts Assigner]”- Type id:
p2labCmsAssignRulesInCategoryWithChildrenRule - Class:
Rule\InCategoryWithChildrenRule(extends the previous) - Scope: product and category pages.
True when the product (or category being viewed) is in any of the listed categories, OR in one of their descendants. The descendant check is done by looking up the Shopware category path (which stores the ancestor chain as |id1|id2|id3|).
Fields: same as Item in category.
Cost: one additional DB lookup per evaluation per category being checked. Prefer Item in category when descendant matching isn’t needed.
Shopware stock conditions — supported
Section titled “Shopware stock conditions — supported”The plugin’s ConditionNameEnum::CONDITIONS list explicitly allows the following stock Shopware conditions:
General
Section titled “General”- Sales Channel —
salesChannel - Date range —
dateRange - Day of week —
dayOfWeek - Language —
language - Time range —
timeRange - Currency —
currency - Always valid —
alwaysValid
Customer
Section titled “Customer”- Affiliate code, billing city / country / zip / state / street, campaign code, is company, age, created by admin, birthday, email, customer group, is active, is newsletter recipient, logged in, customer number, salutation, last name, custom field, default payment method, different addresses, tag, is guest, is new customer, number of reviews, order count, shipping city / country / zip / state / street, days since first login, days since last login, days since last order, order total amount.
(See Enum\ConditionNameEnum::CONDITIONS for the canonical list.)
Containers
Section titled “Containers”- AND container —
andContainer - OR container —
orContainer - All line items container —
allLineItemsContainer(substituted with the plugin’s ownMatchAllRule— see Replacement flow internals)
Shopware stock conditions — unsupported
Section titled “Shopware stock conditions — unsupported”Anything not in CONDITIONS or CONTAINERS is silently skipped. This includes most cart / line-item / shipping / payment conditions:
- Cart total, cart shipping cost, items in cart, line item promoted, line item with delivery date, line item required, line item taxonomy, line item promotion, etc.
- Shipping method, payment method, shipping country (cart-scoped variant), etc.
These are intentionally excluded — they target the checkout flow, where there’s an actual cart to inspect, not the page-load flow where the plugin runs.
The Layout assignment modal shows a status badge per rule indicating whether all, some, or none of its conditions are supported. See Layout assignment modal.
Adding your own
Section titled “Adding your own”The plugin doesn’t expose a public extension point for new conditions — you’d add them the same way Shopware does (register a Rule class plus its admin component) and then add the type id to ConditionNameEnum::CONDITIONS to enrol it in the matcher.
Related
Section titled “Related”- Rules and conditions — high-level guide.
- Replacement flow internals — how the matcher invokes them.