如何解决使用PHP从Google Content API for Shopping中删除销售价格
我可以通过Google Content API for Shopping使用PHP语言在Google Merchant Feed中更新(更改其他价格)产品的销售价格。
示例。折扣40%的产品(原价= 100.00欧元,促销价= 60.00欧元):
$product = new Google_Service_ShoppingContent_Product();
$product->setOfferId($myProductId);
$product->setContentLanguage($idData[1]);
$product->setTargetCountry($idData[2]);
$product->setChannel($idData[0]);
$price = new Google_Service_ShoppingContent_Price();
$price->setValue(100.00);
$price->setCurrency('EUR');
$product->setPrice($price);
$salePrice = new Google_Service_ShoppingContent_Price();
$salePrice->setValue(60.00);
$salePrice->setCurrency('EUR');
$product->setSalePrice($salePrice);
我无法删除此折扣,我希望我的产品最终价格再次100.00欧元。我尝试过:
$product->setSalePrice(NULL);
但是我遇到了致命错误:
参数1传递给 Google_Service_ShoppingContent_Product :: setSalePrice()必须为 Google_Service_ShoppingContent_Price的实例
我还尝试将值设置为0
$salePrice = new Google_Service_ShoppingContent_Price();
$salePrice->setValue(0.00);
$salePrice->setCurrency('EUR');
但是Google拒绝了我的提议。
我该怎么做?
预先感谢
解决方法
只需设置过去的销售价格生效日期即可,
$saleStartDate = date(DateTime::ISO8601,strtotime('-5 days'));
$saleEndDate = date(DateTime::ISO8601,strtotime('-1 day'));
$product->setSalePriceEffectiveDate($saleStartDate . '/' . $saleEndDate);
还没有尝试过,但是希望可以工作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。