Beispiel #1
0
 /**
  * Tests that product update API requests can be made.
  */
 public function testSendingProductUpdate()
 {
     $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->update();
     $this->specify('successful product update', function () use($result) {
         $this->assertTrue($result);
     });
 }
 /**
  * Sends a product update API request to Nosto.
  *
  * @param Product $product the product that has been updated.
  */
 public function update(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->update();
         } catch (NostoException $e) {
             Nosto::helper('nosto_tagging/logger')->error(__CLASS__ . '::' . __FUNCTION__ . ' - ' . $e->getMessage(), $e->getCode(), get_class($product), (int) $product->id);
         }
     }
 }