【发布时间】:2016-11-07 11:54:58
【问题描述】:
我想在一个页面中显示所有产品,同时在主菜单中单击单个按钮,并且还需要在主菜单中显示类别...
提前谢谢...!
【问题讨论】:
-
你的意思是没有任何类别也没有分页? ?检查this是否对您有帮助,否则会尽快回复您,
标签: php module opencart opencart2.x opencart-module
我想在一个页面中显示所有产品,同时在主菜单中单击单个按钮,并且还需要在主菜单中显示类别...
提前谢谢...!
【问题讨论】:
标签: php module opencart opencart2.x opencart-module
在一个页面中显示所有产品
您必须创建单独的页面来显示所有产品。
catalog\model\catalog\allproduct.php并粘贴
编码http://pastebin.com/suF5TP3z
catalog\controller\productallproduct.php 和
粘贴以下代码http://pastebin.com/jZq3hZyc
catalog\view\theme\default\template\productallproduct.tpl 并粘贴
以下代码http://pastebin.com/1HNh3x73catalog\language\en-gb\product\allproduct.php
并粘贴以下代码http://pastebin.com/EcyJH7F9
【讨论】:
我建议不要对默认主题代码和结构进行任何更改。如果您已经使用自定义主题,您可以轻松创建菜单并定义所有类别,包括一个菜单或按钮下的所有产品。 让我们以这种方式克服: 例如,您有 5 个类别。每个类别都包含十多种产品或更多。
就是这样!
也许你想玩一下菜单 css。就像我之前说的,如果您已经使用自定义主题,则不需要分叉您的核心代码,尤其是默认主题。
如果有任何帮助,请告诉我。
【讨论】:
我这样做的方式是这样的
控制器:ControllerProductCategory
在索引函数里面替换
if (isset($this->request->get['limit'])) {
$limit = $this->request->get['limit'];
} else {
$limit = $this->config->get('config_product_limit');
}
与
if (isset($this->request->get['viewall'])) {
$limit = "";
} else if (isset($this->request->get['limit'])) {
$limit = $this->config->get('config_product_limit');
} else {
$limit = $this->config->get('config_product_limit');
}
同样进行此更改以显示所有没有类别过滤器的产品
替换此代码
if ($category_info) {
$this->document->setTitle($category_info['meta_title']);
$this->document->setDescription($category_info['meta_description']);
$this->document->setKeywords($category_info['meta_keyword']);
使用此代码
if (($category_info) || ($category_id == 0)) {
if ($category_id == 0) {
$this->document->setTitle('all products');
$this->document->setDescription('all products');
$this->document->setKeywords('all products');
$this->data['heading_title'] = 'all products';
$category_info['description'] = '';
$category_info['image'] = '';
} else {
$this->document->setTitle($category_info['name']);
$this->document->setDescription($category_info['meta_description']);
$this->document->setKeywords($category_info['meta_keyword']);
$this->data['heading_title'] = $category_info['name'];
}
最后创建一个新类别,您可以将其命名为任何您想要的名称。并给链接这样的东西
https://www.yourwebsite.com/yourCategoryname?viewall=viewall?viewall=viewall
您可以将此链接放在您想要的任何位置,它将加载所有产品而无需任何分页。
如果您仍然不明白任何地方,请告诉我。
【讨论】: