Set SKU codes
Last updated: 27-Sep-2021
Rate this article:
Overview
Use the setSku method to create a valid combination of elements (code) for a specific product.
In case there is an active SKU schema available for that Product Code and Pricing Configuration Code, when setting new SKUs the entire existing schema will be overwritten with the new values. The same validations that are applied to the CSV file import in the Merchant Control Panel are applicable to the API as well.
Product SKUs created via API will also be available in the Merchant Control Panel for manual update (Dashboard → Setup → Products → Edit product → Information → SKU Manager (SKU list Tab).
Request Example
<?php
require ('PATH_TO_AUTH');
$product = new \stdClass();
$product->ProductCode = "6B3CB17DDA_COPY1";
$skuPricingOption1 = new \stdClass();
$skuPricingOption1->Code = "E684EC99B0";
$skuDetail1 = new \stdClass();
$skuDetail1->ProductSKU = "Product_Test_SKU_001022";
$skuDetail1->Currency = "USD";
$skuDetail1->FromQty = 1;
$skuDetail1->ToQty = 3
$skuDetail1->PurchaseType = "NEW_PRODUCT";
$skuGroup = new \stdClass();
$skuGroup->GroupCode = "GRUP_1";
$skuGroupOption = new \stdClass();
$skuGroupOption->Name = "option name 1";
$skuGroupOption->Value = "option_code_1";
$skuGroup->Options = [$skuGroupOption];
$skuDetail1->Groups = [$skuGroup];
$skuDetail1->Options = "eJwBLADT/6G10uOW07exk6mNk7KvrpaSc4l1lbXToqi5sriTcbOXseWu3ZGrlXauuZOojh8cww==";
$skuDetail2 = new \stdClass();
$skuDetail2->ProductSKU = "Product_Test_SKU_001023";
$skuDetail2->Currency = "USD";
$skuDetail2->FromQty = 1;
$skuDetail2->ToQty = 3
$skuDetail2->PurchaseType = "NEW_PRODUCT";
$skuGroup = new \stdClass();
$skuGroup->GroupCode = "GRUP_1";
$skuGroupOption = new \stdClass();
$skuGroupOption->Name = "option name 2";
$skuGroupOption->Value = "option_code_2";
$skuGroup->Options = [$skuGroupOption];
$skuDetail2->Groups = [$skuGroup];
$skuDetail2->Options = "eJwBLADT/6G10uOW07exk6mNk7KvrpaSc4l1lbXToqi5sriTcbOXseWu3ZGrmXauuZOojjccxw==";
$skuPricingOption1->Details = [$skuDetail1, $skuDetail2];
$product->SkuPricingOptions = [$skuPricingOption1];
try {
$skuOutput = $client->setSku($sessionID, [$product]);
} catch (SoapFault $e) {
echo "setSku: " . $e->getMessage();
exit;
}
var_dump("setSku", $skuOutput);
Response Example
class stdClass#201 (2) {
public $Results =>
class stdClass#202 (1) {
public $0 =>
class stdClass#203 (2) {
public $ProductCode =>
string(16) "6B3CB17DDA_COPY1"
public $PricingConfigurationCode =>
string(10) "E684EC99B0"
}
}
public $Errors =>
class stdClass#204 (0) {
}
}
Rate this article: