/**
  * @param $productId
  * @return bool|void
  */
 public function processViews($productId)
 {
     if (!$this->_config->isEnabled()) {
         return false;
     }
     if ($this->_customerSession->isLoggedIn()) {
         return $this->_eventClient->saveCustomerViewProduct($this->_customerSession->getCustomerId(), $productId);
     }
     return false;
 }
 /**
  * Send customer-buys-item events to PredictionIO for all existing orders
  *
  * @param $customerId
  * @param $products
  * @return bool
  */
 protected function _sendPurchaseEvent($customerId, $products)
 {
     foreach ($products as $productId) {
         if (!$this->_eventClient->saveCustomerBuyProduct($customerId, $productId)) {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 3
0
 /**
  * Method called on the cron to do the export
  *
  * @return bool
  */
 public function export()
 {
     $productExport = $this->_getProductsForExport();
     $productCount = count($productExport);
     $exportCount = 0;
     foreach ($productExport as $productId => $categories) {
         try {
             $this->_eventClient->saveProductData($productId, $categories);
             $this->_setExportedProducts($productId);
             ++$exportCount;
         } catch (\Exception $e) {
             $this->_logger->addCritical("Product ID - {$productId} failed to export: " . $e);
             return false;
         }
     }
     $this->_updateDatabase();
     $this->_logger->addInfo("Successfully exported " . $exportCount . " out " . $productCount . " products ");
     return true;
 }
 /**
  * Send all the guest product views to PredictionIO when we get the customers ID
  *
  * @param $guestProductViews
  */
 private function _sendAllGuestProductViews($guestProductViews)
 {
     foreach ($guestProductViews as $productId) {
         $this->_eventClient->saveCustomerViewProduct($this->_customerSession->getCustomerId(), $productId);
     }
 }
 /**
  * Send the new product to PredictionIO
  *
  * @param $productId
  * @return bool
  */
 private function _sendToPredictionIO($productId)
 {
     return $this->_eventClient->saveProductData($productId, $this->_getProductCategoryCollection($productId));
 }