Esempio n. 1
0
 protected function processResponseInfo($responseInfo)
 {
     try {
         parent::processResponseInfo($responseInfo);
     } catch (Exception $exception) {
         $message = array(parent::MESSAGE_TYPE_KEY => parent::MESSAGE_TYPE_ERROR, parent::MESSAGE_TEXT_KEY => $exception->getMessage());
         $this->addProductsLogsMessage($this->otherListing, $message, Ess_M2ePro_Model_Log_Abstract::PRIORITY_HIGH);
         if (strpos($exception->getMessage(), 'code:34') === false || $this->account->getChildObject()->isModeSandbox()) {
             throw $exception;
         }
         $this->mayBeDuplicateWasCreated = true;
     }
 }
Esempio n. 2
0
 /**
  * @param array $products
  * @param string $connectorNameSingle
  * @param array $params
  * @return int
  */
 protected function processProducts(array $products, $connectorNameSingle, array $params = array())
 {
     $results = array();
     if (count($products) == 0) {
         return Ess_M2ePro_Model_Connector_Server_Ebay_OtherItem_Abstract::getMainStatus($results);
     }
     if (!class_exists($connectorNameSingle)) {
         return Ess_M2ePro_Model_Connector_Server_Ebay_OtherItem_Abstract::getMainStatus($results);
     }
     $needRemoveLockItem = false;
     $lockItemParams = array('component' => Ess_M2ePro_Helper_Component_Ebay::NICK);
     $lockItem = Mage::getModel('M2ePro/Listing_Other_LockItem', $lockItemParams);
     if ($lockItem->isExist()) {
         if (!isset($params['status_changer']) || $params['status_changer'] != Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) {
             // Parser hack -> Mage::helper('M2ePro')->__('Other listings locked by other process.');
             throw new LogicException("Other listings locked by other process.");
         }
         $lockItem->activate();
     } else {
         $lockItem->create();
         $lockItem->makeShutdownFunction();
         $needRemoveLockItem = true;
     }
     try {
         foreach ($products as $product) {
             $connector = new $connectorNameSingle($params, $product);
             $connector->process();
             $results[] = $connector->getStatus();
         }
     } catch (Exception $exception) {
         Mage::helper('M2ePro/Module_Exception')->process($exception);
         $logModel = Mage::getModel('M2ePro/Listing_Other_Log');
         $logModel->setComponentMode(Ess_M2ePro_Helper_Component_Ebay::NICK);
         $logModel->addGlobalMessage(Ess_M2ePro_Model_Log_Abstract::INITIATOR_UNKNOWN, $this->logsActionId, Ess_M2ePro_Model_Listing_Other_Log::ACTION_UNKNOWN, Mage::helper('M2ePro')->__($exception->getMessage()), Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR, Ess_M2ePro_Model_Log_Abstract::PRIORITY_HIGH);
         $results[] = Ess_M2ePro_Model_Connector_Server_Ebay_Item_Abstract::STATUS_ERROR;
     }
     $needRemoveLockItem && $lockItem->isExist() && $lockItem->remove();
     return Ess_M2ePro_Model_Connector_Server_Ebay_OtherItem_Abstract::getMainStatus($results);
 }
Esempio n. 3
0
 public function execute(Ess_M2ePro_Model_Synchronization_LockItem $lockItem, $percentsFrom, $percentsTo)
 {
     $lockItem->activate();
     $lockItem->setPercents($percentsFrom);
     $lockItem->setStatus(Mage::helper('M2ePro')->__('Communication with eBay is started. Please wait...'));
     // Get prepared for actions array
     //----------------------------
     $actions = $this->makeActionsForExecute();
     //----------------------------
     // Calculate total count items
     //----------------------------
     $totalCount = 0;
     foreach ($actions as $combinations) {
         foreach ($combinations as $combination) {
             $totalCount += count($combination['items']);
         }
     }
     //----------------------------
     $results = array();
     if ($totalCount == 0) {
         $results[] = Ess_M2ePro_Model_Connector_Server_Ebay_Item_Abstract::STATUS_SUCCESS;
     } else {
         // Execute eBay actions
         //----------------------------
         $countProcessedItems = 0;
         $percentsOneProduct = ($percentsTo - $percentsFrom) / $totalCount;
         $waitMessage = Mage::helper('M2ePro')->__('Please wait...');
         foreach ($actions as $action => $combinations) {
             $actionTitle = Ess_M2ePro_Model_Connector_Server_Ebay_OtherItem_Dispatcher::getActionTitle($action);
             foreach ($combinations as $combination) {
                 $tempCount = count($combination['items']);
                 $maxCountPerStep = 10;
                 $tempCount <= 25 && ($maxCountPerStep = 5);
                 $tempCount <= 15 && ($maxCountPerStep = 3);
                 $tempCount <= 8 && ($maxCountPerStep = 2);
                 $tempCount <= 4 && ($maxCountPerStep = 1);
                 for ($i = 0; $i < count($combination['items']); $i += $maxCountPerStep) {
                     $itemsForStep = array_slice($combination['items'], $i, $maxCountPerStep);
                     $countProcessedItems += count($itemsForStep);
                     // Set status for progress bar
                     //-----------------------------
                     $statusProductsIds = array();
                     foreach ($itemsForStep as $item) {
                         $statusProductsIds[] = $item->getData('product_id');
                     }
                     $statusIdsString = Mage::helper('M2ePro')->__('product(s) with id(s)') . ' "' . implode('", "', $statusProductsIds) . '".';
                     $lockItem->setStatus($actionTitle . ' ' . $statusIdsString . ' ' . $waitMessage);
                     //-----------------------------
                     $tempResult = Mage::getModel('M2ePro/Connector_Server_Ebay_OtherItem_Dispatcher')->process($action, $itemsForStep, $combination['params']);
                     $results = array_merge($results, array($tempResult));
                     // Set percents for progress bar
                     //-----------------------------
                     $tempPercents = $percentsFrom + $countProcessedItems * $percentsOneProduct;
                     $lockItem->setPercents($tempPercents > $percentsTo ? $percentsTo : $tempPercents);
                     //-----------------------------
                     $lockItem->activate();
                 }
             }
         }
         //----------------------------
     }
     $lockItem->setStatus(Mage::helper('M2ePro')->__('Communication with eBay is finished. Please wait...'));
     $lockItem->setPercents($percentsTo);
     $lockItem->activate();
     return Ess_M2ePro_Model_Connector_Server_Ebay_OtherItem_Abstract::getMainStatus($results);
 }