/** * Sends a product create API request to Nosto. * * @param Product $product the product that has been created. */ public function create(Product $product) { if (!Validate::isLoadedObject($product) || in_array($product->id, self::$_processed_products)) { return; } self::$_processed_products[] = $product->id; foreach ($this->getAccountData() as $data) { list($account, $id_shop, $id_lang) = $data; $nosto_product = $this->loadNostoProduct((int) $product->id, $id_lang, $id_shop); if (is_null($nosto_product)) { continue; } try { $op = new NostoOperationProduct($account); $op->addProduct($nosto_product); $op->create(); } catch (NostoException $e) { Nosto::helper('nosto_tagging/logger')->error(__CLASS__ . '::' . __FUNCTION__ . ' - ' . $e->getMessage(), $e->getCode(), get_class($product), (int) $product->id); } } }
/** * Tests that product create API requests can be made. */ public function testSendingProductCreate() { $account = new NostoAccount('platform-00000000'); $product = new NostoProduct(); $token = new NostoApiToken('products', '01098d0fc84ded7c4226820d5d1207c69243cbb3637dc4bc2a216dafcf09d783'); $account->addApiToken($token); $op = new NostoOperationProduct($account); $op->addProduct($product); $result = $op->create(); $this->specify('successful product create', function () use($result) { $this->assertTrue($result); }); }