예제 #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->getLogger()->logListingOtherMessage($this->otherListing, $message, Ess_M2ePro_Model_Log_Abstract::PRIORITY_HIGH);
         throw $exception;
     }
 }
예제 #2
0
 protected function getRequestInfo()
 {
     if (isset($this->cache['request_info'])) {
         return $this->cache['request_info'];
     }
     if (!isset($this->params['__request_info__']) || !is_array($this->params['__request_info__']) || count($this->params['__request_info__']) <= 0) {
         $this->cache['request_info'] = parent::getRequestInfo();
     } else {
         $this->cache['request_info'] = $this->params['__request_info__'];
         unset($this->params['__request_info__']);
     }
     return $this->cache['request_info'];
 }
예제 #3
0
 public function process()
 {
     if (!$this->isNeedSendRequest()) {
         return false;
     }
     $result = parent::process();
     foreach ($this->messages as $message) {
         if ($message[parent::MESSAGE_TYPE_KEY] != parent::MESSAGE_TYPE_ERROR) {
             continue;
         }
         $this->order->addErrorLog('eBay Order status was not updated. Reason: %msg%', array('msg' => $message[parent::MESSAGE_TEXT_KEY]));
     }
     return $result;
 }
예제 #4
0
 public function process()
 {
     if (!$this->isNeedSendRequest()) {
         return false;
     }
     $result = parent::process();
     foreach ($this->messages as $message) {
         if ($message[parent::MESSAGE_TYPE_KEY] != parent::MESSAGE_TYPE_ERROR) {
             continue;
         }
         $message = 'Shipping status was not updated (Item: %item_id%, Transaction: %trn_id%). Reason: %msg%';
         $this->orderItem->getOrder()->addErrorLog($message, array('!item_id' => $this->orderItem->getChildObject()->getItemId(), '!trn_id' => $this->orderItem->getChildObject()->getTransactionId(), 'msg' => $message[parent::MESSAGE_TEXT_KEY]));
     }
     return $result;
 }
예제 #5
0
 public function process()
 {
     try {
         $this->getLogger()->setStatus(Ess_M2ePro_Helper_Data::STATUS_SUCCESS);
         if (!$this->isNeedSendRequest()) {
             return array();
         }
         $this->eventBeforeProcess();
         $result = parent::process();
     } catch (Exception $exception) {
         $this->eventAfterProcess();
         throw $exception;
     }
     $this->eventAfterProcess();
     return $result;
 }
예제 #6
0
 public function process()
 {
     if (!$this->isNeedSendRequest()) {
         return false;
     }
     $result = parent::process();
     foreach ($this->messages as $message) {
         if ($message[parent::MESSAGE_TYPE_KEY] != parent::MESSAGE_TYPE_ERROR) {
             continue;
         }
         $this->orderItem->getOrder()->addErrorLog('Unpaid Item Process was not open for Item #%id%. Reason: %msg%', array('!id' => $this->orderItem->getChildObject()->getItemId(), 'msg' => $message[parent::MESSAGE_TEXT_KEY]));
         if (isset($message[parent::MESSAGE_CODE_KEY]) && in_array($message[parent::MESSAGE_CODE_KEY], array(16207, 16212))) {
             $this->orderItem->setData('unpaid_item_process_state', Ess_M2ePro_Model_Ebay_Order_Item::UNPAID_ITEM_PROCESS_OPENED);
             $this->orderItem->save();
         }
     }
     return $result;
 }
예제 #7
0
 public function process()
 {
     $this->getLogger()->setStatus(Ess_M2ePro_Helper_Data::STATUS_SUCCESS);
     if (!$this->isNeedSendRequest()) {
         return array();
     }
     $this->eventBeforeProcess();
     try {
         $result = parent::process();
     } catch (Exception $exception) {
         $this->eventAfterProcess();
         throw $exception;
     }
     $this->eventAfterProcess();
     foreach ($this->messages as $message) {
         $priority = Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM;
         if ($message[parent::MESSAGE_TYPE_KEY] == parent::MESSAGE_TYPE_ERROR) {
             $priority = Ess_M2ePro_Model_Log_Abstract::PRIORITY_HIGH;
         }
         $this->getLogger()->logListingOtherMessage($this->otherListing, $message, $priority);
     }
     return $result;
 }
 private function getProductDatesChanges(Ess_M2ePro_Model_Listing_Product $listingProduct, array $change)
 {
     return array('start_date' => Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($change['startTime']), 'end_date' => Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($change['endTime']));
 }
예제 #9
0
 protected function appendStartDateEndDateValues($data, $response)
 {
     if (isset($response['ebay_start_date_raw'])) {
         $data['start_date'] = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($response['ebay_start_date_raw']);
     }
     if (isset($response['ebay_end_date_raw'])) {
         $data['end_date'] = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($response['ebay_end_date_raw']);
     }
     return $data;
 }
예제 #10
0
 /**
  * @param Ess_M2ePro_Model_Connector_Ebay_Requester|Ess_M2ePro_Model_Connector_Ebay_Abstract $connector
  * @return mixed
  */
 public function process($connector)
 {
     return $connector->process();
 }
 private function prepareChangedListingsProducts(Ess_M2ePro_Model_Listing_Product $tempListingProductModel, $ebayChange)
 {
     /** @var $tempEbayListingProductModel Ess_M2ePro_Model_Ebay_Listing_Product */
     $tempEbayListingProductModel = $tempListingProductModel->getChildObject();
     // Prepare eBay changes values
     //--------------------------
     $tempEbayChanges = array();
     if ($tempEbayListingProductModel->isListingTypeAuction()) {
         $tempEbayChanges['online_start_price'] = (double) $ebayChange['currentPrice'] < 0 ? 0 : (double) $ebayChange['currentPrice'];
     }
     if ($tempEbayListingProductModel->isListingTypeFixed()) {
         $tempEbayChanges['online_buyitnow_price'] = (double) $ebayChange['currentPrice'] < 0 ? 0 : (double) $ebayChange['currentPrice'];
     }
     $tempEbayChanges['online_qty'] = (int) $ebayChange['quantity'] < 0 ? 0 : (int) $ebayChange['quantity'];
     $tempEbayChanges['online_qty_sold'] = (int) $ebayChange['quantitySold'] < 0 ? 0 : (int) $ebayChange['quantitySold'];
     if ($tempEbayListingProductModel->isListingTypeAuction()) {
         $tempEbayChanges['online_qty'] = 1;
         $tempEbayChanges['online_bids'] = (int) $ebayChange['bidCount'] < 0 ? 0 : (int) $ebayChange['bidCount'];
     }
     $tempEbayChanges['start_date'] = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($ebayChange['startTime']);
     $tempEbayChanges['end_date'] = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($ebayChange['endTime']);
     if ($tempEbayChanges['online_qty'] == $tempEbayChanges['online_qty_sold'] && ($ebayChange['listingStatus'] == self::EBAY_STATUS_COMPLETED || $ebayChange['listingStatus'] == self::EBAY_STATUS_ENDED)) {
         $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_SOLD;
     } else {
         if ($ebayChange['listingStatus'] == self::EBAY_STATUS_COMPLETED) {
             $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED;
         } else {
             if ($ebayChange['listingStatus'] == self::EBAY_STATUS_ENDED) {
                 $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_FINISHED;
             } else {
                 if ($ebayChange['listingStatus'] == self::EBAY_STATUS_ACTIVE) {
                     $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_LISTED;
                 }
             }
         }
     }
     if ($tempListingProductModel->getStatus() != $tempEbayChanges['status'] || $tempListingProductModel->getChildObject()->getOnlineQty() != $tempEbayChanges['online_qty'] || $tempListingProductModel->getChildObject()->getOnlineQtySold() != $tempEbayChanges['online_qty_sold']) {
         Mage::getModel('M2ePro/ProductChange')->addUpdateAction($tempListingProductModel->getProductId(), Ess_M2ePro_Model_ProductChange::CREATOR_TYPE_SYNCHRONIZATION);
     }
     if ($tempEbayChanges['status'] != $tempListingProductModel->getStatus()) {
         $tempEbayChanges['status_changer'] = Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_COMPONENT;
         $tempLogMessage = '';
         switch ($tempEbayChanges['status']) {
             case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Listed".');
                 $tempLogMessage = 'Item status was successfully changed to "Listed".';
                 break;
             case Ess_M2ePro_Model_Listing_Product::STATUS_SOLD:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Sold".');
                 $tempLogMessage = 'Item status was successfully changed to "Sold".';
                 break;
             case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Stopped".');
                 $tempLogMessage = 'Item status was successfully changed to "Stopped".';
                 break;
             case Ess_M2ePro_Model_Listing_Product::STATUS_FINISHED:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Finished".');
                 $tempLogMessage = 'Item status was successfully changed to "Finished".';
                 break;
         }
         $tempLog = Mage::getModel('M2ePro/Listing_Log');
         $tempLog->setComponentMode(Ess_M2ePro_Helper_Component_Ebay::NICK);
         $tempLog->addProductMessage($tempListingProductModel->getListingId(), $tempListingProductModel->getProductId(), $tempListingProductModel->getId(), Ess_M2ePro_Model_Log_Abstract::INITIATOR_EXTENSION, $this->getLogActionId(), Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL, $tempLogMessage, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
     }
     //--------------------------
     // Create changed listings products
     //--------------------------
     $changedListingsProducts = array('ebay_item_id' => $ebayChange['id'], 'listing_product' => array('instance' => $tempListingProductModel, 'changes' => $tempEbayChanges), 'listings_products_variations' => array());
     //--------------------------
     // Cancel when have not eBay variations
     //--------------------------
     if (!isset($ebayChange['variations']) || is_null($ebayChange['variations'])) {
         return $changedListingsProducts;
     }
     //--------------------------
     // Get listings products variations
     //-----------------------
     $tempVariations = $tempListingProductModel->getVariations(true);
     if (count($tempVariations) == 0) {
         return $changedListingsProducts;
     }
     //-----------------------
     // Get listings products variations with options
     //-----------------------
     $tempVariationsWithOptions = array();
     foreach ($tempVariations as $variation) {
         /** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
         $options = $variation->getOptions(true);
         if (count($options) == 0) {
             continue;
         }
         $tempVariationsWithOptions[] = array('variation' => $variation, 'options' => $options);
     }
     if (count($tempVariationsWithOptions) == 0) {
         return $changedListingsProducts;
     }
     //-----------------------
     // Search our variations for eBay variations
     //--------------------------
     foreach ($ebayChange['variations'] as $ebayVariation) {
         // Find our variation
         //--------------------------
         foreach ($tempVariationsWithOptions as $M2eProVariation) {
             $equalVariation = true;
             foreach ($M2eProVariation['options'] as $M2eProOptionValue) {
                 $haveOption = false;
                 foreach ($ebayVariation['specifics'] as $ebayOptionKey => $ebayOptionValue) {
                     if ($M2eProOptionValue->getData('attribute') == $ebayOptionKey && $M2eProOptionValue->getData('option') == $ebayOptionValue) {
                         $haveOption = true;
                         break;
                     }
                 }
                 if ($haveOption === false) {
                     $equalVariation = false;
                     break;
                 }
             }
             if ($equalVariation === true && count($M2eProVariation['options']) == count($ebayVariation['specifics'])) {
                 // Prepare eBay changes values
                 //--------------------------
                 $tempEbayChanges = array();
                 $tempEbayChanges['online_price'] = (double) $ebayVariation['price'] < 0 ? 0 : (double) $ebayVariation['price'];
                 $tempEbayChanges['online_qty'] = (int) $ebayVariation['quantity'] < 0 ? 0 : (int) $ebayVariation['quantity'];
                 $tempEbayChanges['online_qty_sold'] = (int) $ebayVariation['quantitySold'] < 0 ? 0 : (int) $ebayVariation['quantitySold'];
                 if ($tempEbayChanges['online_qty'] <= $tempEbayChanges['online_qty_sold']) {
                     $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_SOLD;
                 }
                 if ($tempEbayChanges['online_qty'] <= 0) {
                     $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED;
                 }
                 //--------------------------
                 // Add changed variation
                 //--------------------------
                 $changedListingsProducts['listings_products_variations'][] = array('instance' => $M2eProVariation, 'changes' => $tempEbayChanges);
                 //--------------------------
                 break;
             }
         }
         //--------------------------
     }
     return $changedListingsProducts;
 }
예제 #12
0
 private function prepareFromTime(Ess_M2ePro_Model_Account $account)
 {
     $lastSynchronizationDate = $account->getData('orders_last_synchronization');
     if (is_null($lastSynchronizationDate)) {
         $sinceTime = new DateTime('now', new DateTimeZone('UTC'));
         $sinceTime = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($sinceTime);
         $this->saveLastUpdateTime($account, $sinceTime);
         return $sinceTime;
     }
     $sinceTime = new DateTime($lastSynchronizationDate, new DateTimeZone('UTC'));
     // Get min date for synch
     //------------------------
     $minDate = new DateTime('now', new DateTimeZone('UTC'));
     $minDate->modify('-90 days');
     //------------------------
     // Prepare last date
     //------------------------
     if ((int) $sinceTime->format('U') < (int) $minDate->format('U')) {
         $sinceTime = $minDate;
     }
     //------------------------
     return Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($sinceTime);
 }
예제 #13
0
 private function prepareSinceTime($sinceTime)
 {
     if (is_null($sinceTime)) {
         $sinceTime = new DateTime('now', new DateTimeZone('UTC'));
         $sinceTime->modify('-10 days');
     } else {
         $sinceTime = new DateTime($sinceTime, new DateTimeZone('UTC'));
     }
     return Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($sinceTime);
 }
예제 #14
0
 private function prepareFromTime(Ess_M2ePro_Model_Account $account)
 {
     $lastSynchronizationDate = $account->getData('orders_last_synchronization');
     if (is_null($lastSynchronizationDate)) {
         $sinceTime = new DateTime('now', new DateTimeZone('UTC'));
         $sinceTime = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($sinceTime);
         $this->saveLastUpdateTime($account, $sinceTime);
         return $sinceTime;
     }
     $sinceTime = new DateTime($lastSynchronizationDate, new DateTimeZone('UTC'));
     return Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($sinceTime);
 }