Jump to content

Add field in product category on Prestashop


Recommended Posts

I'm on Prestashop and I would like to add a custom wysiwyg field in the product category page and be able to display its value in the front-office. I already managed to set up the wysiwyg field in the back office but I can't manage to get the value to insert it in the template and display it on the customer side.

Here is my module :

 

<?php


if (!defined('_PS_VERSION_'))
    exit;

class Wysi extends Module
{
    public function __construct()
    {
        $this->name = 'wysi';
        $this->tab = 'front_office_features';
        $this->version = '0.1';
        $this->author = 'advisa';
        $this->need_instance = 0;

        parent::__construct();

        $this->displayName = $this->l('wysi');
        $this->description = $this->l('Add WYSIWYG field in Product Category');
    }

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

    public function uninstall()
    {
        return parent::uninstall();
    }
    public function hookDisplayBackOfficeCategory($params)
    {
        return $this->display(__FILE__, 'wysi.tpl');

    }

 

And here is my template that displays the wysiwyg field

<label for="texteSeo">Texte SEO</label><br>

<textarea class= "autoload_rte" id="id" name="name" rows="10" cols="45"></textarea>

Can someone help me please I can't do it for weeks!

Link to comment
Share on other sites

You are missing an important part. Where is the text going to be saved? with this module and this hook DisplayBackOfficeCategory you are only able to show something in BO category page. Then you enter some text and press save or something. You need to save this too. I think you are not aware of this. After you have saved this, you can retrieve it any time you want and display that respectively. But there is one question for me. Why do you need to do this? If you explain your needs, we might give you better solutions.

Link to comment
Share on other sites

18 minutes ago, Guillaume_KS said:

hello stifler, that's an exercice ! I need to set up a wysiwyg field in the product category and display the result in the front-office

As I told you, you need to save the data in the form. Do you understand this or need some more explanations?

Link to comment
Share on other sites

I think I need more explanations,

moreover, I broke the back office, when I want to access the category list I get this error message 

 

Quote

[Semantical Error] The annotation "@AdminSecurity" in method PrestaShopBundle\Controller\Admin\Sell\Catalog\CategoryController::indexAction() was never imported. Did you maybe forget to add a "use" statement for this annotation?

 

I tried to put some uses to stop the problem but it doesn't work

 

 use PrestaShopBundle\Controller\Admin\Sell\Catalog\CategoryController

 

Thank you for your time stifler

  • Confused 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...