[*] BO : #PSFV-696 : add attachment when we duplicate a product
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14560 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -3282,6 +3282,28 @@ class ProductCore extends ObjectModel
|
||||
return Db::getInstance()->insert('product_download', $data);
|
||||
}
|
||||
|
||||
public static function duplicateAttachments($id_product_old, $id_product_new)
|
||||
{
|
||||
// Get all ids attachments of the old product
|
||||
$sql = 'SELECT `id_attachment` FROM `'._DB_PREFIX_.'product_attachment` WHERE `id_product` = '.(int)$id_product_old;
|
||||
$results = Db::getInstance()->executeS($sql);
|
||||
|
||||
if (!$results)
|
||||
return true;
|
||||
|
||||
$data = array();
|
||||
|
||||
// Prepare data of table product_attachment
|
||||
foreach ($results as $row)
|
||||
$data[] = array(
|
||||
'id_product' => (int)$id_product_new,
|
||||
'id_attachment' => (int)$row['id_attachment']
|
||||
);
|
||||
|
||||
// Duplicate product attachement
|
||||
return Db::getInstance()->insert('product_attachment', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate features when duplicating a product
|
||||
*
|
||||
|
||||
@@ -438,6 +438,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
&& Product::duplicateTags($id_product_old, $product->id)
|
||||
&& Product::duplicateDownload($id_product_old, $product->id)
|
||||
&& Product::duplicateTaxRulesGroup((int)$id_product_old, (int)$product->id)
|
||||
&& Product::duplicateAttachments((int)$id_product_old, (int)$product->id)
|
||||
&& $product->duplicateShops($id_product_old))
|
||||
{
|
||||
if ($product->hasAttributes())
|
||||
|
||||
Reference in New Issue
Block a user