/**
  * Send the query to PredictionIO engine for product data set
  *
  * @param array $productIds
  * @param array $categories
  * @param array $whitelist
  * @param array $blacklist
  * @return array|bool
  */
 public function sendQuery(array $productIds, array $categories = [], array $whitelist = [], array $blacklist = [])
 {
     try {
         $data = ['items' => $productIds, 'num' => (int) $this->_config->getProductCount(Config::COMPLEMENTARY_PRODUCT_COUNT)];
         return $this->_engineClient->sendQuery($data);
     } catch (\Exception $e) {
         $this->_logger->addCritical($e);
     }
     return false;
 }
 /**
  * Send the query to PredictionIO engine for product data set
  *
  * @param array $productIds
  * @param array $categories
  * @param array $whitelist
  * @param array $blacklist
  * @return array|bool
  */
 public function sendQuery(array $productIds, array $categories = [], array $whitelist = [], array $blacklist = [])
 {
     try {
         $data = ['items' => $productIds, 'num' => (int) $this->_config->getProductCount(Config::SIMILARITY_PRODUCT_COUNT)];
         $this->_addProperties('categories', $data, $categories);
         $this->_addProperties('whitelist', $data, $whitelist);
         $this->_addProperties('blacklist', $data, $blacklist);
         return $this->_engineClient->sendQuery($data);
     } catch (\Exception $e) {
         $this->_logger->addCritical($e);
     }
     return false;
 }
 /**
  * Mark product as exported in DB
  *
  * @param $exportId
  */
 private function _setProductExported($exportId)
 {
     $export = $this->_exportFactory->create()->load($exportId);
     $export->setData('is_exported', '1');
     try {
         $export->save();
     } catch (\Exception $e) {
         $this->_logger->addCritical($e->getMessage());
     }
 }
 /**
  * Save the new export item with Product Id
  *
  * @param $productId
  * @return Export
  */
 public function saveProductForExport($productId)
 {
     $exportItem = $this->_exportFactory->create();
     $exportItem->setData('product_id', $productId);
     try {
         $exportItem->save();
     } catch (\Exception $e) {
         $this->_logger->addError($e->getMessage());
     }
     return $exportItem;
 }
 /**
  * Update the database row with the `is_exported` as 1
  */
 private function _updateDatabase()
 {
     foreach ($this->_getExportedProducts() as $productId) {
         $model = $this->_getItemModel($productId);
         $model->setData('is_exported', '1');
         try {
             $model->save();
         } catch (\Exception $e) {
             $this->_logger->addCritical($e->getMessage());
         }
     }
 }