Zangetsu Posted March 15, 2019 Share Posted March 15, 2019 Buenos días, estoy intentando insertar un nuevo tipo de redirección en la ficha de los productos pero cuando desactivo el producto y accedo a él me lleva a la página del error 404. He realizado los siguientes cambios: - En la tabla ps_orders y ps_orders_shop he añadido en el campo redirect_type el valor 410 - En el archivo informations.tpl he añadido el nuevo valor para el select (Desde el admin puedo guardar y recuperar el valor de este campo correctamente) - En el controllers/front/ProductController.php he añadido : switch ($this->product->redirect_type) { case '410': header('HTTP/1.1 410 Gone'); header('Status: 410 Gone'); $this->errors[] = Tools::displayError('Producto permanentemente eliminado.'); exit; case '301': header('HTTP/1.1 301 Moved Permanently'); 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'); 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; } ¿Alguien sabe si se tendría que realizar algún paso más? Gracias y un saludo!!! Link to comment Share on other sites More sharing options...
JGomezRoyal Posted October 12, 2022 Share Posted October 12, 2022 Hola Zangetsu. Conseguiste darle solución a esto problema? Gracias de antemano. Link to comment Share on other sites More sharing options...
JGomezRoyal Posted October 12, 2022 Share Posted October 12, 2022 Hola Zangetsu. Creo que lo que te ocurre está en las líneas anteriores a lo que muestras en ProductController.php. Hay un IF en el que siempre entra si el tipo de redirección no es 301 o 302: $this->product->redirect_type = ProductInterface::REDIRECT_TYPE_NOT_FOUND; Habría que añadir aquí un nuevo condicional si no, aun habiendo definido correctamente el case siempre entra en el 404. En este ejemplo de contribución a la nueva versión la quitan directamente: https://github.com/PrestaShop/PrestaShop/pull/27467/files#diff-faea250f832e6719c052be9ce3da4ea91c8b56ac2344a8659f096e5ef375e513R78 Saludos. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now