1

我从去年开始使用谷歌购物 Api,它工作正常。但现在我想在其中添加新属性,例如CustomLabel5. 为此,我使用setCustomAttributes()了方法并传递了三个属性name, type, value但它正在显示错误 400 无效属性值。以下是我的代码,请检查并建议正确的答案。

$product = new Google_Service_ShoppingContent_Product();
$data= new Google_Service_ShoppingContent_ProductCustomAttribute();
$data->setName('CustomLabel5');
$data->setType('text');
$data->setValue('test');
$product->setCustomAttributes($data);

请给出答案。

4

1 回答 1

0

相当简单的修复在这里。

setCustomAttributesGoogle_Service_ShoppingContent_ProductCustomAttribute需要一个实例数组。

你需要的是:

$attributesArray = array($data);
$product->setCustomAttributes($attributesArray);
于 2018-05-25T17:05:37.060 回答