public function deleteProductBatch($offer_ids) { $entries = array(); foreach ($offer_ids as $key => $offer_id) { $entry = new Google_Service_ShoppingContent_ProductsCustomBatchRequestEntry(); $entry->setMethod('delete'); $entry->setBatchId($key); $entry->setProductId($this->buildProductId($offer_id)); $entry->setMerchantId($this->merchant_id); $entries[] = $entry; } $batch_request = new Google_Service_ShoppingContent_ProductsCustomBatchRequest(); $batch_request->setEntries($entries); $batch_responses = $this->service->products->custombatch($batch_request); $errors = 0; foreach ($batch_responses->entries as $entry) { if (!empty($entry->getErrors())) { $errors++; } } print "Requested delete of batch inserted test products\n"; printf("There were %d errors\n", $errors); }
public function addEntry($product, $productId) { $entry = new \Google_Service_ShoppingContent_ProductsCustomBatchRequestEntry(); $entry->setBatchId($productId); $entry->setMerchantId($this->merchantId); $entry->setMethod($this->method); if ($this->method !== "insert") { $entry->setProductId($productId); } $entry->setProduct($product); $this->entries[] = $entry; }