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.5. Get products

This example is an extension of example 2.4, in which data for updating the stock of products and their variants is needed. To fetch all products, the following method is used:

$ProductReturn = $Client->Product_GetAll();
$Products = $ProductReturn->Product_getAllResult->item;

Notice that the return value is wrapped in the variable 'Product_getAllResult. This is due to the SOAP document / literal wrapped style. A function named 'x' will always return its result in an object variable named 'xResult'.
IF the result is furthermore a complex type such as an array, this is further wrapped in an 'item' variable inside the 'xResult'.

An example of a simple application writing out the fetched data:

foreach ($Products as $Product) {
echo "Product: $Product->Id, stock: $Product->Stock\n";
foreach ($Product->Variants as $Variant) {
echo "Product: $Product->Id, variant: $Variant->Id stock: $Variant->Stock \n";

There exist multiple possibilities to costumize the Product object so it fits the needs of the application using it. A complete description of all data objects and methods for the webservice can be found at

In addition, several methods for specifying which products are wanted in the extract exist, each being favourable in varioussituations.
An example could be ecquiring products which have been modified during a given period of time. Products which have been modified during the last week can be fetched like this:

$StartDate = date('Y-m-d', time() – 60 * 60 * 24 * 7);
$Products = $Client->Product_GetByUpdatedDate(array('StartDate' => $StartDate));