Jump to content

Add new bulk button in backoffice product list like Delete selected


vlskrbek

Recommended Posts

Hello,

I would like to help with prestashop version 1.5.3.1.

I know that this is quite an old version but we still have it.

 

I need just clue not to develope it. The user vekia was very helpfull hope somebody still can help like he.

I need add new button for bulk operation like there is already "Delete selected" and I want to add new one just next to it so I can do my thinks.

I know that the main part is in AdminProductsController.php but I cannot find where should I put the function for new bulk button and where should I put the button itself.

See the picture.

 

Thank for help.

Best Regards

products button Delete selected.jpg

Link to comment
Share on other sites

The better way is to create own module and override "AdminProductsController.php" like as:
 

class AdminProductsController  extends AdminProductsControllerCore

{

  public function __construct($theme_name = 'default')
    {
        $this->bootstrap = true;
         $this->bulk_actions = array(
            'enableRajNaZemi' => array(
                'text' => $this->l('Set Raj na zemi'),
                'icon' => 'icon-power-off text-success',
            ),
        );  

        parent::__construct('', $theme_name);
    }
    public function processBulkEnableRajNaZemi()
    {
        //do something
         
    }
}

if you do not want to create own module, you can write directly into AdminProductsController.php file
 



  public function __construct($theme_name = 'default')
    {
        ..
        ..
        if (!is_array($this->bulk_actions)) {
                $this->bulk_actions = array();
        }

        $this->bulk_actions = array_merge(array(
            'enableRajNaZemi' => array(
                'text' => $this->l('Set Raj na zemi'),
                'icon' => 'icon-power-off text-success',
            ),
        );  

        parent::__construct('', $theme_name);
    }
    public function processBulkEnableRajNaZemi()
    {
        //do something
         
    }
            

 

Link to comment
Share on other sites

Thanks very much. I have also find this way but your example was very helpful anyway. 

Firstly I need to find out how it works then I would create override. 

When I tried it I found the comment that I should create method with name "bulkActionName". But in reality it is name "processBulkActionName". 

For me this is a little misleading. Why there is the word "process" in the beginning? 

If I follow that comment then it will not work. 

Best regards 

Edited by vlskrbek (see edit history)
Link to comment
Share on other sites

Quote

For me this is a little misleading. Why there is the word "process" in the beginning? 


I assume  it's a rhetorical question
It is name convention for the controller's functions that should process bulk actions

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...