I am using google shopping Api from last one year it is working properly. But now I want to add new attributes in it such as CustomLabel5
. For that I have used setCustomAttributes()
method and passed three attributes name
, type
, value
. But it is working showing error 400 invalid attribute values . following is my code please check and suggest proper answer for that.
$product = new Google_Service_ShoppingContent_Product();
$data= new Google_Service_ShoppingContent_ProductCustomAttribute();
$data->setName('CustomLabel5');
$data->setType('text');
$data->setValue('test');
$product->setCustomAttributes($data);
Please give answer.
Fairly simple fix here.
setCustomAttributes
expects an array of Google_Service_ShoppingContent_ProductCustomAttribute
instances.
What you need is:
$attributesArray = array($data);
$product->setCustomAttributes($attributesArray);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.