更新后“主页"类别页面不起作用 [英] 'Home' category page not working after update

查看:85
本文介绍了更新后“主页"类别页面不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

版本 1.4.1.4 的 prestashop 网站使用 category.php 文件用于类别页面.不幸的是,1.6.0.6 的更新删除了该文件,因为它已被视为已弃用.(CMS 更新后 URL 结构发生变化)

A prestashop website at version 1.4.1.4 was working with category.php file for category pages. The update to 1.6.0.6 unfortunatley deleted that file because it has been considered as deprecated. (URL structure changed after CMS update)

一个后果是 URL 结构的变化.

One consequence is the change in the URL structure.

来自:

url/category.php?id_category=6

url/category.php?id_category=6

到:

url/index.php?id_category=6&controller=category&id_lang=2

url/index.php?id_category=6&controller=category&id_lang=2

所以现在,第一个 URL 结构给出了 404.

So now, the first URL structure is giving 404.

问题:我们不知道为什么所有类别页面在新结构下都能正常工作,除了 Home(acceuil) 类别(所有网站类别的全局父类别)的页面.即使使用新结构,这个 home 类别页面也会给出 404.换句话说,以下网址不起作用:

The question: We don't know why all the category pages are working fine with the new strucure, except the page for Home(acceuil) category (the global parent category for all website categories). This home category page is giving 404 even with the new structure. In other words, the following url is not working:

url/index.php?id_category=1&controller=category&id_lang=2

url/index.php?id_category=1&controller=category&id_lang=2

如果我没猜错的话,Prestashop 默认给这个 home 类别赋予 id=1 吗?你的观点有什么问题?任何见解都非常感谢.

If I am not wrong, Prestashop gives id=1 by default to this home category? What is going wrong in your point of you? Any insights are highly appreciated.

根据 Prestashop-Developper.co 答案进行编辑

当我在 PhpMyAdmin 中检查我的数据库时:

When I checked my database in PhpMyAdmin:

从 1.4.1.4 更新到 1.6.0.6 后:

我既没有找到 id=0 的类别,也没有找到 id=2 的类别.我只找到 id=1 的类别 Home 和 id=104 的类别 Root.Root 是 Home 的父级,但 Home 的字段 is_root_category 设置为 1!!!!我真的什么都不懂.

I found neither a category with id=0 nor a category with id=2. I only find the category Home with id=1 and category Root with id=104. Root is parent of Home, but the field is_root_category for Home is set to 1!!!! I am really not understanding anything.

从 1.4.1.4 更新到 1.6.0.6 之前:

根本没有Root类别,也根本没有is_root_category字段.

There is no Root category at all, and there is no is_root_category field at all.

注意:这些观察是基于表:ps_category, ps_category_group, ps_category_product, ps_category_shop 在更新前后 = 1.4.1.4 到 1.6.0.6 之间.

Note: These observations are based on the tables : ps_category, ps_category_group, ps_category_product, ps_category_shop before and after updtate =between 1.4.1.4 to 1.6.0.6.

推荐答案

在 PrestaShop 1.6 中,Root &Home 类别总是返回 404(在 PS 1.5 中只有 Root 返回 404),如果您需要为 Home 类别更改它,您必须为 CategoryController 创建一个覆盖.

In PrestaShop 1.6 the Root & Home categories always return 404 (in PS 1.5 only Root returns 404), if you need to change that for Home category you must create an override for CategoryController.

请注意,在 PrestaShop 1.4 中,您有 id=1 的Home",从 1.5 开始,您有 id=1 的Root"和 id=2 的Home".查找 Home 类别的 ID.

Note that in PrestaShop 1.4 you have "Home" with id=1 and since 1.5 you have "Root" with id=1 and "Home" with id=2. Find the ID of the Home category.

在/override/controllers/front/中创建文件CategoryController.php,内容如下:

Create file CategoryController.php in /override/controllers/front/ with the following content:

<?php 

class CategoryController extends CategoryControllerCore
{
    public function canonicalRedirection($canonicalURL = '')
    {
        if (Tools::getValue('live_edit'))
            return ;
        if (!Validate::isLoadedObject($this->category) || !$this->category->inShop() || !$this->category->isAssociatedToShop() || $this->category->id == Configuration::get('PS_ROOT_CATEGORY'))
        {
            $this->redirect_after = '404';
            $this->redirect();
        }
        if (!Tools::getValue('noredirect') && Validate::isLoadedObject($this->category))
            FrontController::canonicalRedirection($this->context->link->getCategoryLink($this->category));
    }
}

确保在创建上述文件后删除/cache/class_index.php.

Make sure you delete /cache/class_index.php after creating the above file.

这篇关于更新后“主页"类别页面不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆