// Redirect if blog's category is not a child of the current shop's category
$shopCategory =
$this->
get('shop'
)->
getCategory();
$category =
$this->
getCategoryRepository()->
findOneBy(['id' =>
$categoryId, 'active' => true
]);
$isChild =
($shopCategory &&
$category instanceof Category
) ?
$category->
isChildOf($shopCategory) : false;
if (!
$isChild) { throw new Enlight_Controller_Exception('Blog category missing, non-existent or invalid for the current shop', 404
);
} $perPage =
$this->
getPerPage($this->
Request(),
$this->container->
get('session'
));
$filter =
$this->
createFilter($filterDate,
$filterAuthor,
$filterTags);
// Start for Limit
$limitStart =
($page - 1
) *
$perPage;
$limitEnd =
$perPage;
// Get all blog articles
$query =
$this->
getCategoryRepository()->
getBlogCategoriesByParentQuery($categoryId);
$blogCategoryIds =
array_column($query->
getArrayResult(), 'id'
);
$blogCategoryIds[] =
$categoryId;
$shopId =
(int) $this->
get('shop'
)->
getId();
$blogArticlesQuery =
$this->
getRepository()->
getListQuery($blogCategoryIds,
$limitStart,
$limitEnd,
$filter,
$shopId);