Codewerk.
Get a quote
Home/Blog/The search criteria concept: Shopware's most underused feature

The search criteria concept: Shopware's most underused feature

Most integrations fetch far too much data because nobody read the criteria docs. Filters, aggregations and associations, explained by example.

Photo: free stock photography (Unsplash licence) — see imprint

One concept, three places

The same criteria object drives the DAL in PHP, the Admin API and the Store API. Learning it once pays off everywhere — and it is the difference between an integration that syncs in two minutes and one that times out.

Associations are opt-in for a reason

By default you get the entity, not its world. Ask for exactly the associations you render — and no more. 'Give me products with manufacturer, cover and prices' is fast; 'give me products with everything' will happily fetch half your database.

Aggregate instead of counting in PHP

If you are pulling 40,000 orders to count how many are unpaid, stop. An aggregation does it in the database and returns a number. This single habit removes most 'the export script kills the server' tickets.

Page it, always

No matter how small the catalogue is today, iterate with limit and offset — or better, with a cursor over a sorted key. Every integration that did not, eventually met a client with 300,000 products.

Key takeaways
  • Request only the associations you actually render.
  • Aggregate in the database, not in PHP.
  • Always paginate, even on a small catalogue.

We do this for a living — Shopware, Node.js, React, ERP integration and automation for B2B.

Talk to an engineer

// Keep reading

Related articles