对于一个项目,我必须在Google Merchant Center中自动化产品的更新过程。这些产品是通过以Google表格作为输入方法的Feed添加的。这是“主要供稿”。
根据v2.1 api的文档,可以通过补充Feed来完成通过主Feed添加的产品更新(请参见:https://developers.google.com/shopping-content/guides/products/supplemental-feeds/using-supplemental-feeds)。此补充Feed仅允许更新部分产品属性。
使用补充Feed的Feed ID,我可以插入单个产品。但是,由于api http请求限制和要更新的大量产品,我需要使用批处理方法。不幸的是,我似乎无法正常工作。
TL; DR插入单个产品有效,但是使用custombatch方法插入产品无效。批处理方法的响应似乎还可以,但对Google Merchant Center仪表板没有影响。
实施
服务:
service = build('content','v2.1',credentials=scoped_credentials)
通过我的补充Feed更新单个产品可以使用以下代码。
/*
product = {'title': 'Single update 12-42','price': {'value': '69','currency': 'EUR'},'offerId': 'abcd1','contentLanguage': 'en','targetcountry': 'NL','channel': 'online','availability': 'out of stock'}
*/
result = service.products().insert(merchantId=MERCHANT_ID,body=product,feedId=FEED_ID).execute()
/*
result = {'kind': 'content#product','id': 'online:en:NL:abcd1','channel': 'online'}
*/
但是,通过批处理请求进行更新没有效果。
/*
body = {'entries': [{'batchId': 1,'merchantId': MERCHANT_ID,'method': 'insert','feedId': FEED_ID,'product': {'title': 'Batch update 12-44','offerId': 'abcd2','availability': 'out of stock'}}]}
*/
result = service.products().custombatch(body=body).execute()
/*
result = {'kind': 'content#productsCustomBatchResponse','entries': [{'kind': 'content#productsCustomBatchResponseEntry','batchId': 1,'product': {'kind': 'content#product','id': 'online:en:NL:abcd2','channel': 'online'}}]}
*/
值得注意的是,我确实收到了有效的答复,没有任何错误。但是,使用批处理方法(在单个插入项中)对商人中心仪表板没有影响。
还有其他人遇到相同的问题,还是我错过了什么?