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(); }
protected function updateProduct(\Ess\M2ePro\Model\Listing\Product $listingProduct, array $response) { $productData = array(); $descriptionTemplate = $listingProduct->getChildObject()->getDescriptionTemplate(); $oldDescriptionTemplateId = $descriptionTemplate->getId(); if (!isset($this->descriptionTemplatesIds[$oldDescriptionTemplateId]) && (trim($descriptionTemplate->getData('title_template')) != '#ebay_translated_title#' || trim($descriptionTemplate->getData('subtitle_template')) != '#ebay_translated_subtitle#' || trim($descriptionTemplate->getData('description_template')) != '#ebay_translated_description#')) { $data = $descriptionTemplate->getDataSnapshot(); unset($data['id'], $data['update_date'], $data['create_date']); $data['title'] = $data['title'] . $this->getHelper('Module\\Translation')->__(' (Changed because Translation Service applied.)'); $data['title_mode'] = \Ess\M2ePro\Model\Ebay\Template\Description::TITLE_MODE_CUSTOM; $data['title_template'] = '#ebay_translated_title#'; $data['subtitle_mode'] = \Ess\M2ePro\Model\Ebay\Template\Description::SUBTITLE_MODE_CUSTOM; $data['subtitle_template'] = '#ebay_translated_subtitle#'; $data['description_mode'] = \Ess\M2ePro\Model\Ebay\Template\Description::DESCRIPTION_MODE_CUSTOM; $data['description_template'] = '#ebay_translated_description#'; $data['is_custom_template'] = 1; $newDescriptionTemplate = $this->modelFactory->getObject('Ebay\\Template\\Manager')->setTemplate(\Ess\M2ePro\Model\Ebay\Template\Manager::TEMPLATE_DESCRIPTION)->getTemplateBuilder()->build($data); $this->descriptionTemplatesIds[$oldDescriptionTemplateId] = $newDescriptionTemplate->getId(); } if (isset($this->descriptionTemplatesIds[$oldDescriptionTemplateId])) { $productData['template_description_custom_id'] = $this->descriptionTemplatesIds[$oldDescriptionTemplateId]; $productData['template_description_mode'] = \Ess\M2ePro\Model\Ebay\Template\Manager::MODE_CUSTOM; } $attributes = array('ebay_translated_title' => array('label' => 'Ebay Translated Title', 'type' => 'text'), 'ebay_translated_subtitle' => array('label' => 'Ebay Translated Subtitle', 'type' => 'text'), 'ebay_translated_description' => array('label' => 'Ebay Translated Description', 'type' => 'textarea')); $this->checkAndCreateMagentoAttributes($listingProduct->getMagentoProduct(), $attributes); $listingProduct->getMagentoProduct()->setAttributeValue('ebay_translated_title', $response['title'])->setAttributeValue('ebay_translated_subtitle', $response['subtitle'])->setAttributeValue('ebay_translated_description', $response['description']); //------------------------------ $categoryPath = !is_null($response['category']['primary_id']) ? $this->getHelper('Component\\Ebay\\Category\\Ebay')->getPath((int) $response['category']['primary_id'], $this->params['marketplace_id']) : ''; $response['category']['path'] = $categoryPath; if ($categoryPath) { $data = $this->activeRecordFactory->getObject('Ebay\\Template\\Category')->getDefaultSettings(); $data['category_main_id'] = (int) $response['category']['primary_id']; $data['category_main_path'] = $categoryPath; $data['marketplace_id'] = $this->params['marketplace_id']; $data['specifics'] = $this->getSpecificsData($response['item_specifics']); $productData['template_category_id'] = $this->modelFactory->getObject('Ebay\\Template\\Category\\Builder')->build($data)->getId(); } else { $response['category']['primary_id'] = null; } $additionalData = $listingProduct->getAdditionalData(); $additionalData['translation_service']['to'] = array_merge($additionalData['translation_service']['to'], $response); $productData['additional_data'] = json_encode($additionalData); $listingProduct->addData($productData)->save(); $listingProduct->getChildObject()->addData(array('translation_status' => \Ess\M2ePro\Model\Ebay\Listing\Product::TRANSLATION_STATUS_TRANSLATED, 'translated_date' => $this->getHelper('Data')->getCurrentGmtDate()))->save(); }
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); }