diff --git a/admin-dev/themes/template/products/attachments.tpl b/admin-dev/themes/template/products/attachments.tpl
index 0dcd3034c..6eabf56b6 100644
--- a/admin-dev/themes/template/products/attachments.tpl
+++ b/admin-dev/themes/template/products/attachments.tpl
@@ -99,11 +99,45 @@
+
{/if}
diff --git a/admin-dev/themes/template/products/form.tpl b/admin-dev/themes/template/products/form.tpl
index edcb44727..795d625da 100644
--- a/admin-dev/themes/template/products/form.tpl
+++ b/admin-dev/themes/template/products/form.tpl
@@ -165,20 +165,6 @@
$('#desc-product-newCombination').show();
populate_attrs();
}
- else if (btn_name == 'Attachments')
- {
- $("#addAttachment").live('click', function() {
- return !$("#selectAttachment2 option:selected").remove().appendTo("#selectAttachment1");
- });
- $("#removeAttachment").live('click', function() {
- return !$("#selectAttachment1 option:selected").remove().appendTo("#selectAttachment2");
- });
- $("#product").submit(function() {
- $("#selectAttachment1 option").each(function(i) {
- $(this).attr("selected", "selected");
- });
- });
- }
else
{
$('#desc-product-newCombination').hide();
diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php
index 75009081e..e75af17db 100644
--- a/controllers/admin/AdminProductsController.php
+++ b/controllers/admin/AdminProductsController.php
@@ -1024,6 +1024,15 @@ class AdminProductsControllerCore extends AdminController
*/
public function postProcess($token = null)
{
+ if ($this->action == 'attachments')
+ if ($id = (int)Tools::getValue($this->identifier))
+ {
+ $attachments = trim(Tools::getValue('arrayAttachments'), ',');
+ $attachments_tab = explode(',', $attachments);
+ if (Attachment::attachToProduct($id, $attachments_tab))
+ $this->redirect_after = self::$currentIndex.'&id_product='.(int)$id.(isset($_POST['id_category']) ? '&id_category='.(int)$_POST['id_category'] : '').'&conf=4&add'.$this->table.'&action=Attachments&token='.($token ? $token : $this->token);
+ }
+
if (!$this->redirect_after)
parent::postProcess(true);
}