【问题标题】:Add a product into a custom page - Prestashop 1.6将产品添加到自定义页面 - Prestashop 1.6
【发布时间】:2017-06-09 21:52:26
【问题描述】:

一切都在问题中,是否可以将产品添加到我创建的页面中?

我是否必须构建一些控制器等?

【问题讨论】:

    标签: prestashop prestashop-1.6


    【解决方案1】:

    是的,可以在自定义页面上显示 PrestaShop 产品。您首先必须通过模块创建一个前端控制器,如下所示。

    你需要在你的模块中为它创建一个单独的控制器,路径如下:

    /modules/supercheckout/controllers/front/fcont.php(其中 supercheckout 是您的模块名称)

    并在文件中写入以下代码:

    class SupercheckoutFcontModuleFrontController extends ModuleFrontController
    {
    
    public function initContent()
    {
            parent::initContent();
            $this->setTemplate('template_file.tpl');
    }
    }
    

    然后将主题的 product-list.tpl 文件包含在模块的模板文件中,以在控制器页面上列出产品。

    {include file="$tpl_dir./product-list.tpl" products=$filtered_products id='block_list_id'}
    

    注意:$filtered_products 变量包含要加载到自定义控制器页面上的产品。

    【讨论】:

    • 你能解释一下为什么我必须通过一个模块吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-08
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    • 2013-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多