$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()) { $location =
['controller' => 'index'
];
} // Redirect if blog's category is not a child of the current shop's category
$shopCategory =
Shopware()->
Shop()->
getCategory();
$isChild =
($shopCategory &&
$category) ?
$category->
isChildOf($shopCategory) : false;
if (!
$isChild) { $location =
['controller' => 'index'
];
} if (isset($location)) {