header

Magento 1.x Software Support Notice

For Magento Commerce 1, Magento is providing software support through June 2020. Depending on your Magento Commerce 1 version, software support may include both quality fixes and security patches. Please review our Magento Software Lifecycle Policy to see how your version of Magento Commerce 1 is supported.

For Magento Open Source 1.5 to 1.9, Magento is providing software security patches through June 2020 to ensure those sites remain secure and compliant. Visit our information page for more details about our software maintenance policy and other considerations for your business.

Product Link Update

Edit this page on GitHub

Module: Mage_Catalog

Resource: catalog_product_link

Aliases:

Method:

Allows you to update the product link.

Aliases:

Arguments:

Type Name Description
string sessionId Session ID
string
type
Type of the link (cross_sell, grouped, related, or up_sell)
string
product\productId
Product ID or SKU
string
linkedProduct\linkedProductId
Product ID or SKU for the link
array data
Array of catalogProductLinkEntity
string identifierType Defines whether the product ID or SKU is passed in the 'product' parameter

Returns:

Type Name Description
boolean\int result True (1) if the link is updated

The catalogProductLinkEntity content is as follows:

Type Name Description
string product_id
Product ID
string
type
Type of the link
string
set
Product attribute set
string
sku
Product SKU
string
position
Position
string
qty
Quantity

Examples

Request Example SOAP V1
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');

$productId = '1';
$linkedProductId = '2';
$data = array(
	'position' => '50'
);

$result = $proxy->call(
	$session,
	'catalog_product_link.update',
	array(
		'cross_sell',
		$productId,
		$linkedProductId,
		$data
	)
);
Request Example SOAP V2
<?php

$client = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

$session = $client->login('apiUser', 'apiKey');

$data = array(
   "position" => 15
  );

$identifierType = "product_id";
$type = "related";
$product = "1";
$linkedProduct = "3";

$orders = $client->catalogProductLinkUpdate($session, $type, $product, $linkedProduct, $data, $identifierType);

echo 'Number of results: ' . count($orders) . '<br/>';
var_dump ($orders);
?>
Request Example SOAP V2 (WS-I Compliance Mode)
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');
$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey'));

$result = $proxy->catalogProductLinkUpdate((object)array('sessionId' => $sessionId->result, 'type' => 'cross_sell', 'productId' => '1', 'linkedProductId' => '2', 'data' => ((object)array(
'position' => '1'
))));

var_dump($result->result);