Beispiel #1
0
 private function linkItem(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $data = array('general_id' => $listingProduct->getData('general_id'), 'is_isbn_general_id' => Mage::helper('M2ePro')->isISBN($listingProduct->getData('general_id')), 'sku' => $listingProduct->getData('sku'), 'status' => Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED);
     $listingProduct->addData($data)->save();
     $dataForAdd = array('account_id' => $listingProduct->getListing()->getAccountId(), 'marketplace_id' => $listingProduct->getListing()->getMarketplaceId(), 'sku' => $listingProduct->getData('sku'), 'product_id' => $listingProduct->getProductId(), 'store_id' => $listingProduct->getListing()->getStoreId());
     Mage::getModel('M2ePro/Amazon_Item')->setData($dataForAdd)->save();
     $message = Mage::helper('M2ePro')->__('The product was found in your Amazon inventory and linked by SKU.');
     $this->addListingsProductsLogsMessage($listingProduct, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
 }
Beispiel #2
0
 protected function updateProductAfterAction(Ess_M2ePro_Model_Listing_Product $listingProduct, array $nativeRequestData = array(), array $params = array(), $ebayItemsId = NULL, $saveEbayQtySold = false)
 {
     $dataForUpdate = array('status' => Ess_M2ePro_Model_Listing_Product::STATUS_LISTED);
     !is_null($ebayItemsId) && ($dataForUpdate['ebay_item_id'] = (int) $ebayItemsId);
     isset($params['status_changer']) && ($dataForUpdate['status_changer'] = (int) $params['status_changer']);
     if (isset($params['start_date_raw'])) {
         $dataForUpdate['start_date'] = Ess_M2ePro_Model_Connector_Server_Ebay_Abstract::ebayTimeToString($params['start_date_raw']);
     }
     if (isset($params['end_date_raw'])) {
         $dataForUpdate['end_date'] = Ess_M2ePro_Model_Connector_Server_Ebay_Abstract::ebayTimeToString($params['end_date_raw']);
     }
     if ($saveEbayQtySold) {
         $dataForUpdate['online_qty_sold'] = is_null($listingProduct->getChildObject()->getOnlineQtySold()) ? 0 : $listingProduct->getChildObject()->getOnlineQtySold();
         $tempIsVariation = $nativeRequestData['is_variation_item'] && isset($nativeRequestData['variation']);
         $tempUpdateFlag = $tempIsVariation || isset($nativeRequestData['qty']);
         if ($tempUpdateFlag) {
             $tempQty = $tempIsVariation ? $listingProduct->getChildObject()->getQty() : $nativeRequestData['qty'];
             $dataForUpdate['online_qty'] = (int) $tempQty + (int) $dataForUpdate['online_qty_sold'];
         }
     } else {
         $dataForUpdate['online_qty_sold'] = 0;
         $tempIsVariation = $nativeRequestData['is_variation_item'] && isset($nativeRequestData['variation']);
         $tempUpdateFlag = $tempIsVariation || isset($nativeRequestData['qty']);
         if ($tempUpdateFlag) {
             $tempQty = $tempIsVariation ? $listingProduct->getChildObject()->getQty() : $nativeRequestData['qty'];
             $dataForUpdate['online_qty'] = $tempQty;
         }
     }
     if ($listingProduct->getChildObject()->isListingTypeFixed()) {
         $dataForUpdate['online_start_price'] = NULL;
         $dataForUpdate['online_reserve_price'] = NULL;
         $dataForUpdate['online_bids'] = NULL;
         $tempIsVariation = $nativeRequestData['is_variation_item'] && isset($nativeRequestData['variation']);
         $tempUpdateFlag = $tempIsVariation || isset($nativeRequestData['price_fixed']);
         if ($tempUpdateFlag) {
             if ($tempIsVariation) {
                 $tempPrice = NULL;
                 foreach ($nativeRequestData['variation'] as $variation) {
                     if ((int) $variation['qty'] <= 0) {
                         continue;
                     }
                     if (!is_null($tempPrice) && (double) $variation['price'] >= $tempPrice) {
                         continue;
                     }
                     $tempPrice = (double) $variation['price'];
                 }
             } else {
                 $tempPrice = $nativeRequestData['price_fixed'];
             }
             $dataForUpdate['online_buyitnow_price'] = (double) $tempPrice;
         }
     } else {
         $dataForUpdate['online_bids'] = 0;
         if (isset($nativeRequestData['price_start'])) {
             $dataForUpdate['online_start_price'] = (double) $nativeRequestData['price_start'];
         }
         if (isset($nativeRequestData['price_reserve'])) {
             $dataForUpdate['online_reserve_price'] = (double) $nativeRequestData['price_reserve'];
         }
         if (isset($nativeRequestData['price_buyitnow'])) {
             $dataForUpdate['online_buyitnow_price'] = (double) $nativeRequestData['price_buyitnow'];
         }
     }
     $listingProduct->addData($dataForUpdate)->save();
 }
Beispiel #3
0
 protected function updateProductAfterAction(Ess_M2ePro_Model_Listing_Product $listingProduct, array $nativeRequestData = array(), array $params = array(), $startDate = false)
 {
     $dataForUpdate = array('status' => Ess_M2ePro_Model_Listing_Product::STATUS_LISTED, 'ignore_next_inventory_synch' => 1);
     if ($this->isAllPermissionsEnabled($this->getPreparedPermissions($params['params']))) {
         $dataForUpdate['synch_status'] = Ess_M2ePro_Model_Listing_Product::SYNCH_STATUS_OK;
         $dataForUpdate['synch_reasons'] = NULL;
     }
     isset($params['status_changer']) && ($dataForUpdate['status_changer'] = (int) $params['status_changer']);
     $startDate !== false && ($dataForUpdate['start_date'] = $startDate);
     if (isset($nativeRequestData['qty'])) {
         $dataForUpdate['online_qty'] = (int) $nativeRequestData['qty'];
         if ((int) $dataForUpdate['online_qty'] > 0) {
             $dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_LISTED;
             $dataForUpdate['end_date'] = NULL;
         } else {
             $dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED;
             $dataForUpdate['end_date'] = Mage::helper('M2ePro')->getCurrentGmtDate();
         }
     }
     if (isset($nativeRequestData['price'])) {
         $dataForUpdate['online_price'] = (double) $nativeRequestData['price'];
     }
     if (isset($nativeRequestData['condition_note'])) {
         $dataForUpdate['condition_note'] = (string) $nativeRequestData['condition_note'];
     }
     if (isset($nativeRequestData['shipping_standard_rate'])) {
         $dataForUpdate['shipping_standard_rate'] = $nativeRequestData['shipping_standard_rate'];
         $dataForUpdate['shipping_standard_rate'] === '' && ($dataForUpdate['shipping_standard_rate'] = NULL);
     }
     if (isset($nativeRequestData['shipping_expedited_mode'])) {
         $dataForUpdate['shipping_expedited_mode'] = (int) $nativeRequestData['shipping_expedited_mode'];
     }
     if (isset($nativeRequestData['shipping_expedited_rate'])) {
         $dataForUpdate['shipping_expedited_rate'] = $nativeRequestData['shipping_expedited_rate'];
         $dataForUpdate['shipping_expedited_rate'] === '' && ($dataForUpdate['shipping_expedited_rate'] = NULL);
     }
     if (isset($nativeRequestData['shipping_one_day_mode'])) {
         $dataForUpdate['shipping_one_day_mode'] = $nativeRequestData['shipping_one_day_mode'];
         $dataForUpdate['shipping_one_day_mode'] === '' && ($dataForUpdate['shipping_one_day_mode'] = NULL);
     }
     if (isset($nativeRequestData['shipping_one_day_rate'])) {
         $dataForUpdate['shipping_one_day_rate'] = $nativeRequestData['shipping_one_day_rate'];
         $dataForUpdate['shipping_one_day_rate'] === '' && ($dataForUpdate['shipping_one_day_rate'] = NULL);
     }
     if (isset($nativeRequestData['shipping_two_day_mode'])) {
         $dataForUpdate['shipping_two_day_mode'] = $nativeRequestData['shipping_two_day_mode'];
         $dataForUpdate['shipping_two_day_mode'] === '' && ($dataForUpdate['shipping_two_day_mode'] = NULL);
     }
     if (isset($nativeRequestData['shipping_two_day_rate'])) {
         $dataForUpdate['shipping_two_day_rate'] = $nativeRequestData['shipping_two_day_rate'];
         $dataForUpdate['shipping_two_day_rate'] === '' && ($dataForUpdate['shipping_two_day_rate'] = NULL);
     }
     $listingProduct->addData($dataForUpdate)->save();
 }
Beispiel #4
0
 protected function updateProductAfterAction(Ess_M2ePro_Model_Listing_Product $listingProduct, array $nativeRequestData = array(), array $params = array(), $startDate = false)
 {
     $dataForUpdate = array('status' => Ess_M2ePro_Model_Listing_Product::STATUS_LISTED, 'is_afn_channel' => Ess_M2ePro_Model_Amazon_Listing_Product::IS_AFN_CHANNEL_NO);
     if ($this->isAllPermissionsEnabled($this->getPreparedPermissions($params['params']))) {
         $dataForUpdate['synch_status'] = Ess_M2ePro_Model_Listing_Product::SYNCH_STATUS_OK;
         $dataForUpdate['synch_reasons'] = NULL;
     }
     isset($params['status_changer']) && ($dataForUpdate['status_changer'] = (int) $params['status_changer']);
     $startDate !== false && ($dataForUpdate['start_date'] = $startDate);
     if (isset($nativeRequestData['qty'])) {
         $dataForUpdate['online_qty'] = (int) $nativeRequestData['qty'];
         if ((int) $dataForUpdate['online_qty'] > 0) {
             $dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_LISTED;
             $dataForUpdate['end_date'] = NULL;
         } else {
             $dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED;
             $dataForUpdate['end_date'] = Mage::helper('M2ePro')->getCurrentGmtDate();
         }
     }
     if (isset($nativeRequestData['price'])) {
         $dataForUpdate['online_price'] = (double) $nativeRequestData['price'];
         $dataForUpdate['online_sale_price'] = NULL;
         $dataForUpdate['online_sale_price_start_date'] = NULL;
         $dataForUpdate['online_sale_price_end_date'] = NULL;
         if (isset($nativeRequestData['sale_price'])) {
             $salePrice = (double) $nativeRequestData['sale_price'];
             if ($salePrice > 0) {
                 $dataForUpdate['online_sale_price'] = $salePrice;
                 $dataForUpdate['online_sale_price_start_date'] = $nativeRequestData['sale_price_start_date'];
                 $dataForUpdate['online_sale_price_end_date'] = $nativeRequestData['sale_price_end_date'];
             } else {
                 $dataForUpdate['online_sale_price'] = 0;
             }
         }
     }
     $listingProduct->addData($dataForUpdate)->save();
 }
 private function modifyAndLogListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct, $status, $duplicateItemId = null)
 {
     /** @var Ess_M2ePro_Model_Listing_Log $logModel */
     $logModel = Mage::getModel('M2ePro/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_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::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 = Mage::helper('M2ePro')->__($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_Abstract::TYPE_WARNING, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
 }
Beispiel #6
0
 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'] . Mage::helper('M2ePro')->__(' (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 = Mage::getModel('M2ePro/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;
     }
     $this->checkAndCreateMagentoAttributes(array('ebay_translated_title' => 'Ebay Translated Title', 'ebay_translated_subtitle' => 'Ebay Translated Subtitle'), 'text');
     $this->checkAndCreateMagentoAttributes(array('ebay_translated_description' => 'Ebay Translated Description'), 'textarea');
     $this->checkAndCreateMagentoProductAttributes($listingProduct->getMagentoProduct(), array('ebay_translated_title', 'ebay_translated_subtitle', 'ebay_translated_description'));
     $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']) ? Mage::helper('M2ePro/Component_Ebay_Category_Ebay')->getPath((int) $response['category']['primary_id'], $this->params['marketplace_id']) : '';
     $response['category']['path'] = $categoryPath;
     if ($categoryPath) {
         $data = Mage::getModel('M2ePro/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'] = Mage::getModel('M2ePro/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' => Mage::helper('M2ePro')->getCurrentGmtDate()))->save();
 }
Beispiel #7
0
 private function linkItem(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $data = array('general_id' => $listingProduct->getData('general_id'), 'sku' => $listingProduct->getData('sku'), 'status' => Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED);
     $listingProduct->addData($data)->save();
     $dataForAdd = array('account_id' => $listingProduct->getListing()->getAccountId(), 'marketplace_id' => $listingProduct->getListing()->getMarketplaceId(), 'sku' => $listingProduct->getData('sku'), 'product_id' => $listingProduct->getProductId(), 'store_id' => $listingProduct->getListing()->getStoreId());
     if ($listingProduct->getChildObject()->isVariationsReady()) {
         $variations = $listingProduct->getVariations(true);
         /* @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
         $variation = reset($variations);
         $options = $variation->getOptions();
         $dataForAdd['variation_options'] = array();
         foreach ($options as $optionData) {
             $dataForAdd['variation_options'][$optionData['attribute']] = $optionData['option'];
         }
         $dataForAdd['variation_options'] = json_encode($dataForAdd['variation_options']);
     }
     Mage::getModel('M2ePro/Buy_Item')->setData($dataForAdd)->save();
     $message = Mage::helper('M2ePro')->__('The product was found in your Rakuten.com inventory and linked by Reference ID.');
     $this->addListingsProductsLogsMessage($listingProduct, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
 }
Beispiel #8
0
 private function updateListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct, $generalId)
 {
     $tempSku = $listingProduct->getChildObject()->getAddingSku();
     $data = array('general_id' => $generalId, 'sku' => $tempSku, 'existance_check_status' => Ess_M2ePro_Model_Buy_Listing_Product::EXISTANCE_CHECK_STATUS_FOUND, 'status' => Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED);
     $listingProduct->addData($data)->save();
     $dataForAdd = array('account_id' => $listingProduct->getListing()->getGeneralTemplate()->getAccountId(), 'marketplace_id' => $listingProduct->getListing()->getGeneralTemplate()->getMarketplaceId(), 'sku' => $tempSku, 'product_id' => $listingProduct->getProductId(), 'store_id' => $listingProduct->getListing()->getStoreId());
     Mage::getModel('M2ePro/Buy_Item')->setData($dataForAdd)->save();
     $message = Mage::helper('M2ePro')->__('The product was found in your Rakuten.com inventory and linked by Reference ID.');
     $this->addListingsProductsLogsMessage($listingProduct, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
 }
Beispiel #9
0
 protected function updateProductAfterAction(Ess_M2ePro_Model_Listing_Product $listingProduct, array $nativeRequestData = array(), array $params = array(), $startDate = false)
 {
     $dataForUpdate = array('status' => Ess_M2ePro_Model_Listing_Product::STATUS_LISTED);
     isset($params['status_changer']) && ($dataForUpdate['status_changer'] = (int) $params['status_changer']);
     $startDate !== false && ($dataForUpdate['start_date'] = $startDate);
     if (isset($nativeRequestData['qty'])) {
         $dataForUpdate['online_qty'] = (int) $nativeRequestData['qty'];
         if ((int) $dataForUpdate['online_qty'] > 0) {
             $dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_LISTED;
             $dataForUpdate['end_date'] = NULL;
         } else {
             $dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED;
             $dataForUpdate['end_date'] = Mage::helper('M2ePro')->getCurrentGmtDate();
         }
     }
     if (isset($nativeRequestData['price'])) {
         $dataForUpdate['online_price'] = (double) $nativeRequestData['price'];
     }
     if (isset($nativeRequestData['condition_note'])) {
         $dataForUpdate['condition_note'] = (string) $nativeRequestData['condition_note'];
         $dataForUpdate['condition_note'] == '' && ($dataForUpdate['condition_note'] = new Zend_Db_Expr("''"));
     }
     if (isset($nativeRequestData['shipping_standard_rate'])) {
         $dataForUpdate['shipping_standard_rate'] = $nativeRequestData['shipping_standard_rate'];
         $dataForUpdate['shipping_standard_rate'] === '' && ($dataForUpdate['shipping_standard_rate'] = NULL);
     }
     if (isset($nativeRequestData['shipping_expedited_mode'])) {
         $dataForUpdate['shipping_expedited_mode'] = (int) $nativeRequestData['shipping_expedited_mode'];
     }
     if (isset($nativeRequestData['shipping_expedited_rate'])) {
         $dataForUpdate['shipping_expedited_rate'] = $nativeRequestData['shipping_expedited_rate'];
         $dataForUpdate['shipping_expedited_rate'] === '' && ($dataForUpdate['shipping_expedited_rate'] = NULL);
     }
     if (isset($nativeRequestData['shipping_one_day_mode'])) {
         $dataForUpdate['shipping_one_day_mode'] = $nativeRequestData['shipping_one_day_mode'];
         $dataForUpdate['shipping_one_day_mode'] === '' && ($dataForUpdate['shipping_one_day_mode'] = NULL);
     }
     if (isset($nativeRequestData['shipping_one_day_rate'])) {
         $dataForUpdate['shipping_one_day_rate'] = $nativeRequestData['shipping_one_day_rate'];
         $dataForUpdate['shipping_one_day_rate'] === '' && ($dataForUpdate['shipping_one_day_rate'] = NULL);
     }
     if (isset($nativeRequestData['shipping_two_day_mode'])) {
         $dataForUpdate['shipping_two_day_mode'] = $nativeRequestData['shipping_two_day_mode'];
         $dataForUpdate['shipping_two_day_mode'] === '' && ($dataForUpdate['shipping_two_day_mode'] = NULL);
     }
     if (isset($nativeRequestData['shipping_two_day_rate'])) {
         $dataForUpdate['shipping_two_day_rate'] = $nativeRequestData['shipping_two_day_rate'];
         $dataForUpdate['shipping_two_day_rate'] === '' && ($dataForUpdate['shipping_two_day_rate'] = NULL);
     }
     $listingProduct->addData($dataForUpdate)->save();
 }
Beispiel #10
0
 protected function updateProductAfterAction(Ess_M2ePro_Model_Listing_Product $listingProduct, array $nativeRequestData = array(), array $params = array(), $ebayItemsId = NULL, $saveSoldData = false)
 {
     $dataForUpdate = array('status' => Ess_M2ePro_Model_Listing_Product::STATUS_LISTED, 'additional_data' => $listingProduct->getAdditionalData());
     !empty($nativeRequestData['title']) && ($dataForUpdate['online_title'] = $nativeRequestData['title']);
     !empty($nativeRequestData['sku']) && ($dataForUpdate['online_sku'] = $nativeRequestData['sku']);
     $dataForUpdate['additional_data']['is_eps_ebay_images_mode'] = $params['is_eps_ebay_images_mode'];
     $isImagesUploadError = isset($params['is_images_upload_error']) ? $params['is_images_upload_error'] : false;
     if (isset($nativeRequestData['images']['images']) && !$isImagesUploadError) {
         $dataForUpdate['additional_data']['ebay_product_images_hash'] = sha1(json_encode($nativeRequestData['images']['images']));
     }
     !is_null($ebayItemsId) && ($dataForUpdate['ebay_item_id'] = (int) $ebayItemsId);
     isset($params['status_changer']) && ($dataForUpdate['status_changer'] = (int) $params['status_changer']);
     if (isset($nativeRequestData['category_main_id'])) {
         $dataForUpdate['online_category'] = Mage::helper('M2ePro/Component_Ebay_Category_Ebay')->getPath($nativeRequestData['category_main_id'], $listingProduct->getMarketplace()->getId()) . ' (' . $nativeRequestData['category_main_id'] . ')';
     }
     if (isset($params['start_date_raw'])) {
         $dataForUpdate['start_date'] = Ess_M2ePro_Model_Connector_Server_Ebay_Abstract::ebayTimeToString($params['start_date_raw']);
     }
     if (isset($params['end_date_raw'])) {
         $dataForUpdate['end_date'] = Ess_M2ePro_Model_Connector_Server_Ebay_Abstract::ebayTimeToString($params['end_date_raw']);
     }
     if ($saveSoldData) {
         $dataForUpdate['online_qty_sold'] = is_null($listingProduct->getChildObject()->getOnlineQtySold()) ? 0 : $listingProduct->getChildObject()->getOnlineQtySold();
         $tempIsVariation = $nativeRequestData['is_variation_item'] && isset($nativeRequestData['variation']);
         $tempUpdateFlag = $tempIsVariation || isset($nativeRequestData['qty']);
         if ($tempUpdateFlag) {
             $tempQty = $tempIsVariation ? $listingProduct->getChildObject()->getQty() : $nativeRequestData['qty'];
             $dataForUpdate['online_qty'] = (int) $tempQty + (int) $dataForUpdate['online_qty_sold'];
         }
     } else {
         $dataForUpdate['online_qty_sold'] = 0;
         $tempIsVariation = $nativeRequestData['is_variation_item'] && isset($nativeRequestData['variation']);
         $tempUpdateFlag = $tempIsVariation || isset($nativeRequestData['qty']);
         if ($tempUpdateFlag) {
             $tempQty = $tempIsVariation ? $listingProduct->getChildObject()->getQty() : $nativeRequestData['qty'];
             $dataForUpdate['online_qty'] = $tempQty;
         }
     }
     if ($listingProduct->getChildObject()->isListingTypeFixed()) {
         $dataForUpdate['online_start_price'] = NULL;
         $dataForUpdate['online_reserve_price'] = NULL;
         $dataForUpdate['online_bids'] = NULL;
         $tempIsVariation = $nativeRequestData['is_variation_item'] && isset($nativeRequestData['variation']);
         $tempUpdateFlag = $tempIsVariation || isset($nativeRequestData['price_fixed']);
         if ($tempUpdateFlag) {
             if ($tempIsVariation) {
                 $tempPrice = NULL;
                 foreach ($nativeRequestData['variation'] as $variation) {
                     if ((int) $variation['qty'] <= 0) {
                         continue;
                     }
                     if (!is_null($tempPrice) && (double) $variation['price'] >= $tempPrice) {
                         continue;
                     }
                     $tempPrice = (double) $variation['price'];
                 }
             } else {
                 $tempPrice = $nativeRequestData['price_fixed'];
             }
             $dataForUpdate['online_buyitnow_price'] = (double) $tempPrice;
         }
     } else {
         !$saveSoldData && ($dataForUpdate['online_bids'] = 0);
         if (isset($nativeRequestData['price_start'])) {
             $dataForUpdate['online_start_price'] = (double) $nativeRequestData['price_start'];
         }
         if (isset($nativeRequestData['price_reserve'])) {
             $dataForUpdate['online_reserve_price'] = (double) $nativeRequestData['price_reserve'];
         }
         if (isset($nativeRequestData['price_buyitnow'])) {
             $dataForUpdate['online_buyitnow_price'] = (double) $nativeRequestData['price_buyitnow'];
         }
     }
     $dataForUpdate['additional_data'] = json_encode($dataForUpdate['additional_data']);
     $listingProduct->addData($dataForUpdate)->save();
 }
 private function modifyAndLogListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct, $status, $duplicateItemId = null)
 {
     $additionalData = $listingProduct->getAdditionalData();
     unset($additionalData['last_failed_action_data']);
     $listingProduct->addData(array('status' => $status, 'additional_data' => json_encode($additionalData)))->save();
     /** @var Ess_M2ePro_Model_Listing_Log $logModel */
     $logModel = Mage::getModel('M2ePro/Listing_Log');
     $logModel->setComponentMode(Ess_M2ePro_Helper_Component_Ebay::NICK);
     $logActionId = $logModel->getNextActionId();
     $statusLogMessage = $this->getStatusLogMessage($status);
     Mage::log(print_r($listingProduct, true));
     $logModel->addProductMessage($listingProduct->getData('listing_id'), $listingProduct->getData('product_id'), $listingProduct->getId(), Ess_M2ePro_Model_Log_Abstract::INITIATOR_EXTENSION, $logActionId, Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL, $statusLogMessage, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
     if (is_null($duplicateItemId)) {
         return;
     }
     // ->__('Duplicated item %s was found and stopped on eBay.');
     $duplicateDeletedMessage = sprintf('Duplicated item %s was found and stopped on eBay.', $duplicateItemId);
     $logModel->addProductMessage($listingProduct->getData('listing_id'), $listingProduct->getData('product_id'), $listingProduct->getId(), Ess_M2ePro_Model_Log_Abstract::INITIATOR_EXTENSION, $logActionId, Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL, $duplicateDeletedMessage, Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
 }