/** * @param $eBayProduct * @param Product $product * @return \DTS\eBaySDK\Trading\Types\ReviseInventoryStatusResponseType|null * @throws EbayErrorException * @throws \StoreIntegrator\Exceptions\MissingTokenException */ private function checkAndRevisePriceAndQuantity($eBayProduct, Product $product) { $inventoryChanges = []; if ($product->hasVariations()) { foreach ($product->getVariationOptions() as $option) { $inventoryChanges[] = ['sku' => $option['sku'], 'quantity' => $option['quantity'], 'price' => $option['price']]; } } else { $inventoryChanges[] = ['sku' => $product->getSku(), 'quantity' => $product->getQuantity(), 'price' => $product->getPrice()]; } $chunks = array_chunk($inventoryChanges, 4); $response = null; foreach ($chunks as $chunk) { foreach ($chunk as $inventoryData) { $request = new ReviseInventoryStatusRequestType(); $inventory = new InventoryStatusType(); $inventory->SKU = $inventoryData['sku']; $inventory->Quantity = $inventoryData['quantity']; $inventory->StartPrice = new AmountType(array('value' => doubleval($inventoryData['price']))); $request->InventoryStatus[] = $inventory; $this->addAuthToRequest($request); $response = $this->service->reviseInventoryStatus($request); if ($response->Ack == 'Failure') { $this->handleError($response); } } } return $response; }