From eaa0a81d6f9ccb3d10167ed2de4886c0193c64a1 Mon Sep 17 00:00:00 2001 From: mMarinetti Date: Wed, 23 Nov 2011 20:52:52 +0000 Subject: [PATCH] // fix save and stay in product page --- admin-dev/themes/template/products/form.tpl | 5 ++++- classes/AdminController.php | 2 ++ controllers/admin/AdminProductsController.php | 10 ++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/admin-dev/themes/template/products/form.tpl b/admin-dev/themes/template/products/form.tpl index bffcdc767..da06e336a 100644 --- a/admin-dev/themes/template/products/form.tpl +++ b/admin-dev/themes/template/products/form.tpl @@ -152,6 +152,9 @@ $(document).ready(function(){ }); } }); + {if $show_product_tab_content} + $("div.productTabs a[id$=-{$show_product_tab_content}]").click(); + {/if} }); @@ -294,7 +297,7 @@ $(document).ready(function(){ {/if} - +
diff --git a/classes/AdminController.php b/classes/AdminController.php index aa5cb06e6..2aaedef09 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -600,9 +600,11 @@ class AdminControllerCore extends Controller if ($back = Tools::getValue('back')) $this->redirect_after = urldecode($back).'&conf=4'; // Specific scene feature + // @todo change stay_here submit name (not clear for redirect to scene ... ) if (Tools::getValue('stay_here') == 'on' || Tools::getValue('stay_here') == 'true' || Tools::getValue('stay_here') == '1') $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=4&updatescene&token='.$token; // Save and stay on same form + // @todo on the to following if, we may prefer to avoid override redirect_after previous value if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=4&update'.$this->table.'&token='.$token; // Save and back to parent diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 7dd570018..13c9bf082 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -761,7 +761,7 @@ class AdminProductsControllerCore extends AdminController } } if (!sizeof($this->_errors)) - $this->redirect_after = self::$currentIndex.'&id_product='.(int)$product->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&add'.$this->table.'&tabs=4&conf=4&token='.($token ? $token : $this->token); + $this->redirect_after = self::$currentIndex.'&id_product='.(int)$product->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&add'.$this->table.'&action=Features&tabs=4&conf=4&token='.($token ? $token : $this->token); } else $this->_errors[] = Tools::displayError('Product must be created before adding features.'); @@ -1279,9 +1279,9 @@ class AdminProductsControllerCore extends AdminController $this->_errors[] = Tools::displayError('An error occurred while linking object.').' '.$this->table.' '.Tools::displayError('To categories'); else if (!$this->updateTags($languages, $object)) $this->_errors[] = Tools::displayError('An error occurred while adding tags.'); - else if ($id_image = $this->addProductImage($object, Tools::getValue('resizer'))) + else if (Tools::getValue('id_image') && $id_image = $this->addProductImage($object, Tools::getValue('resizer'))) { - self::$currentIndex .= '&image_updated='.(int)Tools::getValue('id_image'); + self::$currentIndex .= '&image_updated='.$id_image; Hook::exec('updateProduct', array('product' => $object)); Search::indexation(false, $object->id); if (Tools::getValue('resizer') == 'man' && isset($id_image) && is_int($id_image) && $id_image) @@ -1606,6 +1606,8 @@ class AdminProductsControllerCore extends AdminController public function initContent($token = null) { + // this is made to "save and stay" feature + $this->tpl_form_vars['show_product_tab_content'] = Tools::getValue('action'); if (Tools::getValue('id_product') || ((Tools::isSubmit('submitAddproduct') OR Tools::isSubmit('submitAddproductAndPreview') OR Tools::isSubmit('submitAddproductAndStay') OR Tools::isSubmit('submitSpecificPricePriorities') OR Tools::isSubmit('submitPriceAddition') OR Tools::isSubmit('submitPricesModification')) AND sizeof($this->_errors)) OR Tools::isSubmit('updateproduct') OR Tools::isSubmit('addproduct')) { $this->fields_form = array(); @@ -1806,7 +1808,7 @@ class AdminProductsControllerCore extends AdminController public function initToolbar() { - if ($this->display == 'edit') + if ($this->display == 'edit' || $this->display == 'add') if ($product = $this->loadObject(true)) { if ($this->tabAccess['delete'])