Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
enrichCriteria example
$criteriaBuild
=
new
CriteriaBuilder
(
$this
->
getContainer
(
)
->
get
(
ProductDefinition::
class
)
)
;
$criteria
=
new
Criteria
(
)
;
$config
=
new
Config
(
[
'name',
]
,
[
]
,
[
]
)
;
$criteriaBuild
->
enrichCriteria
(
$config
,
$criteria
)
;
static
::
assertEmpty
(
$criteria
->
getAssociations
(
)
)
;
}
public
function
testAssociations
(
)
: void
{
$criteriaBuild
=
new
CriteriaBuilder
(
$this
->
getContainer
(
)
->
get
(
ProductDefinition::
class
)
)
;
$criteria
=
new
Criteria
(
)
;
$config
=
new
Config
(
[
$progress
=
$this
->importExportService->
getProgress
(
$this
->logEntity->
getId
(
)
,
$offset
)
;
if
(
$progress
->
isFinished
(
)
)
{
return
$progress
;
}
$config
= Config::
fromLog
(
$this
->logEntity
)
;
$criteriaBuilder
=
new
CriteriaBuilder
(
$this
->repository->
getDefinition
(
)
)
;
$criteria
=
$criteria
=== null ?
new
Criteria
(
)
:
clone
$criteria
;
$criteriaBuilder
->
enrichCriteria
(
$config
,
$criteria
)
;
$enrichEvent
=
new
EnrichExportCriteriaEvent
(
$criteria
,
$this
->logEntity
)
;
$this
->eventDispatcher->
dispatch
(
$enrichEvent
)
;
if
(
$criteria
->
getSorting
(
)
===
[
]
)
{
// default sorting
$criteria
->
addSorting
(
new
FieldSorting
(
'createdAt', FieldSorting::ASCENDING
)
)
;
}
$criteria
->
addSorting
(
new
FieldSorting
(
'id'
)
)
;
$criteria
->
setOffset
(
$offset
)
;