Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getBackendListQuery example
/** @var array $filter */
$filter
=
$this
->
Request
(
)
->
getParam
(
'filter',
[
]
)
;
$node
=
(int)
$this
->
Request
(
)
->
getParam
(
'node'
)
;
$preselectedNodes
=
$this
->
Request
(
)
->
getParam
(
'preselected'
)
;
if
(
empty
(
$filter
)
)
{
$node
= !
empty
(
$node
)
?
$node
: 1;
$filter
[
]
=
[
'property' => 'c.parentId', 'value' =>
$node
]
;
}
$query
=
$this
->
getRepository
(
)
->
getBackendListQuery
(
$filter
,
$this
->
Request
(
)
->
getParam
(
'sort',
[
]
)
,
$this
->
Request
(
)
->
getParam
(
'limit'
)
,
$this
->
Request
(
)
->
getParam
(
'start'
)
)
->
getQuery
(
)
;
$count
=
$this
->em->
getQueryCount
(
$query
)
;
$data
=
$query
->
getArrayResult
(
)
;
foreach
(
$data
as
$key
=>
$category
)
{
/** @var array $filter */
$filter
=
$this
->
Request
(
)
->
getParam
(
'filter',
[
]
)
;
$query
=
$this
->
getCategoryRepository
(
)
->
getBlogCategoriesByParentQuery
(
$categoryId
)
;
$blogCategories
=
$query
->
getArrayResult
(
)
;
$blogCategoryIds
=
$this
->
getBlogCategoryListIds
(
$blogCategories
)
;
$blogCategoryIds
[
]
=
$categoryId
;
$repository
=
$this
->
getRepository
(
)
;
$dataQuery
=
$repository
->
getBackendListQuery
(
$blogCategoryIds
,
$filter
,
$order
,
$offset
,
$limit
)
;
$totalCount
=
$this
->
getManager
(
)
->
getQueryCount
(
$dataQuery
)
;
$data
=
$dataQuery
->
getArrayResult
(
)
;
$this
->
View
(
)
->
assign
(
[
'success' => true, 'data' =>
$data
, 'totalCount' =>
$totalCount
]
)
;
}
catch
(
Exception
$e
)
{
$this
->
View
(
)
->
assign
(
[
'success' => false, 'errorMsg' =>
$e
->
getMessage
(
)
]
)
;
}
}
/** * Reads all known blog categories to show it in the category treepanel */