/**
  * Send product data to PredictionIO
  *
  * @param $collection
  * @return int
  */
 protected function _sendProductData($collection)
 {
     $collectionCount = count($collection);
     $sentProductCount = 0;
     foreach ($collection as $productId) {
         $sentProduct = $this->_sendToPredictionIO($productId);
         $exportItem = $this->_export->saveProductForExport($productId);
         $this->_setProductExported($exportItem->getId());
         if ($sentProduct) {
             ++$sentProductCount;
         }
     }
     if ($collectionCount != $sentProductCount) {
         throw new Exception('There was a problem sending the product data, check the log file for more information');
     }
     return $sentProductCount;
 }
 /**
  * Check the product exists in the export table
  *
  * @param $productId
  * @return bool
  */
 private function _isReadyForExport($productId)
 {
     $product = $this->_export->getCollection()->addFieldToFilter('product_id', $productId)->getFirstItem();
     return $product->getData("product_id") ? true : false;
 }