/** * Sends a batch product re-crawl request to nosto. * * @param NostoExportProductCollection $collection the product collection to re-crawl. * @param NostoAccountInterface $account the account to re-crawl the products for. * @return bool true on success, false otherwise. * @throws NostoException if the request fails or cannot be made. */ public static function sendBatch(NostoExportProductCollection $collection, NostoAccountInterface $account) { if ($collection->count() === 0) { throw new NostoException('Failed to send product re-crawl to Nosto. No products in collection.'); } $payload = array('products' => array()); foreach ($collection->getArrayCopy() as $product) { /** @var NostoProductInterface $product */ $payload['products'][] = array('product_id' => $product->getProductId(), 'url' => $product->getUrl()); } return self::sendRequest($account, $payload); }
/** * Tests that the export collection does not accept stdClass items. */ public function testCollectionValidationForObject() { $this->setExpectedException('NostoException'); $collection = new NostoExportProductCollection(); $collection->append(new stdClass()); }