--- layout: m1x_soap title: Product Tag Add ---
Aliases: product_tag
Allows you to add one or more tags to a product.
Arguments:
| Type | Name | Description |
|---|---|---|
| string | sessionId | Session ID |
| array | data | Array of catalogProductTagAddEntity |
Return:
| Type | Name | Description |
|---|---|---|
| array | result | Associative array of added tags with the tag name as a key and the tag ID as a value |
The catalogProductTagAddEntity content is as follows:
| Type | Name | Description |
|---|---|---|
| string | tag |
Tag to be added (can contain several tags separated with white spaces). A tag that contains several words should be enclosed in single quotes. |
| string |
product_id |
Product ID |
| string |
customer_id |
Customer ID |
| string |
store |
Store ID |
Faults:
| Fault Code | Fault Message |
|---|---|
| 101 | Requested store does not exist. |
| 102 | Requested product does not exist. |
| 103 | Requested customer does not exist. |
| 105 | Provided data is invalid. |
| 106 | Error while saving tag. Details in error message. |
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$data = array('product_id' => 2, 'store' => 'default', 'customer_id' => 10002, 'tag' => "First 'Second tag' Third");
echo "Adding Tag... ";
$addResult = $proxy->call(
$sessionId,
"product_tag.add",
array($data)
);
echo ((count($addResult) == 3) ? "Done!" : "Fail!");
echo "<br />";
print_r($addResult);
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$result = $proxy->catalogProductTagAdd($sessionId, array(
'tag' => 'album',
'product_id' => '3',
'customer_id' => '1',
'store' => '0'
));
var_dump($result);
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');
$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey'));
$result = $proxy->catalogProductTagAdd((object)array('sessionId' => $sessionId->result, 'data' => ((object)array(
'tag' => 'album',
'product_id' => '3',
'customer_id' => '1',
'store' => '0'
))));
var_dump($result->result);