Read More
Read More
Menu Close

    Adding custom action button in PrestaShop renderlist

    Adding custom action button in PrestaShop renderlist – We can easily use ‘view’, ‘edit’, ‘delete’ buttons in Prestashop render list by the help of addRowAction(‘view’) function. But what if we need to add some custom buttons in the list!! we can use PrestaShop field list ‘callback’ property for the same.

     

    Add a temp array key in you $this->fields_list array :

    $this->fields_list = array(
       'id_temp' => array(
            'title' => $this->l('My Button'),
            'align' =>'text-right',
            'search' => false,
            'callback' => 'viewMyButton',
       ),
    }

     

    id_temp is an alias of your list id, you can define this like :

    Searching for an experienced
    Prestashop Company ?
    Read More
    $this->_select = 'a.`id` as `id_temp`';

     

    Now create a function with callback name viewMyButton

    public function viewMyButton($id)
    {
        return '<span class="btn-group-action">
                    <span class="btn-group">
                        <a class="btn btn-default" href="'.self::$currentIndex.'&token='.$this->token.'&view'.$this->table.'&id='.$id.'"><i class="icon-search-plus"></i>&nbsp;'.$this->l('View').'
                        </a>
                    </span>
                </span>';
    }
    

     

    This will create a button in the render list like this :

    single action button

     

     

    If you want to display multiple buttons, you need to write the HTML for that only,

    public function viewMyButton($id)
    {
            return '<span class="btn-group-action">
                        <span class="btn-group pull-right">
                            <a class="btn btn-default" href="'.self::$currentIndex.'&token='.$this->token.'&view'.$this->table.'&id='.$id.'"><i class="icon-search-plus"></i>&nbsp;'.$this->l('My Button1').'
                            </a>
                            <button data-toggle="dropdown" class="btn btn-default dropdown-toggle">
                            <i class="icon-caret-down"></i>&nbsp;
                        </button>
                        <ul class="dropdown-menu">
                            <li>
                                <a class="delete" title="Delete" href="#">
                                <i class="icon-trash"></i> My Button2
                                </a>
                            </li>
                        </ul>
                        </span>
                    </span>';
    }

     

    This will look like this :

    multiple action button

     

    Thanks.

    . . .
    Discuss on Helpdesk

    Leave a Comment

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


    Be the first to comment.

    Back to Top