Google Content API for Shopping在线库存状态显示异常求助
Google Merchant Center商品状态显示异常排查(期望"In stock online"却显示"Contact for online availability")
代码中的直接错误
促销价格赋值错误:
代码里创建了Google_Service_ShoppingContent_Price类型的salePrice对象,但调用setSalePrice时直接传入了字符串'379.99',而非该对象;同时salePrice的setValue错误设置为原价579.99。修正代码如下:if ($pcp_on_sale) { $salePrice = new Google_Service_ShoppingContent_Price(); $salePrice->setValue('379.99'); // 改为正确促销价 $salePrice->setCurrency('CAD'); $product->setSalePrice($salePrice); // 传入Price对象 }运费设置类型不匹配:
$shipping->setPrice(0)直接传入数字,但setPrice要求接收Google_Service_ShoppingContent_Price对象,应替换为预先创建的$shipping_price:$shipping->setPrice($shipping_price);GTIN格式违规:
代码中设置的GTIN'HTRYSHDJCND15487'包含字母,而GTIN(全球贸易项目代码)必须是纯数字(如GTIN-8/13等)。非合规GTIN会触发数据验证失败,导致商品状态异常。若商品无合法GTIN,可添加$product->setIdentifierExists(false)(需符合Google Merchant Center规则)。
其他排查方向
- 同步延迟:Google Merchant Center与Shopping页面的数据同步可能需要数小时至24小时,可等待一段时间后再确认状态。
- 后台审核问题:登录Google Merchant Center后台,查看该商品的审核详情,可能存在必填字段缺失、内容违规等未被代码覆盖的问题。
- AvailabilityDate校验:代码中
availabilityDate设为当前时间date('c'),若该值被误设为未来时间,会导致商品显示为待上线状态而非现货。 - 字段一致性:确认
channel为online、availability为in stock的设置未在后续逻辑中被意外修改。
内容的提问来源于stack exchange,提问作者Dinesh
相关产品推荐
相关产品推荐

