docs(storefront): use ProductListingCollectSortingEvent for runtime sortings - #2479
docs(storefront): use ProductListingCollectSortingEvent for runtime sortings#2479Vin Le (vienthuong) wants to merge 2 commits into
Conversation
Developer Docs healthcheckStatus: Completed with |
📢 Developer Announcement RecommendationRecommendation: ❌ No Announcement Recommended No developer announcement signals were detected.
|
There was a problem hiding this comment.
Pull request overview
Updates the Shopware 6 storefront guide for adding custom product-listing sortings at runtime to use the newer ProductListingCollectSortingEvent, fixing the documented recipe that no longer applies sortings correctly since the sorting resolution now happens before ProductListingCriteriaEvent is dispatched.
Changes:
- Switches the recipe from
ProductListingCriteriaEvent(+ priority workaround) toProductListingCollectSortingEvent. - Updates the example code to add the sorting via
$event->getSortings()->add(...)and removes the unusedProductSortingCollectionimport. - Adds a note about availability since Shopware
6.7.15.0and explains the behavior on earlier versions.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
6ba19bb to
cc6a11a
Compare
Micha Hobert (Isengo1989)
left a comment
There was a problem hiding this comment.
Thank you for the PR Vin Le (@vienthuong) 👍
cb22427 to
c4678bb
Compare
Summary
The "Create individual sorting at runtime" recipe on the custom sorting guide does not work and has not worked since v6.6.
It tells you to add a
ProductSortingEntityto thesortingscriteria extension fromProductListingCriteriaEvent, subscribing withpriority => 500"to add your sorting before the default shopware logic applies". That was accurate while the sorting logic lived inProductListingFeaturesSubscriber, a listener on the same event. Since shopware/shopware@588c40d51c5 removed that subscriber,SortingListingProcessor::prepare()runs before the event is dispatched, so no listener priority can precede it. Following the guide today produces a sorting that appears in the Storefront dropdown but never orders the products — see shopware/shopware#6072.This updates the section to the new
ProductListingCollectSortingEvent, which is dispatched before the requested sorting is resolved:ProductListingCollectSortingEventinstead, without the priority workaround and without the staleProductSortingNotFoundExceptionwarning$event->getSortings()->add(...)instead of reading and re-writing thesortingscriteria extensionProductSortingCollectionimportRelated links
Checklist
PageRefreferences where relevant..gitbook.yamlif pages were moved, renamed, or deleted..wordlist.txt(and sorted it) if spellcheck flags new legitimate terms.Notes
The dependent-changes box is unchecked because shopware/shopware#16213 is still open. Please merge this only once that lands, so the guide does not document an event that does not exist yet.
No page was moved or renamed, so no redirect is needed. No wordlist entry is needed either: the new identifiers appear only inside code spans and code blocks, the same way
ProductListingCriteriaEventdid before.Verified locally with
avtodev/markdown-lint:v1.5againstmarkdown-style-config.yml— no findings.