Valle
Valle

Reputation: 15

Prestashop 1.7 hook on admin product

I have a error on my custom module. I need to put a extra text on product admin page. I have use the hook "hookDisplayAdminProductsMainStepLeftColumnMiddle", and it display my tpl with the info (on the image, it is the text "Información adicional relacionada").

enter image description here

The problem is, when the module is active the product admin page not finish of charge.

enter image description here

So I can't save the product or do anything.

This is the code of the hook

public function hookDisplayAdminProductsMainStepLeftColumnMiddle($params) 
{
    $product = new Product($params['id_product']);
        
    $this->context->smarty->assign(array(
        'product ' => $product,
        )
    );
    return $this->display($this->_path, '/views/templates/admin/admininfo.tpl');
}

If I comment only the line "return ....", of course it doesn't display, but the product page charge properly.

On the tpl I write only a text, I don't put yet even a variable.

The other code seems to works properly. I have commented the javascript code on my module. Nor errors or warnings on the console or even on logs. I have actived the debbug mode, but not even there display any error.

Any idea or suggest will be grateful!

Upvotes: 0

Views: 1483

Answers (1)

gennaris
gennaris

Reputation: 1622

Try using :

$tpl = $this->context->smarty->createTemplate(
        dirname(__FILE__).'/views/templates/admin/yourtemplate.tpl'
    );

And then :

return $tpl->fetch();

Upvotes: 1

Related Questions