Exemplo n.º 1
0
 protected function logError(\Ess\M2ePro\Model\Listing\Product $listingProduct, \Exception $exception)
 {
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Log $logModel */
     $logModel = $this->activeRecordFactory->getObject('Amazon\\Listing\\Log');
     $logModel->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, $logModel->getNextActionId(), $this->getActionForLog(), $exception->getMessage(), \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_HIGH);
     $this->getHelper('Module\\Exception')->process($exception);
 }
Exemplo n.º 2
0
 private function duplicateListingProduct(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     $duplicatedListingProduct = $listingProduct->getListing()->addProduct($listingProduct->getProductId(), false, false);
     $variationManager = $listingProduct->getChildObject()->getVariationManager();
     if (!$variationManager->isVariationProduct()) {
         return $duplicatedListingProduct;
     }
     if ($listingProduct->isComponentModeAmazon()) {
         $duplicatedListingProductManager = $duplicatedListingProduct->getChildObject()->getVariationManager();
         if ($variationManager->isIndividualType() && $duplicatedListingProductManager->modeCanBeSwitched()) {
             $duplicatedListingProductManager->switchModeToAnother();
         }
     }
     return $duplicatedListingProduct;
 }
Exemplo n.º 3
0
 protected function addListingsProductsLogsMessage(\Ess\M2ePro\Model\Listing\Product $listingProduct, $text, $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE, $priority = \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_MEDIUM)
 {
     $action = \Ess\M2ePro\Model\Listing\Log::ACTION_TRANSLATE_PRODUCT;
     if ($this->getStatusChanger() == \Ess\M2ePro\Model\Listing\Product::STATUS_CHANGER_UNKNOWN) {
         $initiator = \Ess\M2ePro\Helper\Data::INITIATOR_UNKNOWN;
     } else {
         if ($this->getStatusChanger() == \Ess\M2ePro\Model\Listing\Product::STATUS_CHANGER_USER) {
             $initiator = \Ess\M2ePro\Helper\Data::INITIATOR_USER;
         } else {
             $initiator = \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION;
         }
     }
     /** @var  $logModel \Ess\M2ePro\Model\Listing\Log */
     $logModel = $this->activeRecordFactory->getObject('Listing\\Log');
     $logModel->setComponentMode(\Ess\M2ePro\Helper\Component\Ebay::NICK);
     $logModel->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), $initiator, $this->getLogsActionId(), $action, $text, $type, $priority);
 }
Exemplo n.º 4
0
 private function logListingProductMessage(\Ess\M2ePro\Model\Listing\Product $listingProduct, $action, $oldValue, $newValue)
 {
     // M2ePro\TRANSLATIONS
     // From [%from%] to [%to%].
     $log = $this->activeRecordFactory->getObject('Listing\\Log');
     $log->setComponentMode($listingProduct->getComponentMode());
     $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, NULL, $action, $log->encodeDescription('From [%from%] to [%to%].', array('from' => $oldValue, 'to' => $newValue)), \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW);
 }
Exemplo n.º 5
0
 protected function addListingsProductsLogsMessage(\Ess\M2ePro\Model\Listing\Product $listingProduct, $text, $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE, $priority = \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_MEDIUM)
 {
     $action = \Ess\M2ePro\Model\Listing\Log::ACTION_TRANSLATE_PRODUCT;
     if ($this->params['status_changer'] == \Ess\M2ePro\Model\Listing\Product::STATUS_CHANGER_UNKNOWN) {
         $initiator = \Ess\M2ePro\Helper\Data::INITIATOR_UNKNOWN;
     } else {
         if ($this->params['status_changer'] == \Ess\M2ePro\Model\Listing\Product::STATUS_CHANGER_USER) {
             $initiator = \Ess\M2ePro\Helper\Data::INITIATOR_USER;
         } else {
             $initiator = \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION;
         }
     }
     switch ($type) {
         case \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR:
             $this->setStatus(\Ess\M2ePro\Helper\Data::STATUS_ERROR);
             break;
         case \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING:
             $this->setStatus(\Ess\M2ePro\Helper\Data::STATUS_WARNING);
             break;
         case \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS:
         case \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE:
             $this->setStatus(\Ess\M2ePro\Helper\Data::STATUS_SUCCESS);
             break;
         default:
             $this->setStatus(\Ess\M2ePro\Helper\Data::STATUS_ERROR);
             break;
     }
     $logModel = $this->activeRecordFactory->getObject('Listing\\Log');
     $logModel->setComponentMode(\Ess\M2ePro\Helper\Component\Ebay::NICK);
     $logModel->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), $initiator, $this->logsActionId, $action, $text, $type, $priority);
 }
Exemplo n.º 6
0
 private function updateListingsProductChange(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     $this->activeRecordFactory->getObject('ProductChange')->addUpdateAction($listingProduct->getProductId(), \Ess\M2ePro\Model\ProductChange::INITIATOR_INSPECTOR);
     foreach ($listingProduct->getVariations(true) as $variation) {
         /** @var $variation \Ess\M2ePro\Model\Listing\Product\Variation */
         foreach ($variation->getOptions(true) as $option) {
             /** @var $option \Ess\M2ePro\Model\Listing\Product\Variation\Option */
             $this->activeRecordFactory->getObject('ProductChange')->addUpdateAction($option->getProductId(), \Ess\M2ePro\Model\ProductChange::INITIATOR_INSPECTOR);
         }
     }
 }
Exemplo n.º 7
0
 private function logListingProductMessage(\Ess\M2ePro\Model\Listing\Product $listingProduct, $action, $oldValue, $newValue, $messagePostfix = '')
 {
     // M2ePro\TRANSLATIONS
     // From [%from%] to [%to%].
     $log = $this->activeRecordFactory->getObject(ucfirst($listingProduct->getComponentMode()) . '\\Listing\\Log');
     $oldValue = strlen($oldValue) > 150 ? substr($oldValue, 0, 150) . ' ...' : $oldValue;
     $newValue = strlen($newValue) > 150 ? substr($newValue, 0, 150) . ' ...' : $newValue;
     $messagePostfix = trim(trim($messagePostfix), '.');
     if (!empty($messagePostfix)) {
         $messagePostfix = ' ' . $messagePostfix;
     }
     if ($listingProduct->isComponentModeEbay() && is_array($listingProduct->getData('found_options_ids'))) {
         $collection = $this->activeRecordFactory->getObject('Listing\\Product\\Variation\\Option')->getCollection()->addFieldToFilter('main_table.id', array('in' => $listingProduct->getData('found_options_ids')));
         $additionalData = array();
         foreach ($collection as $listingProductVariationOption) {
             /** @var \Ess\M2ePro\Model\Listing\Product\Variation\Option $listingProductVariationOption  */
             $additionalData['variation_options'][$listingProductVariationOption->getAttribute()] = $listingProductVariationOption->getOption();
         }
         if (!empty($additionalData['variation_options']) && $collection->getFirstItem()->getProductType() == \Ess\M2ePro\Model\Magento\Product::TYPE_BUNDLE) {
             foreach ($additionalData['variation_options'] as $attribute => $option) {
                 $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, NULL, $action, $log->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW, array('variation_options' => array($attribute => $option)));
             }
             return;
         }
         $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, NULL, $action, $log->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW, $additionalData);
         return;
     }
     $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, NULL, $action, $log->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW);
 }
Exemplo n.º 8
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Product $listingProduct
  * @param \Ess\M2ePro\Model\Connector\Connection\Response\Message $message
  * @param int $priority
  */
 public function logListingProductMessage(\Ess\M2ePro\Model\Listing\Product $listingProduct, \Ess\M2ePro\Model\Connector\Connection\Response\Message $message, $priority = \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_MEDIUM)
 {
     if ($this->storeMode) {
         $this->storedMessages[] = array('type' => $this->initLogType($message), 'text' => $message->getText());
         return;
     }
     $this->getListingLog()->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), $this->initiator, $this->actionId, $this->action, $message->getText(), $this->initLogType($message), $priority);
 }
Exemplo n.º 9
0
 /**
  * @param Product $listingProduct
  * @throws Logic
  */
 protected function logAddedToMagentoProduct(Product $listingProduct)
 {
     $tempLog = $this->activeRecordFactory->getObject('Listing\\Log');
     $tempLog->setComponentMode($this->getListing()->getComponentMode());
     $tempLog->addProductMessage($this->getListing()->getId(), $listingProduct->getProductId(), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_UNKNOWN, NULL, \Ess\M2ePro\Model\Listing\Log::ACTION_ADD_PRODUCT_TO_MAGENTO, 'Product was successfully Added', \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW);
 }
Exemplo n.º 10
0
 protected function logListingProductException(\Ess\M2ePro\Model\Listing\Product $listingProduct, \Exception $exception, $action, $params)
 {
     $logModel = $this->activeRecordFactory->getObject('Listing\\Log');
     $logModel->setComponentMode(\Ess\M2ePro\Helper\Component\Ebay::NICK);
     $action = $this->recognizeActionForLogging($action, $params);
     $initiator = $this->recognizeInitiatorForLogging($params);
     $logModel->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), $initiator, $this->logsActionId, $action, $exception->getMessage(), \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_HIGH);
 }
Exemplo n.º 11
0
 private function logReportChange(\Ess\M2ePro\Model\Listing\Product $listingProduct, $logMessage)
 {
     if (empty($logMessage)) {
         return;
     }
     $log = $this->activeRecordFactory->getObject('Listing\\Log');
     $log->setComponentMode(\Ess\M2ePro\Helper\Component\Ebay::NICK);
     $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, $this->getLogsActionId(), \Ess\M2ePro\Model\Listing\Log::ACTION_CHANNEL_CHANGE, $logMessage, \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW);
 }