Merge pull request #356 from arnolem/dev-wsSetProductTags
[*] WS : Allow to set the tags list of product
This commit is contained in:
@@ -4740,6 +4740,44 @@ class ProductCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'product_tag`
|
||||
WHERE `id_product` = '.(int)$this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Webservice setter : set tag ids of current product for association
|
||||
*
|
||||
* @param $tag_ids tag ids
|
||||
*/
|
||||
public function setWsTags($tag_ids)
|
||||
{
|
||||
$ids = array();
|
||||
foreach ($tag_ids as $value)
|
||||
$ids[] = $value['id'];
|
||||
if ($this->deleteWsTags())
|
||||
{
|
||||
if ($ids)
|
||||
{
|
||||
$sql_values = '';
|
||||
$ids = array_map('intval', $ids);
|
||||
foreach ($ids as $position => $id)
|
||||
$sql_values[] = '('.(int)$this->id.', '.(int)$id.')';
|
||||
$result = Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'product_tag` (`id_product`, `id_tag`)
|
||||
VALUES '.implode(',', $sql_values)
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete products tags entries without delete tags for webservice usage
|
||||
*
|
||||
* @return array Deletion result
|
||||
*/
|
||||
public function deleteWsTags()
|
||||
{
|
||||
return Db::getInstance()->delete('product_tag', 'id_product = '.(int)$this->id);
|
||||
}
|
||||
|
||||
|
||||
public function getWsManufacturerName()
|
||||
|
||||
Reference in New Issue
Block a user