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);
 }
 protected function getSuccessfulParams(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     $responseData = $this->getPreparedResponseData();
     if (!is_array($responseData['asins']) || empty($responseData['asins'])) {
         return array();
     }
     foreach ($responseData['asins'] as $key => $asin) {
         if ((int) $key != (int) $listingProduct->getId()) {
             continue;
         }
         return array('general_id' => $asin);
     }
     return array();
 }
 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);
 }
Beispiel #4
0
 /**
  * @param $variationMpnValues
  * @throws Logic
  */
 protected function fillVariationMpnValues($variationMpnValues)
 {
     /** @var Collection $variationCollection */
     $variationCollection = $this->activeRecordFactory->getObject('Listing\\Product\\Variation')->getCollection();
     $variationCollection->addFieldToFilter('listing_product_id', $this->listingProduct->getId());
     /** @var Collection $variationOptionCollection */
     $variationOptionCollection = $this->activeRecordFactory->getObject('Listing\\Product\\Variation\\Option')->getCollection();
     $variationOptionCollection->addFieldToFilter('listing_product_variation_id', $variationCollection->getColumnValues('id'));
     /** @var Variation[] $variations */
     $variations = $variationCollection->getItems();
     /** @var Variation\Option[] $variationOptions */
     $variationOptions = $variationOptionCollection->getItems();
     foreach ($variations as $variation) {
         $specifics = array();
         foreach ($variationOptions as $id => $variationOption) {
             if ($variationOption->getListingProductVariationId() != $variation->getId()) {
                 continue;
             }
             $specifics[$variationOption->getAttribute()] = $variationOption->getOption();
             unset($variationOptions[$id]);
         }
         /** @var EbayVariation $ebayVariation */
         $ebayVariation = $variation->getChildObject();
         foreach ($variationMpnValues as $id => $variationMpnValue) {
             if ($ebayVariation->getOnlineSku() != $variationMpnValue['sku'] && $specifics != $variationMpnValue['specifics']) {
                 continue;
             }
             $additionalData = $variation->getAdditionalData();
             if (!isset($additionalData['ebay_mpn_value']) || $additionalData['ebay_mpn_value'] != $variationMpnValue['mpn']) {
                 $additionalData['ebay_mpn_value'] = $variationMpnValue['mpn'];
                 $variation->setSettings('additional_data', $additionalData);
                 $variation->save();
             }
             unset($variationMpnValues[$id]);
             break;
         }
     }
 }
Beispiel #5
0
 private function checkVariationStructureChanges(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager $variationManager */
     $variationManager = $listingProduct->getChildObject()->getVariationManager();
     if ($variationManager->isRelationParentType()) {
         $this->parentListingsProductsForProcessing[$listingProduct->getId()] = $listingProduct;
         return;
     }
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager\PhysicalUnit $typeModel */
     $typeModel = $variationManager->getTypeModel();
     if (!$listingProduct->getMagentoProduct()->isSimpleType()) {
         $typeModel->inspectAndFixProductOptionsIds();
     }
     if (!$typeModel->isActualProductAttributes()) {
         if ($variationManager->isRelationChildType()) {
             $this->parentListingsProductsForProcessing[$typeModel->getParentListingProduct()->getId()] = $typeModel->getParentListingProduct();
             return;
         }
         /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager\Type\Individual $typeModel */
         $typeModel->resetProductVariation();
         return;
     }
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager\PhysicalUnit $typeModel */
     if ($typeModel->isVariationProductMatched() && !$typeModel->isActualProductVariation()) {
         if ($variationManager->isRelationChildType()) {
             /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager\Type\Relation\ChildRelation $typeModel */
             $this->parentListingsProductsForProcessing[$typeModel->getParentListingProduct()->getId()] = $typeModel->getParentListingProduct();
             return;
         }
         $typeModel->unsetProductVariation();
     }
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager\Type\Relation\ChildRelation $typeModel */
     if ($variationManager->isRelationChildType() && $typeModel->getParentTypeModel()->getVirtualChannelAttributes()) {
         if (!$typeModel->getParentTypeModel()->isActualVirtualChannelAttributes()) {
             $this->parentListingsProductsForProcessing[$typeModel->getParentListingProduct()->getId()] = $typeModel->getParentListingProduct();
         }
     }
 }
 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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
 /**
  * @param \Ess\M2ePro\Model\Listing\Product $listingProduct
  * @return \Ess\M2ePro\Model\Amazon\Listing\Product\Action\Type\Request
  */
 protected function getRequestObject(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     if (!isset($this->requestsObjects[$listingProduct->getId()])) {
         /* @var $request \Ess\M2ePro\Model\Amazon\Listing\Product\Action\Type\ListAction\Request */
         $request = $this->modelFactory->getObject('Amazon\\Listing\\Product\\Action\\Type\\ListAction\\Request');
         $request->setParams($this->params);
         $request->setListingProduct($listingProduct);
         $request->setConfigurator($listingProduct->getActionConfigurator());
         $request->setValidatorsData($this->getValidatorsData($listingProduct));
         $this->requestsObjects[$listingProduct->getId()] = $request;
     }
     return $this->requestsObjects[$listingProduct->getId()];
 }
Beispiel #10
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Product $listingProduct
  * @return string
  */
 public function getViewLogIconHtml($listingProduct)
 {
     $listingProductId = (int) $listingProduct->getId();
     $connection = $this->resourceConnection->getConnection();
     // Get last messages
     // ---------------------------------------
     $dbSelect = $connection->select()->from($this->activeRecordFactory->getObject('Listing\\Log')->getResource()->getMainTable(), array('action_id', 'action', 'type', 'description', 'create_date', 'initiator'))->where('`listing_product_id` = ?', $listingProductId)->where('`action_id` IS NOT NULL')->order(array('id DESC'))->limit(30);
     $logRows = $connection->fetchAll($dbSelect);
     // ---------------------------------------
     // Get grouped messages by action_id
     // ---------------------------------------
     $actionsRows = array();
     $tempActionRows = array();
     $lastActionId = false;
     foreach ($logRows as $row) {
         $row['description'] = $this->getHelper('View')->getModifiedLogMessage($row['description']);
         if ($row['action_id'] !== $lastActionId) {
             if (count($tempActionRows) > 0) {
                 $actionsRows[] = array('type' => $this->getMainTypeForActionId($tempActionRows), 'date' => $this->getMainDateForActionId($tempActionRows), 'action' => $this->getActionForAction($tempActionRows[0]), 'initiator' => $this->getInitiatorForAction($tempActionRows[0]), 'items' => $tempActionRows);
                 $tempActionRows = array();
             }
             $lastActionId = $row['action_id'];
         }
         $tempActionRows[] = $row;
     }
     if (count($tempActionRows) > 0) {
         $actionsRows[] = array('type' => $this->getMainTypeForActionId($tempActionRows), 'date' => $this->getMainDateForActionId($tempActionRows), 'action' => $this->getActionForAction($tempActionRows[0]), 'initiator' => $this->getInitiatorForAction($tempActionRows[0]), 'items' => $tempActionRows);
     }
     if (count($actionsRows) <= 0) {
         return '';
     }
     foreach ($actionsRows as &$actionsRow) {
         usort($actionsRow['items'], function ($a, $b) {
             $sortOrder = array(\Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 1, \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 2, \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 3);
             return $sortOrder[$a["type"]] > $sortOrder[$b["type"]];
         });
     }
     $tips = array(\Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 'Last Action was completed successfully.', \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 'Last Action was completed with error(s).', \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 'Last Action was completed with warning(s).');
     $icons = array(\Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 'normal', \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 'error', \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 'warning');
     $summary = $this->createBlock('Log\\Grid\\Summary', '', ['data' => ['entity_id' => (int) $listingProduct->getId(), 'rows' => $actionsRows, 'tips' => $tips, 'icons' => $icons, 'view_help_handler' => 'ListingProductVariationManageVariationsGridObj.viewItemHelp', 'hide_help_handler' => 'ListingProductVariationManageVariationsGridObj.hideItemHelp']]);
     return $summary->toHtml();
 }
Beispiel #11
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Product $listingProduct
  * @return bool
  * @throws \Ess\M2ePro\Model\Exception
  * @throws \Ess\M2ePro\Model\Exception\Logic
  */
 public function isMeetStopRequirements(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     if (!$listingProduct->isListed() || $listingProduct->isBlocked()) {
         return false;
     }
     if (!$listingProduct->isStoppable()) {
         return false;
     }
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     $variationManager = $amazonListingProduct->getVariationManager();
     if ($variationManager->isVariationProduct()) {
         if ($variationManager->isRelationParentType()) {
             return false;
         }
     }
     if ($listingProduct->isSetProcessingLock('in_action')) {
         return false;
     }
     $amazonSynchronizationTemplate = $amazonListingProduct->getAmazonSynchronizationTemplate();
     $variationResource = $this->activeRecordFactory->getObject('Listing\\Product\\Variation')->getResource();
     if ($amazonSynchronizationTemplate->isStopStatusDisabled()) {
         if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) {
             return true;
         } else {
             if ($variationManager->isPhysicalUnit() && $variationManager->getTypeModel()->isVariationProductMatched()) {
                 $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     return true;
                 }
             }
         }
     }
     if ($amazonSynchronizationTemplate->isStopOutOfStock()) {
         if (!$listingProduct->getMagentoProduct()->isStockAvailability()) {
             return true;
         } else {
             if ($variationManager->isPhysicalUnit() && $variationManager->getTypeModel()->isVariationProductMatched()) {
                 $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     return true;
                 }
             }
         }
     }
     if ($amazonSynchronizationTemplate->isStopWhenQtyMagentoHasValue()) {
         $productQty = (int) $amazonListingProduct->getQty(true);
         $typeQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyMagentoHasValueType();
         $minQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyMagentoHasValueMin();
         $maxQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyMagentoHasValueMax();
         if ($typeQty == \Ess\M2ePro\Model\Amazon\Template\Synchronization::STOP_QTY_LESS && $productQty <= $minQty) {
             return true;
         }
         if ($typeQty == \Ess\M2ePro\Model\Amazon\Template\Synchronization::STOP_QTY_MORE && $productQty >= $minQty) {
             return true;
         }
         if ($typeQty == \Ess\M2ePro\Model\Amazon\Template\Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             return true;
         }
     }
     if ($amazonSynchronizationTemplate->isStopWhenQtyCalculatedHasValue()) {
         $productQty = (int) $amazonListingProduct->getQty(false);
         $typeQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyCalculatedHasValueType();
         $minQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyCalculatedHasValueMin();
         $maxQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyCalculatedHasValueMax();
         if ($typeQty == \Ess\M2ePro\Model\Amazon\Template\Synchronization::STOP_QTY_LESS && $productQty <= $minQty) {
             return true;
         }
         if ($typeQty == \Ess\M2ePro\Model\Amazon\Template\Synchronization::STOP_QTY_MORE && $productQty >= $minQty) {
             return true;
         }
         if ($typeQty == \Ess\M2ePro\Model\Amazon\Template\Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             return true;
         }
     }
     return false;
 }
Beispiel #12
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Product $listingProduct
  * @return \Ess\M2ePro\Model\Ebay\Listing\Product\Action\RequestData
  */
 protected function getRequestDataObject(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     return $this->requestsDataObjects[$listingProduct->getId()];
 }
Beispiel #13
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Product $listingProduct
  * @param array $data
  * @return \Ess\M2ePro\Model\Amazon\Listing\Product\Action\RequestData
  */
 protected function buildRequestDataObject(\Ess\M2ePro\Model\Listing\Product $listingProduct, array $data)
 {
     if (!isset($this->requestsDataObjects[$listingProduct->getId()])) {
         /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Action\RequestData $requestData */
         $requestData = $this->modelFactory->getObject('Amazon\\Listing\\Product\\Action\\RequestData');
         $requestData->setData($data);
         $requestData->setListingProduct($listingProduct);
         $this->requestsDataObjects[$listingProduct->getId()] = $requestData;
     }
     return $this->requestsDataObjects[$listingProduct->getId()];
 }
 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 #15
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Product $listingProduct
  * @return bool
  * @throws \Ess\M2ePro\Model\Exception\Logic
  */
 public function isMeetStopRequirements(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     if (!$listingProduct->isListed()) {
         return false;
     }
     if (!$listingProduct->isStoppable() || $listingProduct->isHidden()) {
         return false;
     }
     /** @var \Ess\M2ePro\Model\Ebay\Listing\Product $ebayListingProduct */
     $ebayListingProduct = $listingProduct->getChildObject();
     $ebaySynchronizationTemplate = $ebayListingProduct->getEbaySynchronizationTemplate();
     if (!$ebayListingProduct->isSetCategoryTemplate()) {
         return false;
     }
     if ($listingProduct->isSetProcessingLock('in_action')) {
         return false;
     }
     $variationResource = $this->activeRecordFactory->getObject('Listing\\Product\\Variation')->getResource();
     if ($ebaySynchronizationTemplate->isStopStatusDisabled()) {
         if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) {
             return true;
         } else {
             if ($ebayListingProduct->isVariationsReady()) {
                 $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     return true;
                 }
             }
         }
     }
     if ($ebaySynchronizationTemplate->isStopOutOfStock()) {
         if (!$listingProduct->getMagentoProduct()->isStockAvailability()) {
             return true;
         } else {
             if ($ebayListingProduct->isVariationsReady()) {
                 $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     return true;
                 }
             }
         }
     }
     if ($ebaySynchronizationTemplate->isStopWhenQtyMagentoHasValue()) {
         $productQty = (int) $listingProduct->getMagentoProduct()->getQty(true);
         $typeQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyMagentoHasValueType();
         $minQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyMagentoHasValueMin();
         $maxQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyMagentoHasValueMax();
         if ($typeQty == \Ess\M2ePro\Model\Ebay\Template\Synchronization::STOP_QTY_LESS && $productQty <= $minQty) {
             return true;
         }
         if ($typeQty == \Ess\M2ePro\Model\Ebay\Template\Synchronization::STOP_QTY_MORE && $productQty >= $minQty) {
             return true;
         }
         if ($typeQty == \Ess\M2ePro\Model\Ebay\Template\Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             return true;
         }
     }
     if ($ebaySynchronizationTemplate->isStopWhenQtyCalculatedHasValue()) {
         $productQty = (int) $ebayListingProduct->getQty();
         $typeQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyCalculatedHasValueType();
         $minQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyCalculatedHasValueMin();
         $maxQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyCalculatedHasValueMax();
         if ($typeQty == \Ess\M2ePro\Model\Ebay\Template\Synchronization::STOP_QTY_LESS && $productQty <= $minQty) {
             return true;
         }
         if ($typeQty == \Ess\M2ePro\Model\Ebay\Template\Synchronization::STOP_QTY_MORE && $productQty >= $minQty) {
             return true;
         }
         if ($typeQty == \Ess\M2ePro\Model\Ebay\Template\Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             return true;
         }
     }
     return false;
 }
Beispiel #16
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);
 }
Beispiel #17
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);
 }
Beispiel #18
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Product $listingProduct
  * @return \Ess\M2ePro\Model\Ebay\Listing\Product\Action\RequestData
  */
 protected function getRequestDataObject(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     if (!isset($this->requestsDataObjects[$listingProduct->getId()])) {
         /** @var \Ess\M2ePro\Model\Ebay\Listing\Product\Action\RequestData $requestData */
         $requestData = $this->modelFactory->getObject('Ebay\\Listing\\Product\\Action\\RequestData');
         $requestData->setData($this->params['products'][$listingProduct->getId()]['request']);
         $requestData->setListingProduct($listingProduct);
         $this->requestsDataObjects[$listingProduct->getId()] = $requestData;
     }
     return $this->requestsDataObjects[$listingProduct->getId()];
 }
Beispiel #19
0
 protected function unlockListingProduct()
 {
     $lockItem = $this->activeRecordFactory->getObject('LockItem');
     $lockItem->setNick(\Ess\M2ePro\Helper\Component\Ebay::NICK . '_listing_product_' . $this->listingProduct->getId());
     $lockItem->remove();
 }
Beispiel #20
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);
 }
Beispiel #21
0
 private function addNewVariations(\Ess\M2ePro\Model\Listing\Product $listingProduct, $addedVariations)
 {
     foreach ($addedVariations as $aVariation) {
         if (isset($aVariation['variation']['id'])) {
             $status = $aVariation['variation']['status'];
             $dataForUpdate = array('add' => $status == \Ess\M2ePro\Model\Listing\Product::STATUS_NOT_LISTED ? 1 : 0, 'delete' => 0);
             $this->ebayFactory->getObjectLoaded('Listing\\Product\\Variation', $aVariation['variation']['id'])->addData($dataForUpdate)->save();
             continue;
         }
         $dataForAdd = array('listing_product_id' => $listingProduct->getId(), 'add' => 1, 'delete' => 0, 'status' => \Ess\M2ePro\Model\Listing\Product::STATUS_NOT_LISTED);
         $newVariationId = $this->ebayFactory->getObject('Listing\\Product\\Variation')->addData($dataForAdd)->save()->getId();
         foreach ($aVariation['options'] as $aOption) {
             $dataForAdd = array('listing_product_variation_id' => $newVariationId, 'product_id' => $aOption['product_id'], 'product_type' => $aOption['product_type'], 'attribute' => $aOption['attribute'], 'option' => $aOption['option']);
             $this->ebayFactory->getObject('Listing\\Product\\Variation\\Option')->addData($dataForAdd)->save();
         }
     }
 }
Beispiel #22
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);
 }