Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Module: Tag

Allows you to operate with product tags.

Resource: catalog_product_tag

Aliases: product_tag

Methods:
Faults:
Fault CodeFault Message
101Requested store does not exist.
102Requested product does not exist.
103Requested customer does not exist.
104Requested tag does not exist.
105Provided data is invalid.
106Error while saving tag. Details in error message.
107Error while removing tag. Details in error message.
Example:
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$productId = 2;
$customerId = 10002;
$store = 'default';

// Add tags
$data = array('product_id' => $productId, 'store' => $store, 'customer_id' => $customerId, '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);
$tagId = reset($addResult);

// Get tag info
echo "<br />Get Tag Info (id = $tagId)... ";
$infoResult = $proxy->call(
    $sessionId,
    "product_tag.info",
    array($tagId, $store)
);
echo "Done!<br />";
print_r($infoResult);

// Update tag data
$data = array('status' => -1, 'base_popularity' => 12, 'name' => 'Changed name');
echo "<br />Update Tag (id = $tagId)... ";
$updateResult = $proxy->call(
    $sessionId,
    "product_tag.update",
    array($tagId, $data, $store)
);
echo ($updateResult ? "Done!" : "Fail!");

// Retrieve list of tags by product
echo "<br />Tag list for product with id = $productId... ";
$listResult = $proxy->call(
    $sessionId,
    "product_tag.list",
    array($productId, $store)
);
echo (count($listResult) ? "Done!" : "Fail!");
echo "<br />";
print_r($listResult);

// Remove existing tag
echo "<br />Remove Tag (id = $tagId)... ";
$removeResult = $proxy->call(
    $sessionId,
    "product_tag.remove",
    array($tagId)
);
echo ($removeResult ? "Done!" : "Fail!");

Create the Magento file system owner


Table of contents