$blogArticleId =
(int) $this->
Request()->
getQuery('blogArticle'
);
if (empty($blogArticleId)) { throw new Enlight_Controller_Exception('Missing necessary parameter "blogArticle"', Enlight_Controller_Exception::PROPERTY_NOT_FOUND
);
} $shop =
$this->
get('shop'
);
$blogArticleQuery =
$this->
getRepository()->
getDetailQuery($blogArticleId,
$shop->
getId());
$blogArticleData =
$blogArticleQuery->
getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY
);
$translation =
$this->
get(Shopware_Components_Translation::
class)->
readWithFallback($shop->
getId(),
$shop->
getFallback() ?
$shop->
getFallback()->
getId() : null, 'blog',
$blogArticleId);
$blogArticleData =
array_merge($blogArticleData ??
[],
$translation ??
[]);
// Redirect if the blog item is not available
if (empty($blogArticleData) ||
empty($blogArticleData['active'
])) { throw new Enlight_Controller_Exception(sprintf('Blog article with id %d not found or inactive',
$blogArticleId), 404
);
} // Redirect if category is not available, inactive or external
/** @var Category|null $category */
$category =
$this->
getCategoryRepository()->
find($blogArticleData['categoryId'
]);
if ($category === null || !
$category->
getActive()) {