Example #1
0
 public function process()
 {
     Mage::helper('M2ePro/Client')->setMemoryLimit(512);
     Mage::helper('M2ePro/Module_Exception')->setFatalErrorHandler();
     // Check global mode
     //----------------------------------
     if (!(bool) Mage::helper('M2ePro/Module')->getSynchronizationConfig()->getGlobalValue('mode')) {
         return false;
     }
     //----------------------------------
     // Before dispatch actions
     //---------------------------
     if (!$this->beforeDispatch()) {
         return false;
     }
     //---------------------------
     if (in_array(Ess_M2ePro_Model_Synchronization_Tasks::ORDERS, $this->_tasks)) {
         Mage::dispatchEvent('m2epro_synchronization_before_start', array());
     }
     try {
         // DEFAULTS SYNCH
         //---------------------------
         $tempTask = $this->checkTask(Ess_M2ePro_Model_Synchronization_Tasks::DEFAULTS);
         $tempGlobalMode = (bool) (int) Mage::helper('M2ePro/Module')->getSynchronizationConfig()->getGroupValue('/defaults/', 'mode');
         if ($tempTask && $tempGlobalMode) {
             $tempSynch = new Ess_M2ePro_Model_Synchronization_Tasks_Defaults();
             $tempSynch->process();
         }
         //---------------------------
     } catch (Exception $exception) {
         $this->catchException($exception);
     }
     try {
         // EBAY SYNCH
         //---------------------------
         if (Mage::helper('M2ePro/Component_Ebay')->isActive() && $this->checkComponent(Ess_M2ePro_Helper_Component_Ebay::NICK)) {
             $synchDispatcher = Mage::getModel('M2ePro/Ebay_Synchronization_Dispatcher');
             $synchDispatcher->setInitiator($this->_initiator);
             $synchDispatcher->setTasks($this->_tasks);
             $synchDispatcher->setParams($this->_params);
             $synchDispatcher->process();
         }
         //---------------------------
     } catch (Exception $exception) {
         $this->catchException($exception);
     }
     try {
         // AMAZON SYNCH
         //---------------------------
         if (Mage::helper('M2ePro/Component_Amazon')->isActive() && $this->checkComponent(Ess_M2ePro_Helper_Component_Amazon::NICK)) {
             $synchDispatcher = Mage::getModel('M2ePro/Amazon_Synchronization_Dispatcher');
             $synchDispatcher->setInitiator($this->_initiator);
             $synchDispatcher->setTasks($this->_tasks);
             $synchDispatcher->setParams($this->_params);
             $synchDispatcher->process();
         }
         //---------------------------
     } catch (Exception $exception) {
         $this->catchException($exception);
     }
     try {
         // BUY SYNCH
         //---------------------------
         if (Mage::helper('M2ePro/Component_Buy')->isActive() && $this->checkComponent(Ess_M2ePro_Helper_Component_Buy::NICK)) {
             $synchDispatcher = Mage::getModel('M2ePro/Buy_Synchronization_Dispatcher');
             $synchDispatcher->setInitiator($this->_initiator);
             $synchDispatcher->setTasks($this->_tasks);
             $synchDispatcher->setParams($this->_params);
             $synchDispatcher->process();
         }
         //---------------------------
     } catch (Exception $exception) {
         $this->catchException($exception);
     }
     try {
         // PLAY SYNCH
         //---------------------------
         if (Mage::helper('M2ePro/Component_Play')->isActive() && $this->checkComponent(Ess_M2ePro_Helper_Component_Play::NICK)) {
             $synchDispatcher = Mage::getModel('M2ePro/Play_Synchronization_Dispatcher');
             $synchDispatcher->setInitiator($this->_initiator);
             $synchDispatcher->setTasks($this->_tasks);
             $synchDispatcher->setParams($this->_params);
             $synchDispatcher->process();
         }
         //---------------------------
     } catch (Exception $exception) {
         $this->catchException($exception);
     }
     if (in_array(Ess_M2ePro_Model_Synchronization_Tasks::ORDERS, $this->_tasks)) {
         Mage::dispatchEvent('m2epro_synchronization_after_end', array());
     }
     // After dispatch actions
     //---------------------------
     if (!$this->afterDispatch()) {
         return false;
     }
     //---------------------------
     return true;
 }
Example #2
0
 public function process()
 {
     // Check global mode
     //----------------------------------
     if (!(bool) Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/synchronization/settings/', 'mode')) {
         return false;
     }
     //----------------------------------
     // Before dispatch actions
     //---------------------------
     if (!$this->beforeDispatch()) {
         return false;
     }
     //---------------------------
     try {
         // DEFAULTS SYNCH
         //---------------------------
         $tempTask = $this->checkTask(Ess_M2ePro_Model_Synchronization_Tasks::DEFAULTS);
         $tempGlobalMode = (bool) (int) Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/synchronization/settings/defaults/', 'mode');
         if ($tempTask && $tempGlobalMode) {
             $tempSynch = new Ess_M2ePro_Model_Synchronization_Tasks_Defaults();
             $tempSynch->process();
         }
         //---------------------------
     } catch (Exception $exception) {
         $this->catchException($exception);
     }
     try {
         // EBAY SYNCH
         //---------------------------
         if (Mage::helper('M2ePro/Component_Ebay')->isActive() && $this->checkComponent(Ess_M2ePro_Helper_Component_Ebay::NICK)) {
             $synchDispatcher = Mage::getModel('M2ePro/Ebay_Synchronization_Dispatcher');
             $synchDispatcher->setInitiator($this->_initiator);
             $synchDispatcher->setTasks($this->_tasks);
             $synchDispatcher->setParams($this->_params);
             $synchDispatcher->process();
         }
         //---------------------------
     } catch (Exception $exception) {
         $this->catchException($exception);
     }
     try {
         // AMAZON SYNCH
         //---------------------------
         if (Mage::helper('M2ePro/Component_Amazon')->isActive() && $this->checkComponent(Ess_M2ePro_Helper_Component_Amazon::NICK)) {
             $synchDispatcher = Mage::getModel('M2ePro/Amazon_Synchronization_Dispatcher');
             $synchDispatcher->setInitiator($this->_initiator);
             $synchDispatcher->setTasks($this->_tasks);
             $synchDispatcher->setParams($this->_params);
             $synchDispatcher->process();
         }
         //---------------------------
     } catch (Exception $exception) {
         $this->catchException($exception);
     }
     try {
         // BUY SYNCH
         //---------------------------
         if (Mage::helper('M2ePro/Component_Buy')->isActive() && $this->checkComponent(Ess_M2ePro_Helper_Component_Buy::NICK)) {
             $synchDispatcher = Mage::getModel('M2ePro/Buy_Synchronization_Dispatcher');
             $synchDispatcher->setInitiator($this->_initiator);
             $synchDispatcher->setTasks($this->_tasks);
             $synchDispatcher->setParams($this->_params);
             $synchDispatcher->process();
         }
         //---------------------------
     } catch (Exception $exception) {
         $this->catchException($exception);
     }
     // After dispatch actions
     //---------------------------
     if (!$this->afterDispatch()) {
         return false;
     }
     //---------------------------
     return true;
 }
Example #3
0
 public function process(array $tasks, $initiator = Ess_M2ePro_Model_Synchronization_Runs::INITIATOR_UNKNOWN, array $params = array())
 {
     // Stop if tasks empty
     //---------------------------
     if (count($tasks) == 0) {
         return false;
     }
     $this->_tasks = $tasks;
     //---------------------------
     // Stop if wrong initiator
     //---------------------------
     if ($initiator !== Ess_M2ePro_Model_Synchronization_Runs::INITIATOR_CRON && $initiator !== Ess_M2ePro_Model_Synchronization_Runs::INITIATOR_USER && $initiator !== Ess_M2ePro_Model_Synchronization_Runs::INITIATOR_DEVELOPER && $initiator !== Ess_M2ePro_Model_Synchronization_Runs::INITIATOR_UNKNOWN) {
         return false;
     }
     $this->_initiator = $initiator;
     //---------------------------
     // Prepare params
     //---------------------------
     $this->_params = $params;
     //---------------------------
     // Execute before dispatch actions
     //---------------------------
     if (!$this->beforeDispatch()) {
         return false;
     }
     //---------------------------
     // Set memory limit
     //----------------------------------
     $memLimitResult = $this->setMemoryLimit();
     /*if ($memLimitResult === false) {
           Mage::registry('synchLogs')->addMessage('Set memory limit failed.',
                                                   Ess_M2ePro_Model_Synchronization_Logs::TYPE_WARNING,
                                                   Ess_M2ePro_Model_Synchronization_Logs::PRIORITY_MEDIUM);
           Mage::registry('synchProfiler')->addTitle('Set memory limit failed.',Ess_M2ePro_Model_Profiler::TYPE_WARNING);
       }*/
     //----------------------------------
     try {
         // DEFAULTS SYNCH
         //---------------------------
         $tempTask = $this->checkTask(Ess_M2ePro_Model_Synchronization_Tasks::DEFAULTS);
         $tempMode = (bool) (int) Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/synchronization/settings/defaults/', 'mode');
         if ($tempTask && $tempMode) {
             $tempSynch = new Ess_M2ePro_Model_Synchronization_Tasks_Defaults();
             $tempSynch->process();
         }
         //---------------------------
         // ORDERS SYNCH
         //---------------------------
         $tempTask = $this->checkTask(Ess_M2ePro_Model_Synchronization_Tasks::ORDERS);
         $tempMode = (bool) (int) Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/synchronization/settings/orders/', 'mode');
         if ($tempTask && $tempMode) {
             $tempSynch = new Ess_M2ePro_Model_Synchronization_Tasks_Orders();
             $tempSynch->process();
         }
         //---------------------------
         // TEMPLATES SYNCH
         //---------------------------
         $tempTask = $this->checkTask(Ess_M2ePro_Model_Synchronization_Tasks::TEMPLATES);
         $tempMode = (bool) (int) Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/synchronization/settings/templates/', 'mode');
         if ($tempTask && $tempMode) {
             $tempSynch = new Ess_M2ePro_Model_Synchronization_Tasks_Templates();
             $tempSynch->process();
         }
         //---------------------------
         // FEEDBACKS SYNCH
         //---------------------------
         $tempTask = $this->checkTask(Ess_M2ePro_Model_Synchronization_Tasks::FEEDBACKS);
         $tempMode = (bool) (int) Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/synchronization/settings/feedbacks/', 'mode');
         if ($tempTask && $tempMode) {
             $tempSynch = new Ess_M2ePro_Model_Synchronization_Tasks_Feedbacks();
             $tempSynch->process();
         }
         //---------------------------
         // MESSAGES SYNCH
         //---------------------------
         $tempTask = $this->checkTask(Ess_M2ePro_Model_Synchronization_Tasks::MESSAGES);
         $tempMode = (bool) (int) Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/synchronization/settings/messages/', 'mode');
         if ($tempTask && $tempMode) {
             $tempSynch = new Ess_M2ePro_Model_Synchronization_Tasks_Messages();
             $tempSynch->process();
         }
         //---------------------------
         // MARKETPLACES SYNCH
         //---------------------------
         $tempTask = $this->checkTask(Ess_M2ePro_Model_Synchronization_Tasks::MARKETPLACES);
         $tempMode = (bool) (int) Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/synchronization/settings/marketplaces/', 'mode');
         if ($tempTask && $tempMode) {
             $tempSynch = new Ess_M2ePro_Model_Synchronization_Tasks_Marketplaces();
             $tempSynch->process();
         }
         //---------------------------
         // EBAY LISTINGS SYNCH
         //---------------------------
         $tempTask = $this->checkTask(Ess_M2ePro_Model_Synchronization_Tasks::EBAY_LISTINGS);
         $tempMode = (bool) (int) Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/synchronization/settings/ebay_listings/', 'mode');
         if ($tempTask && $tempMode) {
             $tempSynch = new Ess_M2ePro_Model_Synchronization_Tasks_EbayListings();
             $tempSynch->process();
         }
         //---------------------------
     } catch (Exception $exception) {
         try {
             Mage::helper('M2ePro/Exception')->process($exception, true);
         } catch (Exception $exceptionTemp) {
         }
         Mage::registry('synchLogs')->addMessage(Mage::helper('M2ePro')->__($exception->getMessage()), Ess_M2ePro_Model_Synchronization_Logs::TYPE_ERROR, Ess_M2ePro_Model_Synchronization_Logs::PRIORITY_HIGH);
         Mage::registry('synchProfiler')->addTitle(Mage::helper('M2ePro')->__($exception->getMessage()), Ess_M2ePro_Model_Profiler::TYPE_ERROR);
         return false;
     }
     return true;
 }