Reading list Switch to dark mode

    Add Custom Row Action In Admin Controller Prestashop

    Updated 29 June 2017

    When we create any admin controller in prestashop there we can have three only defined row action “View“, “Edit” and “Delete“. These row action can easily be create if we write $this->addRowAction(‘view’), $this->addRowAction(‘edit’), $this->addRowAction(‘delete’) because for this prestashop has already code for us. But what If you need to add some row action then ???

    Here we will learn how we can add custom row action which is not defined by the prestashop.

    Step : 1) Add customer row action like – $this->addRowAction(‘information’); . Here i’m trying to list information action in drop down in action column.

    Step : 2) Now use a function

    public function displayInformationLink()
    {
    
    }

    In this function, you can use anything. Anything means to return any tpl file or you can perform PHP as well. This function may contain argument as well.

    Searching for an experienced
    Prestashop Company ?
    Find out More

    Like

    public function displayInformationLink($token = null, $id, $name = null)
    {
      // $token will contain token variable
      // $id will hold id_identifier value
      // $name will hold display name
    }
    
    
    

    Let me explain how this function work when we create custom row action in admin controller.

    Whatever the row action you want to create just define it in $this->addRowAction(‘Your Desire Action name’);

    Now call the function “displayActionNameLink()” this function has a prefix is display and suffix is link. Middle name contain you action name as we have used information. So function become

    public function displayInformationLink() { }

    Checkout the screenshot below. Before creating custom row action

    Custom Row Action
    After adding the custom row action –

    Custom Row Action

    Example code –

    public function renderList()
        {
            $this->addRowAction('view');
            $this->addRowAction('delete');
            $this->addRowAction('information');
        }
    }
    public function displayInformationLink()
    {
        return $this->context->smarty->fetch(_PS_MODULE_DIR_.'yourmodulename/views/templates/hook/information.tpl');
    }

    If there are something not understandable by this post then do comment below. We will surely assist on that.

     

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    1 comments

  • Sumit Wadhwa
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home