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.7. Create a new product

To create a new product the first thing to do is to create an object or array with the relevant data for the product. After this a method invoked with the data as the argument:

class ProductCreate {
           public $Title;
           public $LanguageIso;
           public $DescriptionLong;
...
}
 
$parameter                       = new ProductCreate();
$parameter->Title                = 'A title';
$parameter->DescriptionLong      = 'A long description';
$parameter->LanguageIso          = 'DK';
...
 
$ProductReturn = $Client->Product_Create(array('ProductData' => $parameter));
$NewProductId = $ProductReturn->ProductCreateResult;

The method returns the Id of the newly created product. Using this further enitities for the product such as pictures or variants can be created:

class ProductVariantCreate {
           public $ProductId;
           public $ItemNumber;
           public $Price;
}
 
$parameter                       = new ProductVariantCreate();
$parameter->ProductId            = $NewProductId;
$parameter->ItemNumber           = 'variant43';
$parameter->Price                = 40.2;
 
$Client->Product_CreateVariant(array('VariantData' => $parameter));

Notice that the ProductId of the variant is set to the Id of the newly created product.