使用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拒绝了我的提议。

我该怎么做?

预先感谢

zuoduzu 回答:使用PHP从Google Content API for Shopping中删除销售价格

只需设置过去的销售价格生效日期即可,

$saleStartDate = date(DateTime::ISO8601,strtotime('-5 days'));
$saleEndDate = date(DateTime::ISO8601,strtotime('-1 day'));
$product->setSalePriceEffectiveDate($saleStartDate . '/' . $saleEndDate);

还没有尝试过,但是希望可以工作。

本文链接:https://www.f2er.com/1236045.html

大家都在问