[-] Classes : fix return value when updating product attachment
This commit is contained in:
@@ -127,12 +127,14 @@ class AttachmentCore extends ObjectModel
|
|||||||
public static function attachToProduct($id_product, $array)
|
public static function attachToProduct($id_product, $array)
|
||||||
{
|
{
|
||||||
$result1 = Attachment::deleteProductAttachments($id_product);
|
$result1 = Attachment::deleteProductAttachments($id_product);
|
||||||
|
|
||||||
if (is_array($array))
|
if (is_array($array))
|
||||||
{
|
{
|
||||||
$ids = array();
|
$ids = array();
|
||||||
foreach ($array as $id_attachment)
|
foreach ($array as $id_attachment)
|
||||||
if ((int)$id_attachment > 0)
|
if ((int)$id_attachment > 0)
|
||||||
$ids[] = '('.(int)$id_product.','.(int)$id_attachment.')';
|
$ids[] = array('id_product' => (int)$id_product, 'id_attachment' => (int)$id_attachment);
|
||||||
|
|
||||||
Db::getInstance()->execute('
|
Db::getInstance()->execute('
|
||||||
UPDATE '._DB_PREFIX_.'product
|
UPDATE '._DB_PREFIX_.'product
|
||||||
SET cache_has_attachments = '.(count($ids) ? '1' : '0').'
|
SET cache_has_attachments = '.(count($ids) ? '1' : '0').'
|
||||||
@@ -140,10 +142,10 @@ class AttachmentCore extends ObjectModel
|
|||||||
LIMIT 1
|
LIMIT 1
|
||||||
');
|
');
|
||||||
|
|
||||||
return ($result1 && count($ids) && Db::getInstance()->execute('
|
if (!empty($ids))
|
||||||
INSERT INTO '._DB_PREFIX_.'product_attachment (id_product, id_attachment)
|
$result2 = Db::getInstance()->insert('product_attachment', $ids);
|
||||||
VALUES '.implode(',', $ids))
|
|
||||||
);
|
return ($result1 && (!isset($result2) || $result2));
|
||||||
}
|
}
|
||||||
return $result1;
|
return $result1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user