From 7f6949043e7d8537252d475a27819074f13790c3 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Wed, 6 Jul 2016 12:14:28 +0200 Subject: [PATCH] adding various description blocks in Admin product edit fast --- adm/tabs/AdminProducts.php | 11 ++++- modules/bulkupdate/AdminEditFast.php | 60 +++++++++++++++++++++++----- 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/adm/tabs/AdminProducts.php b/adm/tabs/AdminProducts.php index 8c55dad4..1355895c 100755 --- a/adm/tabs/AdminProducts.php +++ b/adm/tabs/AdminProducts.php @@ -181,11 +181,12 @@ class AdminProducts extends AdminTab if (Tools::isSubmit('editProduct')) { global $cookie, $currentIndex; $products = Tools::getValue('productBox'); + $blocks = Tools::getValue('blocks'); $id_lang_fast = Tools::getValue('id_lang_fast'); $redirect = "/adm/index.php?tab=AdminEditFast"; $token_redirect = Tools::getAdminToken('AdminEditFast'.(int)(Tab::getIdFromClassName('AdminEditFast')).(int)($cookie->id_employee)); - Tools::redirectAdmin($redirect . "&id_product=". json_encode($products)."&id_lang_fast=".(int) $id_lang_fast."&token=". $token_redirect); + Tools::redirectAdmin($redirect . "&id_product=". json_encode($products)."&id_lang_fast=".(int) $id_lang_fast."&blocks=". json_encode($blocks)."&token=". $token_redirect); } if (Tools::isSubmit('addCategoryProduct')) { @@ -1717,6 +1718,14 @@ class AdminProducts extends AdminTab echo ''; } echo ''; + echo '

'; + echo ''; + echo ' Description courte '; + echo ' Bon à savoir '; + echo ' Les plus '; + echo ' Vidéos '; + echo ' Livraison '; + echo '

'; echo '
'; diff --git a/modules/bulkupdate/AdminEditFast.php b/modules/bulkupdate/AdminEditFast.php index d04583a9..aa5037c1 100644 --- a/modules/bulkupdate/AdminEditFast.php +++ b/modules/bulkupdate/AdminEditFast.php @@ -10,11 +10,14 @@ class AdminEditFast extends AdminTab { if (Tools::isSubmit('submitEditFast')){ $products = json_decode(Tools::getValue('id_product'), 0); $title = Tools::getValue('title'); - $short_description = Tools::getValue('short_description'); - $description = Tools::getValue('description'); + $short_description = Tools::getValue('short_description', array()); + $description = Tools::getValue('description', array()); + $description_more = Tools::getValue('description_more', array()); + $description_delivery = Tools::getValue('description_delivery', array()); + $videos = Tools::getValue('videos', array()); $reference = Tools::getValue('reference'); $id_lang_fast = Tools::getValue('id_lang_fast'); - $nbProduct = 0; + $nbProduct = 0; foreach ($products as $key => $product) { if (Validate::isLoadedObject($product = new Product((int)$product))) { @@ -38,6 +41,15 @@ class AdminEditFast extends AdminTab { if(isset($description[$product->id])){ $product->description[(int) $id_lang_fast] = $description[$product->id]; } + if(isset($description_more[$product->id])){ + $product->description_more[(int) $id_lang_fast] = $description_more[$product->id]; + } + if(isset($description_delivery[$product->id])){ + $product->description_delivery[(int) $id_lang_fast] = $description_delivery[$product->id]; + } + if(isset($videos[$product->id])){ + $product->videos[(int) $id_lang_fast] = $videos[$product->id]; + } if(isset($reference[$product->id])){ $product->reference = $reference[$product->id]; } @@ -62,16 +74,24 @@ class AdminEditFast extends AdminTab { global $cookie; $id_lang = Tools::getValue('id_lang_fast', $cookie->id_lang); $language = new Language($id_lang); + $default_blocks = array( + 'short_description', + 'description', + 'description_more', + 'description_delivery', + 'videos' + ); if (Tools::getIsset('id_product')) { $this->_html .= '

Edition rapide - '.$language->name.'

'; $this->_html .= '
'; $this->_html .= '
'; $products = json_decode(Tools::getValue('id_product')); + $blocks = Tools::getIsset('blocks')? json_decode(Tools::getValue('blocks')) : $default_blocks; foreach ($products as $key => $product) { if (Validate::isLoadedObject($product = new Product((int)$product, FALSE, $id_lang) )) { - $this->_html .= self::displayFormProduct($product); + $this->_html .= self::displayFormProduct($product,$blocks); } else { $this->_html .= $product . " erreur"; } @@ -113,7 +133,7 @@ class AdminEditFast extends AdminTab { echo $this->_html; } - public function displayFormProduct(Product $product) { + public function displayFormProduct(Product $product, $blocks = array()) { $form = ''; $form .= '

'. $product->name .'

'; $form .= '
'; @@ -124,12 +144,32 @@ class AdminEditFast extends AdminTab { $form .= ''; $form .= ''; $form .= '

'; - $form .= ''; - $form .= ''; + + if (in_array('short_description',$blocks)) { + $form .= ''; + $form .= ''; $form .= '

'; - $form .= ''; - $form .= ''; - $form .= '

'; + } + if (in_array('description',$blocks)) { + $form .= ''; + $form .= ''; + $form .= '

'; + } + if (in_array('description_more',$blocks)) { + $form .= ''; + $form .= ''; + $form .= '

'; + } + if (in_array('videos',$blocks)) { + $form .= ''; + $form .= ''; + $form .= '

'; + } + if (in_array('description_delivery',$blocks)) { + $form .= ''; + $form .= ''; + $form .= '

'; + } $form .= ''; $form .= '
';