2

Google Merchant Center に商品を掲載しようとしています。現在、Google API PHP クライアントを使用していますが、どのクラスおよびそれを拡張するクラスにも toSimpleObject 関数が見つかりません。

$this->service = new Google_Service_ShoppingContent($client);

$product = array("batchId" => $batchID,
                      "merchantId" => $this->googleapi->merchantID,
                      "method" => "insert",
                      "product" => array(
                        "kind" => "content#product",
                        "offerId" => $skuDetails['SKU'],
                        "title" => $skuDetails['TITLE'],
                        "description" => $skuDetails['DESCRIPTION'],
                        "imageLink" => $skuDetails['IMAGE'],
                        "contentLanguage" => "en",
                        "targetCountry" => "US",
                        "channel" => "online",
                        "availability" => ($skuDetails['QUANTITY'] > 0)?'in stock':'out of stock',
                        "brand" => $skuDetails['BRAND'],
                        "condition" => $skuDetails['CONDITION'],
                        "minHandlingTime" => $skuDetails['HANDLING_TIME'],
                        "ageGroup" => 'adult',
                        "maxHandlingTime" => ($skuDetails['HANDLING_TIME'] + 2),
                        "googleProductCategory" => (empty($skuDetails['CATEGORYID']))?$skuDetails['CATEGORYPATH']:$skuDetails['CATEGORYID'],
                        "price" => [
                          "value" => $price['lp'],
                          "currency" => "USD"
                        ]
                      )
                    );


$productObject = new Google_Service_ShoppingContent_ProductsCustomBatchRequest();
$productObject->setEntries($product);

$result = $this->service->products->custombatch($productObject);

エラー:

An uncaught Exception was encountered
Type: Error

Message: Call to undefined method Google_Service_ShoppingContent_ProductsCustomBatchRequest::toSimpleObject()

Line Number: 108

Backtrace:

File: vendor/google/apiclient-services/src/Google/Service/ShoppingContent/Resource/Products.php
Line: 40
Function: call
4

1 に答える 1

0

製品インスタンスにデータを挿入するために使用する必要がありGoogle_Service_ShoppingContent_Productます。その後、custombatch を使用してアップロードできます

 $product = new Google_Service_ShoppingContent_Product();

 $product->setId($id);
 $product->setTitle($title);
于 2019-08-16T11:22:17.877 に答える