首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Prestashop产品管理挂钩

Prestashop产品管理挂钩
EN

Stack Overflow用户
提问于 2019-07-06 00:43:19
回答 2查看 106关注 0票数 0

我正在为Prestashop创建一个新的插件。插件是激活的,工作正常,除了,我不能挂钩到Prestashop产品管理(后台)的特定区域。

我正在使用这个钩子: DisplayAdminProductsMainStepLeftColumnMiddle。我可以看到它被放在prestashop的模板分枝引擎中,我正在使用它,如下所示,但内容根本没有显示出来。

奇怪的是,我可以很容易地连接到例如钩子AdminOrder,没有问题,但不是DisplayAdminProductsMainStepLeftColumnMiddle。

代码语言:javascript
复制
class my_module extends Module
{


    public function __construct()
    {

        $this->name = "my_module";
        $this->tab = 'front_office_features';
        $this->version = '1.0.0';
        $this->author = 'my_author';
        $this->need_instance = 1;
        $this->ps_versions_compliancy = [
            'min' => '1.6',
            'max' => _PS_VERSION_,
        ];

        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('my_module');
        $this->description = $this->l('my_module');
        $this->confirmUninstall = $this->l('You are about to uninstall Product addons. Wish to continue?');

    }

    public function install()
    {
        return
            parent::install()
            && $this->registerHook('displayAdminProductsMainStepLeftColumnMiddle')
            && $this->registerHook('adminOrder');
    }

    public function uninstall()
    {
        return parent::uninstall();
    }

    public function HookDisplayAdminProductsMainStepLeftColumnMiddle() //No content is being displayed in the productpage backoffice
    {
        echo 'Content in hook';
    }

    public function HookAdminOrder() //This hook works perfectly fine
    {
        echo 'Content in hook';
    }

}
EN

回答 2

Stack Overflow用户

发布于 2019-07-06 18:56:32

使用return而不是echo,它将会工作

代码语言:javascript
复制
public function hookDisplayAdminProductsMainStepLeftColumnMiddle()
{
    return 'Content in hook';
}

并且不要忘记首先重置您的模块以注册钩子

票数 1
EN

Stack Overflow用户

发布于 2019-07-08 16:50:56

后来我发现,在install函数中注册钩子(尤其是后端钩子)是显式的。我只是出于测试目的在构造函数中注册了钩子(前端钩子总是以这种方式工作)。

所以我把钩子放在installer函数中,重新激活模块,然后它就能工作了。

希望这能帮助到一些人=)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56906687

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档