Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getSystemDefaultSorting example
{
}
public
function
getDecorated
(
)
: AbstractListingProcessor
{
throw
new
DecorationPatternException
(
self::
class
)
;
}
public
function
prepare
(
Request
$request
, Criteria
$criteria
, SalesChannelContext
$context
)
: void
{
if
(
!
$request
->
get
(
'order'
)
)
{
$request
->request->
set
(
'order',
$this
->
getSystemDefaultSorting
(
$context
)
)
;
}
/** @var ProductSortingCollection $sortings */
$sortings
=
$criteria
->
getExtension
(
'sortings'
)
??
new
ProductSortingCollection
(
)
;
$sortings
->
merge
(
$this
->
getAvailableSortings
(
$request
,
$context
->
getContext
(
)
)
)
;
$currentSorting
=
$this
->
getCurrentSorting
(
$sortings
,
$request
)
;
$criteria
->
addSorting
(
...
$currentSorting
->
createDalSorting
(
)
)
;