/** * Save the new product ready for export * * @param $productId */ private function _saveProductForExport($productId) { if (!$this->_isReadyForExport($productId)) { $exportItem = $this->_export->saveProductForExport($productId); $this->_eventManager->dispatch('personalised_products_export_after_save', ['exportItem' => $exportItem]); } }
/** * 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; }