Skip to content

Rules and conditions

The plugin reuses Shopware’s Rule Builder for matching. There is no separate UI — every rule that exists under Settings → Rules is a candidate. You attach rules to a layout under Shopping Experiences → open layout → Layout assignment → Rules tab, and at request time the plugin evaluates them against the current page.

Only supported conditions are evaluated. The plugin ships a curated list — Shopware also includes many conditions designed for the cart / order context (cart total, items in cart, shipping cost) that have no meaning when picking a layout for a page that hasn’t been built yet. Those are silently ignored. The Layout assignment modal shows a status badge per rule:

  • All conditions defined in this rule are supported ✓ — the rule will evaluate exactly as you wrote it.
  • Not all conditions defined in this rule are supported ⚠ — supported conditions are evaluated, unsupported ones are skipped.
  • This rule does not contain any supported conditions and will be ignored ✗ — the rule cannot match. The plugin will not pick this layout.
  • Sales Channel — the most-used condition in this plugin. Picks the active sales channel.
  • Date range — restricts the layout to an [from, to] window. Great for seasonal homepages.
  • Day of week — Monday-only flash sale layout, weekend homepage, etc.
  • Time range — happy-hour layouts.
  • Language — pick by storefront language.
  • Currency — pick by storefront currency (often a proxy for country).
  • Always valid — placeholder, useful when prototyping.
  • Is homepage [P2Lab Layouts Assigner] — true only when the request resolves to the sales channel’s root navigation. See Custom rule conditions.
  • Item in category [P2Lab Layouts Assigner] — true when the product or category being viewed is in (or is itself) one of the listed categories.
  • Item in category with children [P2Lab Layouts Assigner] — same, but also matches descendant categories.

The plugin supports most customer-related conditions: customer group, login state, address fields, tags, age, custom fields, order count, days since last order, and more. See Custom rule conditions for the full list.

These conditions only meaningfully match when a customer is logged in. For an anonymous visitor, the value being checked is usually null and the condition returns false (or true, depending on the operator).

Standard Shopware containers: AND container, OR container, All line items container. AND-containers require all child conditions to match. OR-containers require at least one. All line items container is special — see Custom rule conditions for the caveat.

When you attach multiple rules to a layout, they are AND-ed: the layout is only a candidate when all of its rules match. Within a single rule, the standard container logic applies (AND containers AND-ed, OR containers OR-ed).

Typical patterns:

  • One rule per layout — keep one rule per layout for readability. Add multiple conditions to that rule via AND/OR containers.
  • Multiple rules per layout — useful when you want to AND together two existing rules that are reused elsewhere (e.g. “Sales Channel B” AND “B2B customer group”). No need to clone the conditions.

When more than one layout could match a single request, the plugin picks the first match when walking layouts ordered by rule.priority (lowest first). Set the priority of your rules under Settings → Rules → Edit rule → Priority if you need a tie-breaker.

The matcher walks layouts in pages of 100 and stops at the first match — see Performance for the hard limit on the number of candidate layouts evaluated per request.

  • Combining Is homepage with Sales Channel in an AND container. This only matches on the channel’s homepage — listings and other category pages will not match. Either split into two rules or drop Is homepage. See the multi-sales-channel recipe pitfall.
  • Forgetting to assign a base layout to the category. The plugin replaces a base — it does not create one. See How it works.
  • Empty Replacement types for the relevant page kind. The plugin will not look up alternatives at all. See Replacement types.
  • Rule with Always valid only — yes, this matches everywhere. It will replace every page of the right type. Use sales-channel scoping to bound it.