Redirect 如何将禁用的产品重定向到prestashop 1.6中的类别
在后台编辑产品时 禁用产品后,可以将其重定向到其他产品。但我试图将其重定向到一个类别。 当产品被选择为关闭(未激活)时 如果选择301或302重定向 及 如果相关产品字段为空, 重定向到默认类别(在301或302中) 否则 至所选产品(作为标准) 我写了这段代码(前面),但没有工作,请帮忙Redirect 如何将禁用的产品重定向到prestashop 1.6中的类别,redirect,overriding,prestashop,prestashop-1.6,Redirect,Overriding,Prestashop,Prestashop 1.6,在后台编辑产品时 禁用产品后,可以将其重定向到其他产品。但我试图将其重定向到一个类别。 当产品被选择为关闭(未激活)时 如果选择301或302重定向 及 如果相关产品字段为空, 重定向到默认类别(在301或302中) 否则 至所选产品(作为标准) 我写了这段代码(前面),但没有工作,请帮忙 class ProductController extends ProductControllerCore { public function initContent() {
class ProductController extends ProductControllerCore
{
public function initContent()
{
if (!$this->product->active)
{
if (Tools::getValue('adtoken') == Tools::getAdminToken('AdminProducts'.(int)Tab::getIdFromClassName('AdminProducts').(int)Tools::getValue('id_employee')) && $this->product->isAssociatedToShop()) {
$this->context->smarty->assign('adminActionDisplay', true);
}
else
{
$this->context->smarty->assign('adminActionDisplay', false);
if ($this->product->id_product_redirected == $this->product->id) {
$this->product->redirect_type = '404';
}
switch ($this->product->redirect_type)
{
case '301':
header('HTTP/1.1 301 Moved Permanently');
if (!$this->product->id_product_redirected)
{header('Location: '.$this->context->link->getCategoryLink($this->product->id_category_default));}
else
{header('Location: '.$this->context->link->getProductLink($this->product->id_product_redirected));}
exit;
break;
case '302':
header('HTTP/1.1 302 Moved Temporarily');
header('Cache-Control: no-cache');
if (!$this->product->id_product_redirected)
{header('Location: '.$this->context->link->getCategoryLink($this->product->id_category_default));}
else
{header('Location: '.$this->context->link->getProductLink($this->product->id_product_redirected));}
exit;
break;
case '404':
default:
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
$this->errors[] = Tools::displayError('This product is no longer available.');
break;
}
}
}
}
}
是否删除了class_index.php?是的,删除了class_index在该函数的开头添加一个跟踪,以检查是否执行了该代码。