Beispiel #1
0
 protected function markAsPotentialDuplicate()
 {
     $additionalData = $this->listingProduct->getAdditionalData();
     $additionalData['last_failed_action_data'] = array('native_request_data' => $this->getRequestDataObject()->getData(), 'previous_status' => $this->listingProduct->getStatus(), 'action' => $this->getActionType(), 'request_time' => $this->getResponse()->getRequestTime());
     $this->listingProduct->addData(array('status' => \Ess\M2ePro\Model\Listing\Product::STATUS_BLOCKED, 'additional_data' => json_encode($additionalData)))->save();
     $this->listingProduct->getChildObject()->updateVariationsStatus();
 }
 private function modifyAndLogListingProduct(\Ess\M2ePro\Model\Listing\Product $listingProduct, $status, $duplicateItemId = null)
 {
     /** @var \Ess\M2ePro\Model\Listing\Log $logModel */
     $logModel = $this->activeRecordFactory->getObject('Listing\\Log');
     $logModel->setComponentMode(\Ess\M2ePro\Helper\Component\Ebay::NICK);
     $logsActionId = $logModel->getNextActionId();
     $statusLogMessage = $this->getStatusLogMessage($listingProduct->getStatus(), $status);
     $logModel->addProductMessage($listingProduct->getData('listing_id'), $listingProduct->getData('product_id'), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, $logsActionId, \Ess\M2ePro\Model\Listing\Log::ACTION_CHANNEL_CHANGE, $statusLogMessage, \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW);
     $additionalData = $listingProduct->getAdditionalData();
     unset($additionalData['last_failed_action_data']);
     $listingProduct->addData(array('status' => $status, 'additional_data' => json_encode($additionalData)))->save();
     $listingProduct->getChildObject()->updateVariationsStatus();
     if (is_null($duplicateItemId)) {
         return;
     }
     // M2ePro\TRANSLATIONS
     // Duplicated Item %item_id% was found and Stopped on eBay.
     $textToTranslate = 'Duplicated Item %item_id% was found and stopped on eBay.';
     $duplicateDeletedMessage = $this->getHelper('Module\\Translation')->__($textToTranslate, $duplicateItemId);
     $logModel->addProductMessage($listingProduct->getData('listing_id'), $listingProduct->getData('product_id'), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, $logsActionId, \Ess\M2ePro\Model\Listing\Log::ACTION_CHANNEL_CHANGE, $duplicateDeletedMessage, \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW);
 }
Beispiel #3
0
 private function getProductStatusChanges(\Ess\M2ePro\Model\Listing\Product $listingProduct, array $change)
 {
     $data = array();
     $qty = (int) $change['quantity'] < 0 ? 0 : (int) $change['quantity'];
     $qtySold = (int) $change['quantitySold'] < 0 ? 0 : (int) $change['quantitySold'];
     if (($change['listingStatus'] == self::EBAY_STATUS_COMPLETED || $change['listingStatus'] == self::EBAY_STATUS_ENDED) && $qty == $qtySold) {
         $data['status'] = \Ess\M2ePro\Model\Listing\Product::STATUS_SOLD;
     } else {
         if ($change['listingStatus'] == self::EBAY_STATUS_COMPLETED) {
             $data['status'] = \Ess\M2ePro\Model\Listing\Product::STATUS_STOPPED;
         } else {
             if ($change['listingStatus'] == self::EBAY_STATUS_ENDED) {
                 $data['status'] = \Ess\M2ePro\Model\Listing\Product::STATUS_FINISHED;
             } else {
                 if ($change['listingStatus'] == self::EBAY_STATUS_ACTIVE && $qty - $qtySold <= 0) {
                     $data['status'] = \Ess\M2ePro\Model\Listing\Product::STATUS_HIDDEN;
                 } else {
                     if ($change['listingStatus'] == self::EBAY_STATUS_ACTIVE) {
                         $data['status'] = \Ess\M2ePro\Model\Listing\Product::STATUS_LISTED;
                     }
                 }
             }
         }
     }
     $accountOutOfStockControl = $listingProduct->getAccount()->getChildObject()->getOutOfStockControl(true);
     if (isset($change['out_of_stock'])) {
         $data['additional_data'] = array('out_of_stock_control' => (bool) $change['out_of_stock']);
     } elseif ($data['status'] == \Ess\M2ePro\Model\Listing\Product::STATUS_HIDDEN && !is_null($accountOutOfStockControl) && !$accountOutOfStockControl) {
         // Listed Hidden Status can be only for GTC items
         if (is_null($listingProduct->getChildObject()->getOnlineDuration())) {
             $data['online_duration'] = \Ess\M2ePro\Helper\Component\Ebay::LISTING_DURATION_GTC;
         }
         $additionalData = $listingProduct->getAdditionalData();
         empty($additionalData['out_of_stock_control']) && ($additionalData['out_of_stock_control'] = true);
         $data['additional_data'] = json_encode($additionalData);
     }
     if ($listingProduct->getStatus() == $data['status']) {
         return $data;
     }
     $data['status_changer'] = \Ess\M2ePro\Model\Listing\Product::STATUS_CHANGER_COMPONENT;
     $statusChangedFrom = $this->getHelper('Component\\Ebay')->getHumanTitleByListingProductStatus($listingProduct->getStatus());
     $statusChangedTo = $this->getHelper('Component\\Ebay')->getHumanTitleByListingProductStatus($data['status']);
     if (!empty($statusChangedFrom) && !empty($statusChangedTo)) {
         // M2ePro\TRANSLATIONS
         // Item Status was successfully changed from "%from%" to "%to%" .
         $this->logReportChange($listingProduct, $this->getHelper('Module\\Translation')->__('Item Status was successfully changed from "%from%" to "%to%" .', $statusChangedFrom, $statusChangedTo));
     }
     $this->activeRecordFactory->getObject('ProductChange')->addUpdateAction($listingProduct->getProductId(), \Ess\M2ePro\Model\ProductChange::INITIATOR_SYNCHRONIZATION);
     if ($this->listingsProductsLockStatus[$listingProduct->getId()]) {
         $this->listingsProductsIdsForActionSkipping[] = $listingProduct->getId();
     }
     return $data;
 }