<?php
class CategoryController extends CategoryControllerCore
{
public function init()
{
// Get category ID
$id_category = (int)Tools::getValue('id_category');
if (!$id_category || !Validate::isUnsignedId($id_category)) {
$this->errors[] = Tools::displayError('Missing category ID');
}
// Instantiate category
$this->category = new Category($id_category, $this->context->language->id);
//parent::init();
FrontController::init();
// Check if the category is active and return 404 error if is disable.
//if (!$this->category->active || !Validate::isLoadedObject($this->category) || !$this->category->inShop() || !$this->category->isAssociatedToShop() || in_array($this->category->id, array(Configuration::get('PS_HOME_CATEGORY'), Configuration::get('PS_ROOT_CATEGORY')))) {
if (!$this->category->active || !Validate::isLoadedObject($this->category) || !$this->category->inShop() || !$this->category->isAssociatedToShop() ) {
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
$this->errors[] = Tools::displayError('Category not found');
} else
// Check if category can be accessible by current customer and return 403 if not
if (!$this->category->checkAccess($this->context->customer->id)) {
header('HTTP/1.1 403 Forbidden');
header('Status: 403 Forbidden');
$this->errors[] = Tools::displayError('You do not have access to this category.');
$this->customer_access = false;
}
}
/* а до 1.6.1.16 работал такой вариант: */
/* public function canonicalRedirection($canonicalURL = '')
{
if (Tools::getValue('live_edit'))
return;
if (!Validate::isLoadedObject($this->category) || !$this->category->inShop() || !$this->category->isAssociatedToShop())
{
$this->redirect_after = '404';
$this->redirect();
}
if (!Tools::getValue('noredirect') && Validate::isLoadedObject($this->category))
FrontController::canonicalRedirection($this->context->link->getCategoryLink($this->category));
// а было: parent::canonicalRedirection($this->context->link->getCategoryLink($this->category));
}
*/
}