FEEDBACK
X
FEEDBACK

Er du tilfreds med indholdet i denne her guide?

Hvis ikke, så vil vi meget gerne høre dine kommentarer.

Skriv dem herunder, så gør vi det bedste, vi kan for at forbedre manualen.

Tak for din kommentar!

Send ny?

Dansk English

SmartWeb Help | API

2.8. Update a product

The method for updating a product is very similar to that of creating a new product. First an object or array with the data for the update is made, and the it is used as argument in the update method:

class ProductUpdate {
           public $Id;
           public $Stock;
           public $CallForPrice;
}
 
$parameter                       = new ProductUpdate();
$parameter->Id                   = 1337;
$parameter->Stock                = 5;
$parameter->CallForPrice         = false;
 
$Client->Product_Update(array ('ProductData' => $parameter));

There are however a couple of differences. The first thing to note is that not alle fields have to be defined. Only the fields that are to be updated should be defined. In the example above, only Stock and CallForPrice are updated for the product with Id 1337. The remaining fields remain uneffected.

Besides the Id, it is possible to use the ItemNumber as the identifying field. However it should be noted that using the ItemNumber can effect more than one product, since it is not nessecarely unique:

class ProductUpdate {
           public $ItemNumber;
           public $Title;
           public $LanguageISO;
}
 
$parameter                       = new ProductUpdate();
$parameter->ItemNumber           = 'item234';
$parameter->Title                = 'En produkttitel';
$parameter->LanguageISO          = 'DK';
 
$Client->Product_Update(array ('ProductData' => $parameter));

This will update the Danish title of all products having the ItemNumber 'item234'.
The call returns an array of the ids of all affected products

If the Id is specified in the dataobject for the product update, this will alwats be used as the identifier. So if you want to update the ItemNumber of a product, this is possible by setting both the Id and the new Itemnumber:

class ProductUpdate {
           public $Id;
           public $ItemNumber;
}
 
$parameter                       = new ProductUpdate();
$parameter->Id                   = 1337;
$parameter->ItemNumber           = 'nytvarenummer';
 
$Client->Product_Update(array ('ProductData' => $parameter));