Probieren Sie den Status "On -Stock Online" in der Google Content -API zum Einkaufen ausPhp

PHP-Programmierer chatten hier
Anonymous
 Probieren Sie den Status "On -Stock Online" in der Google Content -API zum Einkaufen aus

Post by Anonymous »

Ich verwende die Google Content -API, um meine Produktlisten im Google Merchant Center zu aktualisieren. Wenn ich das Produkt jedoch auf der Google -Einkaufsseite ansehe, zeigt es den Status als „Kontakt für Online -Verfügbarkeit“ anstelle von „auf Lager online“ an.

Code: Select all

$credentialsFilePath = 'content-api-key.json';

$client = new Google_Client();
$client->setAuthConfig($credentialsFilePath);
$client->setScopes('https://www.googleapis.com/auth/content');
$client->fetchAccessTokenWithAssertion();
$token = $client->getAccessToken();
$client->setAccessToken($token['access_token']);
$service = new Google_Service_ShoppingContent($client);

$product = new Google_Service_ShoppingContent_Product();
$product->setOfferId('789');
$product->setTitle('Low Profile Flush Mount Hard');
$product->setDescription('Lorem IPsum');
$product->setLink('https://dummy.com');
$product->setImageLink('https://dummy.com/img.png');
$product->setContentLanguage('en');
$product->setTargetCountry('CA');
$product->setChannel('online');
$product->setAvailability('in stock');
$product->setCondition('new');
$product->setProductTypes('Hardware');
$product->setSellOnGoogleQuantity(5);
$product->setAvailabilityDate(date('c'));
$product->setGtin('QWERTY123');
$product->setBrand('Test');
$price = new Google_Service_ShoppingContent_Price();
$price->setValue('99.99');
$price->setCurrency('CAD');
$product->setPrice($price);

if ($pcp_on_sale) {
$salePrice = new Google_Service_ShoppingContent_Price();
$salePrice->setValue('99.99');
$salePrice->setCurrency('CAD');
$product->setSalePrice('79.99');
}

$shipping_price = new Google_Service_ShoppingContent_Price();
$shipping_price->setValue($shippingAmount);
$shipping_price->setCurrency('CAD');

$shipping = new Google_Service_ShoppingContent_ProductShipping();
$shipping->setPrice(0);
$shipping->setCountry('CA');
$shipping->setService('Standard shipping');
$product->setShipping(array($shipping));
$result = $service->products->insert('7894563251', $product);

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post