mmleoni Posted October 9, 2013 Share Posted October 9, 2013 Hi guys, I'm new to ps, so have a mercy for me I worked for many years with joomla & virtuemart (or joomshopping); I think ps is great, but I really miss mass actions: especially enable/disable products and categories.I took a look to the code, and I think it's quite simple to implement these functions, but I know that authors have a lot of work to do before than this one. I needed to enable/disable a lot of products at same time, so I modified the code, of course I don't want to keep modified core code Can you help me to check if the code is ok and if I can submit this code to be inserted into next official release?bye,marco in: /controllers/admin/AdminProductsController.php (v 1.5.6.0) replace line 65 with: $this->bulk_actions = array( 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), 'enable' => array('text' => $this->l('Enable selected'), 'confirm' => $this->l('Enable selected items?')), 'disable' => array('text' => $this->l('Disable selected'), 'confirm' => $this->l('Disable selected items?')) ); replace line 3476 with: $this->bulk_actions = array( 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), 'enable' => array('text' => $this->l('Enable selected'), 'confirm' => $this->l('Enable selected items?')), 'disable' => array('text' => $this->l('Disable selected'), 'confirm' => $this->l('Disable selected items?')) ); insert where ever you want: protected function processBulkEnable() { $this->doBulkEnable(true); } protected function processBulkDisable() { $this->doBulkEnable(false); } protected function doBulkEnable($status) { if ($this->tabAccess['edit'] === '1') { if (is_array($this->boxes) && !empty($this->boxes)) { $products = Tools::getValue($this->table.'Box'); if (is_array($products) && ($count = count($products))) { // I don't think (un)publish products can be quite long on a cheap server... anyway. if (intval(ini_get('max_execution_time')) < round($count * 1.5)) ini_set('max_execution_time', round($count * 1.5)); foreach ($products as $id_product) { $product = new Product((int)$id_product); $product->active = $status; $product->update(); } } } else $this->errors[] = Tools::displayError('You must select at least one element to enable/disable.'); } else $this->errors[] = Tools::displayError('You do not have permission to enable/disable this.'); } in the attachment the modified fileAdminProductsController.php 2 Link to comment Share on other sites More sharing options...
safa Posted December 10, 2013 Share Posted December 10, 2013 (edited) thanks for sharing, this topic realy helped me. working 1.5.6.0 Edited December 10, 2013 by safa (see edit history) Link to comment Share on other sites More sharing options...
do2go Posted January 6, 2014 Share Posted January 6, 2014 Sometimes when I choose all of products from page - it just disable few - not all leaving some enabled. When I do this few times, random products are enabled and disabled. Don't know why.. 1 Link to comment Share on other sites More sharing options...
krisives Posted January 6, 2014 Share Posted January 6, 2014 Nice work thanks for the code. Link to comment Share on other sites More sharing options...
carbo2022 Posted April 1, 2015 Share Posted April 1, 2015 Hi! Its perfect, can you do a version for prestashop 1.6 please? Link to comment Share on other sites More sharing options...
marckpy Posted March 15, 2016 Share Posted March 15, 2016 I need a way to mass disable products from one brand too for 1.6 please!! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now