In short and in plain language
Shopware can work out special prices for some customers. It uses rules for that. But for the list sorted by price, it only uses up to 100 rules that fit one customer.
If more rules fit, the last ones are left out. Then the price on the item page is right. But in the list, the item is in the wrong place.
All rules that fit right now count. Rules for shipping and payment count too. A rule whose end date has passed no longer fits and does not count.
With the normal settings, the warning about this is not written to the log. So you check the list with a test account for each group of customers.
It is best to clean up the rules after each big sale. You can also set the limit higher. But then the list takes more time to load.
Here is how it can look: a logged-in dealer sees the dealer price on the product page, but in the listing sorted by price ascending the same item sits behind more expensive products. A cache problem is the obvious suspect, but it is not the only explanation. For the cheapest price that listings sort and filter by, Shopware by default only considers up to 100 rules that match in a customer's context (Shopware documentation). If more match, the rest are dropped from this calculation. The product page can then look correct while order and filters in the listing are wrong (Shopware documentation). Anyone who creates new rules for customer groups, shipping and payment for every campaign instead of reusing existing ones moves closer to this limit with every season. This article shows which rules actually count, why the warning is often missing from the log, how to check whether your shop is affected and when cleaning up pays off more than a higher limit. It is based on the Shopware documentation, the changelog and the source code of version 6.7.16.0 (GitHub).
Key takeaways
- For the cheapest price used in listing sorting and filters, Shopware considers up to 100 matching rules by default; if more match, the rest are ignored (Shopware documentation).
- Every rule that matches in the customer context counts, including shipping, payment and campaign rules. Expired date range rules no longer match and take up no slot (Shopware source code).
- The product page and the price on the listing card use all rules. Only the database query for sorting, price filter and price range cuts the list to the first 100 rules by priority (Shopware source code).
- In the documented default configuration the log file only records level error and above, so the warning about the limit is missing there (Shopware documentation). Measure on staging with test accounts per customer group.
- The limit can be raised via shopware.dal.max_rule_prices, but that makes every listing query more expensive (Shopware documentation). After Cyber Monday reduce overlaps first, then schedule inventory and spot check.
What the limit of 100 rules means
The Shopware documentation describes this behavior on a page of its own titled Price rule calculation limit. According to it, Shopware considers up to 100 matching rules by default when it calculates the cheapest price used for filters and sorting in the listing (Shopware documentation). If a customer's context matches more rules, Shopware ignores the rest for this calculation and writes a warning to the log. The documentation names the symptom explicitly: prices on the product page can be correct while order or filters in the listing are wrong.
The setting shopware.dal.max_rule_prices was introduced with version 6.4.17.0 (Shopware changelog). The entry is titled Prevent CheapestPrice query errors and states its purpose: the cheapest price query should no longer fail when many rules are active at once. Shopware considers the default value of 100 sufficient for most use cases (Shopware changelog). Shops with many rules active at once should restructure their rules, the entry continues. So the limit is not a glitch but a safeguard for the database query, and it deliberately leaves part of the rules out to achieve that.
The key word is matching. What counts is not every rule created in the Rule Builder, but the rules that match in the context of a particular visit: different ones for a guest than for a logged-in dealer, different ones with an empty cart than with a full one. A shop can therefore look fine to guests and sort incorrectly for a single customer group only. That is often exactly where the advanced prices sit, which Shopware ties to rules from the Rule Builder, including tier prices (Shopware documentation).
Why the issue shows up during campaign week
Why the product page is right and the listing is not
The source code explains why the two views diverge. Shopware calculates prices in several places, and only one of them knows the limit. The price calculation for the product page goes through the context's rules in order and takes the first one for which an advanced price is stored on the item (Shopware source code). The price shown on the listing card is resolved the same way: it also uses all rules of the context, without a cap (Shopware source code).
The database query that sorts and filters the listing works differently. It does not read the cheapest price from the fully calculated item but from a precomputed JSON field with one entry per rule and currency. The class CheapestPriceAccessorBuilder builds an expression from it that contains a separate part for every rule of the context and takes the first available value. Before doing so, it counts the rules: if the number exceeds max_rule_prices, it cuts the list at the limit, writes the warning and then only appends the default price (Shopware source code). If the first rule for which an item has an advanced price lies beyond the limit, the query finds no rule price for it and sorts it by the standard price.
| Place in the shop | Which rules count | Effect above the limit |
|---|---|---|
| Price on the product page | All matching rules, the first with an advanced price wins | No difference, the price is correct |
| Price on the listing card | All matching rules | No difference, the displayed price is correct |
| Sorting by price | Rules up to the limit, then the standard price | Item sits where its standard price belongs |
| Price filter and price range | Rules up to the limit, then the standard price | Item is missing from the filter or lands in the wrong range |
| Listing via OpenSearch in 6.7.16.0 | All matching rules | The cut does not apply on this path |
This produces the picture the documentation describes: the card shows the correct, lower dealer price but sits between items that are more expensive for this customer. The customer sees an order that contradicts their own prices. With the price filter the effect is less obvious: an item whose rule price falls within the selected range but whose standard price does not simply does not appear in the filtered listing. Anyone who only checks prices on the product page finds no error.
Shops whose listings run through OpenSearch are a special case. In the source code of version 6.7.16.0 this path passes the context's rules to the sorting script without cutting them (Shopware source code). The documentation page does not distinguish between the two paths. Whether a shop is affected is therefore not settled by the configuration alone but by a spot check with real customer accounts, as described further below.
Which rules count
The documentation talks about rules that match in a customer's context. In the source code these are all rules that are loaded when the context is built and whose conditions are met (Shopware source code). What a rule is used for in the shop makes no difference. The exceptions are rules that Shopware has flagged as invalid or that have no stored evaluable conditions, as well as rules that Shopware assigns to the flow condition area (Shopware source code). Shipping, payment and campaign rules therefore count just like the rules behind advanced prices, and a rule that is not assigned anywhere also takes up a slot as long as its conditions match.
This shifts the focus: what matters is not the number of price rules but the number of rules that are true for a given visitor at the same time. Typical candidates for rules that match permanently or for entire groups of visitors:
- Customer group rules: a rule with the condition customer group is Standard customer group matches for every visitor in that group. The condition reads the customer group from the context, so for visitors who are not logged in it uses the sales channel's group (Shopware source code).
- Conditions without restriction: the Rule Builder offers the condition Always valid, which according to the documentation is always met (Shopware documentation). Conditions such as a cart value from zero work practically the same way.
- Shipping and payment rules: even the base data of the installation create a rule named
Cart >= 0and assign it as the availability rule of the Standard and Express shipping methods (Shopware source code). It matches for every cart. - Sales channel, currency, language: rules that only narrow down a sales channel or a currency match for every visitor of that channel or currency.
- Overlaps from campaigns: anyone who creates a separate rule for the same customer group for each campaign ends up with several rules with the same condition, all matching at the same time.
Which rules stay within the limit is decided by the order. The rule loader sorts by priority in descending order and, for equal priority, by the internal ID (Shopware source code). The cut happens at the end of that list, so rules with low priority drop out first. According to the documentation, the priority determines the order in which rules are applied when more than one matches (Shopware documentation). A dealer price rule with low priority is therefore the first candidate for the problem, even if it is the most important price rule in the shop.
Expired campaigns are not the cause
Finding the warning in the log
If a context exceeds the limit, Shopware writes a message at level warning. Its text states the configured limit twice, so with the default value it says 100 (Shopware source code). It is immediately followed by a message at level info that refers to dal.max_rule_prices, warns about a performance impact and recommends restructuring the rules so that fewer of them match at the same time. With the default value the warning looks like this:
app.WARNING: More than 100 rules are active, only the first 100 rules are considered for the cheapest price calculationSearching var/log and finding nothing is not proof yet. In the default configuration that the Shopware documentation shows for production, a handler of type fingers_crossed collects messages and only passes them on when an error occurs; the log file itself also only records level error and above (Shopware documentation). The same documentation describes the level warning as exceptional occurrences that are not errors (Shopware documentation). Exactly these messages do not reach the file with the default configuration. An empty search result there only means that nothing was logged.
# Only finds the warning if the log records level warning
grep -h "rules are active" var/log/*.log | tail -n 20There are two ways to measure reliably. The first is a staging environment with a copy of rules, prices and customer groups in which the log temporarily records level info and above. The second lies in the rule loader itself: for every matching rule it writes a message at level info with a running number, name and priority (Shopware source code). On staging, the highest number for a page request with a test account shows how many rules match in its context, and the list names them in exactly the order in which the limit cuts.
monolog:
handlers:
main:
type: fingers_crossed
action_level: info
handler: nested
nested:
type: rotating_file
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: infoAfter the measurement, restore the original file and clear the cache, otherwise the log keeps growing unchecked. Why a measuring mode must not stay on in production is covered in the article Debug mode in production. If you want to keep an eye on the warning permanently, add a separate handler with its own file for level warning and include that file in log monitoring; what thresholds and alerts look like for this is explained in the article Log monitoring and alerting.
Checking whether the listing is affected
The warning says that rules were cut, but not whether a rule with a price was hit. The actual proof comes from the listing itself. Because the product page and the card calculate correctly, a simple cross-check is enough: does the order of the displayed prices match the sorting?
- Create a test account without real customer data for each customer group with its own prices and log in with it.
- Pick a category that contains items with advanced prices for this group and sort by price ascending.
- Read the displayed prices on the cards from top to bottom. If a cheaper item sits behind a more expensive one, that is the finding.
- Set the price filter so that only an item's rule price falls inside, but not its standard price. If the item is missing, the filter is affected too.
- Repeat the same category with a filled cart and as a guest, because cart rules change the context.
- Record the result with date, customer group and category so the next run can compare.
For the cross-check, the logged-in state is what counts. The documentation explains that by default Shopware no longer delivers complete pages from the cache for logged-in customers or with a filled cart, because the context rules can differ per user (Shopware documentation). A test as a guest therefore checks a different context than the dealer's. If you have configured the HTTP cache differently for these cases, repeat the cross-check with a cleared cache as well; how cache and wrong prices are otherwise connected is covered in the article Stale cache in the shop.
The cross-check can be automated: one test account per customer group, a fixed list of categories and a comparison of whether the displayed prices rise in the order of the sorting. As an application-specific check, such a comparison fits into monitoring that takes the shop's business logic into account and does not just measure availability. It is important that the test accounts carry exactly the customer groups that have prices and that they do not trigger real orders.
Cleaning up the rule inventory
The more sustainable route is fewer rules that match at the same time. The documentation explicitly advises reducing unnecessary overlap between rules first (Shopware documentation). That requires an inventory: which rules exist, how they are prioritized and where they are used.
In the Administration, the rule overview in the Rule Builder has columns that are hidden in the default view and can be shown via the context menu. They count how often a rule is used for product prices, shipping methods, payment methods, promotions and flows (Shopware documentation). Rules cannot be deleted as long as they are assigned (Shopware documentation). For a shop with many rules, a database query is often faster, ideally on the staging copy:
-- Rules in the order in which Shopware loads them
SELECT LOWER(HEX(r.id)) AS rule_id,
r.name,
r.priority,
GROUP_CONCAT(DISTINCT rc.type ORDER BY rc.type SEPARATOR ', ') AS condition_types,
COUNT(DISTINCT pp.id) AS product_prices
FROM `rule` r
LEFT JOIN rule_condition rc ON rc.rule_id = r.id
LEFT JOIN product_price pp ON pp.rule_id = r.id
WHERE r.invalid = 0
GROUP BY r.id, r.name, r.priority
ORDER BY r.priority DESC, r.id;The list follows the order of the rule loader. Candidates for merging can be recognized by identical condition types with similar names, candidates for a higher priority by rules with many product prices far down the list. Condition types such as customerCustomerGroup, salesChannel or alwaysValid point to rules that match for entire groups of visitors (Shopware source code). A second query finds expired date range rules:
-- Candidates for review, not a delete list
SELECT r.name,
JSON_UNQUOTE(JSON_EXTRACT(rc.value, '$.toDate')) AS to_date
FROM rule_condition rc
JOIN `rule` r ON r.id = rc.rule_id
WHERE rc.type = 'dateRange'
AND JSON_UNQUOTE(JSON_EXTRACT(rc.value, '$.toDate')) < DATE_FORMAT(NOW(), '%Y-%m-%dT%H:%i:%s')
ORDER BY to_date;These rules do not count toward the limit, but they clutter the inventory. If the date range condition is only one of several alternatives in the rule, the rule can still match; the list is therefore a starting point for review. If an expired rule is needed again next year, a new period in the same rule is usually better than yet another rule.
- Merge rules with the same condition into one and move the assignments over.
- Reuse one rule with a new period for recurring campaigns instead of creating a new one every year.
- Reduce helper rules for shipping and payment that match on nearly every visit to a few shared rules.
- Delete unassigned rules, because they also take up a slot as long as their conditions match.
- Prioritize price rules for customer groups with their own prices so that they sit ahead of pure helper rules.
- Apply every change on staging first and repeat the cross-check in the listing.
Priorities require care. They determine not only which rules stay within the limit but also which advanced price applies when several price rules match for an item: the price calculation takes the first rule in the order for which a price is stored (Shopware source code). Shifting priorities can therefore change the prices of individual customers. A comparison of prices per test account before and after the change belongs to every restructuring, ideally in a staging environment with current data.
Raising the limit and what it costs
If cleaning up is not enough, the limit can be raised. The documentation names the file config/packages/prod/shopware.yaml for this and shows the value 200 as an example (Shopware documentation):
shopware:
dal:
max_rule_prices: 200The same documentation states the cost: a higher limit makes listing queries more expensive, and performance and logs should be monitored after the change (Shopware documentation). The changelog puts it more bluntly and speaks of a negative impact on the shop's performance (Shopware changelog). The source code shows why: for every rule considered, Shopware adds a separate expression to the query that reads the JSON field, rounds and converts. If the customer's currency is not the default currency, another expression for the conversion is added per rule (Shopware source code). This affects every sort, every price filter and the calculation of the price range. A limit twice as high therefore allows up to twice as many of these expressions in each of these queries.
Before the limit goes up, a measurement before and after belongs in the plan: response times of category pages with a logged-in test account, the database's slow query log and the load at peak times. How we find such queries during operation is described on the page on performance maintenance. The change itself is a configuration change followed by a cache clear. During a change freeze before peak season it therefore goes through the exception process and not casually into campaign week.
| Route | Effect | Side effect |
|---|---|---|
| Reduce overlaps | Fewer rules match at the same time, the limit is reached less often | Assignments have to be moved |
| Order priorities | Price rules stay within the limit | Can change which advanced price applies |
| Raise the limit | More rules count for sorting and filters | More expensive listing queries, measurement required |
| Only observe | No intervention during the campaign | Wrong order stays visible until fixed |
A fixed item in the maintenance plan after Cyber Monday
After Cyber Monday is a good time for the inventory. The campaign is over, the team still knows which rules were created for it, and there is time to sort out the inventory calmly before the next campaign. As a fixed item in the maintenance plan it looks like this:
- Query the rule inventory and compare it with the state after the last campaign.
- Review expired date range rules, mark reusable ones for next season and delete the rest after checking their assignments.
- Merge rules with identical conditions and remove unassigned rules.
- On staging, count how many rules match with test accounts per customer group and repeat the cross-check in the listing.
- Record the result, the number of matching rules per test account and the configured limit in the maintenance log.
- For the next campaign, create rules with a period that stop matching on their own after the end date instead of rules that have to be switched off by hand.
The check fits in with the other tasks after a campaign: closing discount codes, as described in the article Discount codes in Black Week, and setting the year-end backups, as described in the article Year-end backup in the shop. The built-in Shopware system check does not check the rule limit; the cross-check in the listing remains a separate task in the maintenance plan.
What we take on in Shopware maintenance
On request we add the rule inventory as a fixed item after major campaigns to Shopware maintenance: we evaluate the rules by priority and assignment, merge overlaps on staging and check the listing with test accounts per customer group before a change goes live. If the limit is raised, we measure the listing queries before and after. In monitoring we analyze application logs for critical patterns; the warning about the rule limit can be added there as a pattern of its own once the log records it. Which response times apply is governed by the SLA maintenance contract.
Sources
Cart >= 0, that matches for every cart (Shopware source code).Related Articles
Cleaning Up Unused Shop Media: Storage and Backups
Shopware removes unused media with media:delete-unused. How the dry run, grace period and backups fit together, and which images the cleanup run misses.
Debug Mode in Production: Checking Profiler and Error Pages
After a hotfix, debug mode often stays on. What strangers see on error pages and in the profiler, and how to check Shopware and WordPress after each change.
Shopware system check: what system:check reports and misses
Shopware ships its own system check, system:check. What its exit codes, contexts and HTTP endpoint report, what it cannot see and how to evaluate it safely.