[*] FO : improve SEO and http error code
This commit is contained in:
@@ -28,6 +28,7 @@ class CategoryControllerCore extends FrontController
|
||||
{
|
||||
public $php_self = 'category';
|
||||
protected $category;
|
||||
public $customer_access = true;
|
||||
|
||||
/**
|
||||
* Set default medias for this controller
|
||||
@@ -52,6 +53,7 @@ class CategoryControllerCore extends FrontController
|
||||
|
||||
public function canonicalRedirection($canonicalURL = '')
|
||||
{
|
||||
return ;
|
||||
if (!Validate::isLoadedObject($this->category) || !$this->category->inShop() || !$this->category->isAssociatedToShop())
|
||||
{
|
||||
$this->redirect_after = '404';
|
||||
@@ -76,14 +78,30 @@ class CategoryControllerCore extends FrontController
|
||||
$this->category = new Category($id_category, $this->context->language->id);
|
||||
|
||||
parent::init();
|
||||
|
||||
//check if the category is active and return 404 error if is disable.
|
||||
if (!$this->category->active)
|
||||
{
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
header('Status: 404 Not Found');
|
||||
}
|
||||
//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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
|
||||
$this->setTemplate(_PS_THEME_DIR_.'category.tpl');
|
||||
|
||||
if (!$this->customer_access)
|
||||
return;
|
||||
|
||||
if (isset($this->context->cookie->id_compare))
|
||||
$this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)$this->context->cookie->id_compare));
|
||||
@@ -111,9 +129,6 @@ class CategoryControllerCore extends FrontController
|
||||
'comparator_max_item' => (int)Configuration::get('PS_COMPARATOR_MAX_ITEM'),
|
||||
'suppliers' => Supplier::getSuppliers()
|
||||
));
|
||||
|
||||
|
||||
$this->setTemplate(_PS_THEME_DIR_.'category.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user