[+] classes : New method ->attachProduct($id_product)

// Fix #PSTEST-699
// now new attachment are automatically linked to the current product
This commit is contained in:
mMarinetti
2012-02-21 10:03:32 +00:00
parent 8603a4fce0
commit f57e2b1cba
3 changed files with 36 additions and 9 deletions
+20 -1
View File
@@ -88,8 +88,10 @@ class AttachmentCore extends ObjectModel
}
/**
* deassociate $id_product from the current object
*
* @static
* @param $id_product
* @param $id_product int
* @return bool
*/
public static function deleteProductAttachments($id_product)
@@ -100,6 +102,23 @@ class AttachmentCore extends ObjectModel
}
/**
* associate $id_product to the current object.
*
* @param int $id_product id of the product to associate
* @return boolean true if succed
*/
public function attachProduct($id_product)
{
return Db::getInstance()->execute('
INSERT INTO '._DB_PREFIX_.'product_attachment
(id_attachment, id_product) VALUES
('.(int)$this->id.', '.(int)$id_product.')');
}
/**
* associate an array of id_attachment $array to the product $id_product
* and remove eventual previous association
*
* @static
* @param $id_product
* @param $array