按类别列出视图

发布于 2024-12-19 00:10:50 字数 132 浏览 6 评论 0原文

我可以在我正在工作的网站上查看所有类别(http://www.thetradinghouse.co.nz/view-all)。正如您所看到的,产品不是按类别排序的,我如何更改它,因为我也想对管理产品列表执行此操作。

五:1.5.1.3

I have a view all category on the website I am working on (http://www.thetradinghouse.co.nz/view-all). As you can see the products are not in order by category how could I change this as I also would like to do this with the admin product listings too.

V: 1.5.1.3

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牛↙奶布丁 2024-12-26 00:10:50

这种事情需要在相应的 model/catalog/product.php 文件中进行大量编辑。这就是目录方面的事情。管理员应该要求类似的东西。首先,您需要将类别附加到 SQL,就像使用类别过滤器时一样

        if (!empty($data['filter_category_id'])) {
            $sql .= " LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id)";           
        }

然后将变得只是

            $sql .= " LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id)";

因为您希望它可用而不管 filter_category_id

那么您需要将类别 id 添加为排序选项

        $sort_data = array(
            'pd.name',
            'p.model',
            'p.quantity',
            'p.price',
            'rating',
            'p.sort_order',
            'p.date_added'
        );  

需要添加 p2c.category_id

        $sort_data = array(
            'pd.name',
            'p2c.category_id',
            'p.model',
            'p.quantity',
            'p.price',
            'rating',
            'p.sort_order',
            'p.date_added'
        );

并且如果没有提供则设置默认排序,更改

$sql .= " ORDER BY p.sort_order";

$sql .= " ORDER BY p2c.category_id";

最后您需要编辑所述页面的控制器并找到排序值的默认值,并将其更改为p2c.category_id

This kind of thing requires quite a bit of editing in the respective model/catalog/product.php files. This is how for the catalog side of things. The admin should require something similar. To start with, you're going to need to attach the category to the SQL like it does when the category filter is used

        if (!empty($data['filter_category_id'])) {
            $sql .= " LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id)";           
        }

Would then become just

            $sql .= " LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id)";

Since you want it to be available regardless of the filter_category_id

Then you need to add the category id as a sort option

        $sort_data = array(
            'pd.name',
            'p.model',
            'p.quantity',
            'p.price',
            'rating',
            'p.sort_order',
            'p.date_added'
        );  

will need p2c.category_id adding to it

        $sort_data = array(
            'pd.name',
            'p2c.category_id',
            'p.model',
            'p.quantity',
            'p.price',
            'rating',
            'p.sort_order',
            'p.date_added'
        );

And also set the default sort if none is supplied, changing

$sql .= " ORDER BY p.sort_order";

To

$sql .= " ORDER BY p2c.category_id";

Finally you'll need to edit the controller for the said pages and find the default of the sort value, and change it to p2c.category_id

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文