davidtsadler / ebay-sdk-examples

Several examples of using the eBay SDK for PHP
http://devbay.net
Apache License 2.0
184 stars 100 forks source link

Invalid property type: DTS\eBaySDK\Trading\Types\StoreCustomCategoryArrayType::CustomCategory expected <DTS\eBaySDK\Types\UnboundType>, got <DTS\eBaySDK\Trading\Types\StoreCustomCategoryType> #15

Closed utsav closed 8 years ago

utsav commented 8 years ago

now i'm trying to store custom category to ebay store and i got this error

my code is like this.

`$siteId = Constants\SiteIds::US;

$config = config('configuration');

$service = new Services\TradingService(array( 'apiVersion' => $config['tradingApiVersion'], 'sandbox' => true, 'siteId' => $siteId, 'devId' => $config['sandbox']['devId'], 'appId' => $config['sandbox']['appId'], 'certId' => $config['sandbox']['certId'] ));

$requests = new Types\SetStoreCategoriesRequestType();

$requests->RequesterCredentials = new Types\CustomSecurityHeaderType(); $requests->RequesterCredentials->eBayAuthToken = $config['sandbox']['userToken'];

$requests->Action = 'add'; $requests->ItemDestinationCategoryID = intval(1); $requests->DestinationParentCategoryID = intval(0);

$storeCustomCategoryType = new Types\StoreCustomCategoryType(); $storeCustomCategoryType->Name = 'first 1 category testing'; $storeCustomCategoryType->Order = intval(1);

$storeCustomCategory = new Types\StoreCustomCategoryArrayType(); $storeCustomCategory->CustomCategory = $storeCustomCategoryType;

$StoreCategories[] = $storeCustomCategory;

$requests->StoreCategories = $StoreCategories;`

i can't understand this error please reply me with solution.

utsav commented 8 years ago

Ok, I solved. just set unbound from true to false here

davidtsadler commented 8 years ago

There is no need to edit the code. You will need to set it back to 'true'. The CustomCategory field is known in the API as a repeatable field. This means that more than one value can be assigned to it. The SDK treats repeatable fields as arrays.

You can therefore assign values as follows.

$storeCustomCategory->CustomCategory[] = $storeCustomCategoryType;

To be honest this is not explained in the SDK's docs or code.

You may also need to change $requests->StoreCategories = $StoreCategories; to $requests->StoreCategories = $storeCustomCategory; as the StoreCategories field is not repeatable and can only take one value.

utsav commented 8 years ago

i'm set unbound to true tryout about what you give and it work perfectly. Thank You @davidtsadler .

davidtsadler commented 8 years ago

I've created some gists that show how to use the SDK using the examples from the API docs.

Add eBay store category Delete eBay store category Move eBay store category Move eBay store category to top Rename eBay store category

utsav commented 8 years ago

i think you have to add this to this repo in trading section. but appreciate for your support. thank you.