Product ProductCreate - mobly/sellercenter-sdk GitHub Wiki
try {
// factory returning instance of Product client
$client = \SellerCenter\SDK\Sdk::getProduct(['store' => 'mobly-br', 'environment' => 'staging',]);
$product = new \SellerCenter\SDK\Product\Product();
$product->setSellerSku('ABC123MOB');
$product->setParentSku('XYZ999MOB');
$product->setStatus(\SellerCenter\SDK\Product\Enum\StatusEnum::ACTIVE());
$product->setName('Product Name');
$product->setVariation('ABC123MOB-5656');
$product->setPrimaryCategory(123);
$product->setCategories('123, 432, 765');
$product->setDescription('Here we send the big description of the product');
$product->setBrand('Brand Name'); // tip:
$product->setPrice(123.99);
$product->setSalePrice(99.99);
$product->setSaleStartDate(new DateTime());
$endDate = new DateTime();
$endDate->add(DateInterval::createFromDateString('30 days'));
$product->setSaleEndDate($endDate);
$product->setTaxClass(\SellerCenter\SDK\Product\Enum\TaxClassEnum::DEFAULT());
$product->setShipmentType(\SellerCenter\SDK\Product\Enum\ShipmentTypeEnum::DROPSHIPPING());
$product->setProductId('789000042781');
$product->setCondition(\SellerCenter\SDK\Product\Enum\ConditionEnum::NEW());
$product->setProductData(new \SellerCenter\SDK\Product\AttributeCollection());
$product->getProductData()->add(new \SellerCenter\SDK\Product\Attribute('AttributeOne', 'first value'));
$product->getProductData()->add(new \SellerCenter\SDK\Product\Attribute('AttributeTwo', 'second value'));
$product->getProductData()->add(new \SellerCenter\SDK\Product\Attribute('AttributeThird', 'third value'));
$product->setQuantity(500);
$result = $client->productCreate($product);
} catch (\Exception $e) {
// check exception
}
<Request>
<Product>
<SellerSku>ABC123MOB</SellerSku>
<ParentSku>XYZ999MOB</ParentSku>
<Status>active</Status>
<Name>Product New Name</Name>
<Variation>ABC123MOB-5656</Variation>
<PrimaryCategory>123</PrimaryCategory>
<Categories>123, 432, 765</Categories>
<Description>Here we send the big description of the product</Description>
<Brand>Correct Brand Name</Brand>
<Price>123.99</Price>
<SalePrice>99.99</SalePrice>
<SaleStartDate>2014-12-04T11:18:25-0200</SaleStartDate>
<SaleEndDate>2015-01-03T11:18:25-0200</SaleEndDate>
<TaxClass>default</TaxClass>
<ShipmentType>dropshipping</ShipmentType>
<ProductId>789000042781</ProductId>
<Condition>new</Condition>
<ProductData>
<AttributeOne>first value</AttributeOne>
<AttributeTwo>second value</AttributeTwo>
<AttributeThird>third value</AttributeThird>
</ProductData>
<Quantity>500</Quantity>
</Product>
</Request>
The result of ->productCreate()
will be an instance of SellerCenter\SDK\Common\Api\Response\Success\SuccessResponse
which is a representation of a SuccessResponse from SellerCenter API.
$result->getHead()
// returns a representation of response's Head
$result->getHead()->getRequestId()
// returns the Feed ID that you can use to check result of the queue processing by SellerCenter
- Get available brand names with
$client->getBrands()
-
StatusEnum::ACTIVE()
is just one way to set acceptable "status" values, you can also fill param asnew StatusEnum('active')
or any other valid value -
TaxClassEnum::DEFAULT()
is just one way to set acceptable "tax class" values, you can also fill param asnew TaxClassEnum('default')
or any other valid value -
ShipmentTypeEnum:: DROPSHIPPING()
is just one way to set acceptable "shipment type" values, you can also fill param asnew ShipmentTypeEnum('dropshipping')
or any other valid value -
ConditionEnum::NEW()
is just one way to set acceptable "condition" values, you can also fill param asnew ConditionEnum('new')
or any other valid value