Beispiel #1
0
 protected function validateChannelConditions($sourceVariations, $writeLogs = true)
 {
     $tempLog = Mage::getModel('M2ePro/Listing_Log');
     $tempLog->setComponentMode(Ess_M2ePro_Helper_Component_Ebay::NICK);
     $failResult = array('set' => array(), 'variations' => array());
     $set = $sourceVariations['set'];
     $variations = $sourceVariations['variations'];
     foreach ($set as $singleSet) {
         if (count($singleSet) > 30) {
             // Maximum 30 options by one attribute:
             // Color: Red, Blue, Green, ...
             $writeLogs && $tempLog->addProductMessage($this->listingProduct->getListingId(), $this->listingProduct->getProductId(), $this->listingProduct->getId(), $this->logsInitiator, $this->logsActionId, $this->logsAction, 'The product will be listed as a simple product as it has limitation for multi-variation items. Reason: ' . 'number of values for each option more than 30.', Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
             return $failResult;
         }
     }
     foreach ($variations as $singleVariation) {
         if (count($singleVariation) > 5) {
             // Max 5 pair attribute-option:
             // Color: Blue, Size: XL, ...
             $writeLogs && $tempLog->addProductMessage($this->listingProduct->getListingId(), $this->listingProduct->getProductId(), $this->listingProduct->getId(), Ess_M2ePro_Model_Log_Abstract::INITIATOR_UNKNOWN, NULL, Ess_M2ePro_Model_Listing_Log::ACTION_ADD_PRODUCT_TO_LISTING, 'The product will be listed as a simple product as it has limitation for multi-variation items. Reason: ' . 'number of options more than 5.', Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
             return $failResult;
         }
     }
     if (count($variations) > 250) {
         // Not more that 250 possible variations
         $writeLogs && $tempLog->addProductMessage($this->listingProduct->getListingId(), $this->listingProduct->getProductId(), $this->listingProduct->getId(), Ess_M2ePro_Model_Log_Abstract::INITIATOR_UNKNOWN, NULL, Ess_M2ePro_Model_Listing_Log::ACTION_ADD_PRODUCT_TO_LISTING, 'The product will be listed as a simple product as it has limitation for multi-variation items. Reason: ' . 'sum of quantities of all possible products options more than 250.', Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
         return $failResult;
     }
     return $sourceVariations;
 }
Beispiel #2
0
 public function logListingProductMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, array $messageData, $priority = Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM)
 {
     if ($this->storeMode) {
         $this->storedMessages[] = array('type' => $this->initLogType($messageData[Ess_M2ePro_Model_Connector_Protocol::MESSAGE_TYPE_KEY]), 'text' => $messageData[Ess_M2ePro_Model_Connector_Protocol::MESSAGE_TEXT_KEY]);
         return;
     }
     $this->getListingLog()->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), $this->initiator, $this->actionId, $this->action, $messageData[Ess_M2ePro_Model_Connector_Protocol::MESSAGE_TEXT_KEY], $this->initLogType($messageData[Ess_M2ePro_Model_Connector_Protocol::MESSAGE_TYPE_KEY]), $priority);
 }
Beispiel #3
0
 public function unsetLocks($hash, $fail = false, $message = NULL)
 {
     if (!$this->unsetProcessingLock) {
         return;
     }
     $this->listingProduct->deleteObjectLocks(NULL, $hash);
     $this->listingProduct->deleteObjectLocks('in_action', $hash);
     $this->listingProduct->deleteObjectLocks('search_action', $hash);
     $this->listingProduct->getListing()->deleteObjectLocks(NULL, $hash);
     $this->listingProduct->getListing()->deleteObjectLocks('products_in_action', $hash);
     $this->listingProduct->getListing()->deleteObjectLocks('products_search_action', $hash);
     $this->getAccount()->deleteObjectLocks('products_in_action', $hash);
     $this->getAccount()->deleteObjectLocks('products_search_action', $hash);
     $this->getMarketplace()->deleteObjectLocks('products_in_action', $hash);
     $this->getMarketplace()->deleteObjectLocks('products_search_action', $hash);
     $processingStatus = Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_SEARCH_STATUS_NONE;
     $this->listingProduct->getChildObject()->setData('general_id_search_status', $processingStatus)->save();
     if ($fail) {
         $logModel = Mage::getModel('M2ePro/Listing_Log');
         $logModel->setComponentMode(Ess_M2ePro_Helper_Component_Amazon::NICK);
         $logModel->addListingMessage($this->listingProduct->getListingId(), Ess_M2ePro_Model_Log_Abstract::INITIATOR_UNKNOWN, NULL, Ess_M2ePro_Model_Listing_Log::ACTION_UNKNOWN, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR, Ess_M2ePro_Model_Log_Abstract::PRIORITY_HIGH);
     }
 }
 protected function addListingsProductsLogsMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, $text, $type = Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, $priority = Ess_M2ePro_Model_Log_Abstract::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;
         }
     }
     $logModel = Mage::getModel('M2ePro/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);
 }
 private function logReportChange(Ess_M2ePro_Model_Listing_Product $listingProduct, $logMessage)
 {
     if (empty($logMessage)) {
         return;
     }
     $log = Mage::getModel('M2ePro/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_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
 }
Beispiel #6
0
 protected function addBaseListingsLogsMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, $text, $type = Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, $priority = Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM, $isListingMode = true)
 {
     $action = $this->getListingsLogsCurrentAction();
     is_null($action) && ($action = Ess_M2ePro_Model_Listing_Log::ACTION_UNKNOWN);
     switch ($type) {
         case Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR:
             $this->setStatus(Ess_M2ePro_Helper_Data::STATUS_ERROR);
             break;
         case Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING:
             $this->setStatus(Ess_M2ePro_Helper_Data::STATUS_WARNING);
             break;
         case Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS:
         case Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE:
             $this->setStatus(Ess_M2ePro_Helper_Data::STATUS_SUCCESS);
             break;
         default:
             $this->setStatus(Ess_M2ePro_Helper_Data::STATUS_ERROR);
             break;
     }
     $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_UNKNOWN;
     if ($this->params['status_changer'] == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_UNKNOWN) {
         $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_UNKNOWN;
     } else {
         if ($this->params['status_changer'] == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) {
             $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_USER;
         } else {
             $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_EXTENSION;
         }
     }
     $logModel = Mage::getModel('M2ePro/Listing_Log');
     $logModel->setComponentMode(Ess_M2ePro_Helper_Component_Play::NICK);
     if ($isListingMode) {
         $logModel->addListingMessage($listingProduct->getListingId(), $initiator, $this->logsActionId, $action, $text, $type, $priority);
     } else {
         $logModel->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), $initiator, $this->logsActionId, $action, $text, $type, $priority);
     }
 }
 private function prepareChangedListingsProducts(Ess_M2ePro_Model_Listing_Product $tempListingProductModel, $ebayChange)
 {
     /** @var $tempEbayListingProductModel Ess_M2ePro_Model_Ebay_Listing_Product */
     $tempEbayListingProductModel = $tempListingProductModel->getChildObject();
     // Prepare eBay changes values
     //--------------------------
     $tempEbayChanges = array();
     if ($tempEbayListingProductModel->isListingTypeAuction()) {
         $tempEbayChanges['online_start_price'] = (double) $ebayChange['currentPrice'] < 0 ? 0 : (double) $ebayChange['currentPrice'];
     }
     if ($tempEbayListingProductModel->isListingTypeFixed()) {
         $tempEbayChanges['online_buyitnow_price'] = (double) $ebayChange['currentPrice'] < 0 ? 0 : (double) $ebayChange['currentPrice'];
     }
     $tempEbayChanges['online_qty'] = (int) $ebayChange['quantity'] < 0 ? 0 : (int) $ebayChange['quantity'];
     $tempEbayChanges['online_qty_sold'] = (int) $ebayChange['quantitySold'] < 0 ? 0 : (int) $ebayChange['quantitySold'];
     if ($tempEbayListingProductModel->isListingTypeAuction()) {
         $tempEbayChanges['online_qty'] = 1;
         $tempEbayChanges['online_bids'] = (int) $ebayChange['bidCount'] < 0 ? 0 : (int) $ebayChange['bidCount'];
     }
     $tempEbayChanges['start_date'] = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($ebayChange['startTime']);
     $tempEbayChanges['end_date'] = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($ebayChange['endTime']);
     if ($tempEbayChanges['online_qty'] == $tempEbayChanges['online_qty_sold'] && ($ebayChange['listingStatus'] == self::EBAY_STATUS_COMPLETED || $ebayChange['listingStatus'] == self::EBAY_STATUS_ENDED)) {
         $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_SOLD;
     } else {
         if ($ebayChange['listingStatus'] == self::EBAY_STATUS_COMPLETED) {
             $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED;
         } else {
             if ($ebayChange['listingStatus'] == self::EBAY_STATUS_ENDED) {
                 $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_FINISHED;
             } else {
                 if ($ebayChange['listingStatus'] == self::EBAY_STATUS_ACTIVE) {
                     $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_LISTED;
                 }
             }
         }
     }
     if ($tempListingProductModel->getStatus() != $tempEbayChanges['status'] || $tempListingProductModel->getChildObject()->getOnlineQty() != $tempEbayChanges['online_qty'] || $tempListingProductModel->getChildObject()->getOnlineQtySold() != $tempEbayChanges['online_qty_sold']) {
         Mage::getModel('M2ePro/ProductChange')->addUpdateAction($tempListingProductModel->getProductId(), Ess_M2ePro_Model_ProductChange::CREATOR_TYPE_SYNCHRONIZATION);
     }
     if ($tempEbayChanges['status'] != $tempListingProductModel->getStatus()) {
         $tempEbayChanges['status_changer'] = Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_COMPONENT;
         $tempLogMessage = '';
         switch ($tempEbayChanges['status']) {
             case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Listed".');
                 $tempLogMessage = 'Item status was successfully changed to "Listed".';
                 break;
             case Ess_M2ePro_Model_Listing_Product::STATUS_SOLD:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Sold".');
                 $tempLogMessage = 'Item status was successfully changed to "Sold".';
                 break;
             case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Stopped".');
                 $tempLogMessage = 'Item status was successfully changed to "Stopped".';
                 break;
             case Ess_M2ePro_Model_Listing_Product::STATUS_FINISHED:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Finished".');
                 $tempLogMessage = 'Item status was successfully changed to "Finished".';
                 break;
         }
         $tempLog = Mage::getModel('M2ePro/Listing_Log');
         $tempLog->setComponentMode(Ess_M2ePro_Helper_Component_Ebay::NICK);
         $tempLog->addProductMessage($tempListingProductModel->getListingId(), $tempListingProductModel->getProductId(), $tempListingProductModel->getId(), Ess_M2ePro_Model_Log_Abstract::INITIATOR_EXTENSION, $this->getLogActionId(), Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL, $tempLogMessage, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
     }
     //--------------------------
     // Create changed listings products
     //--------------------------
     $changedListingsProducts = array('ebay_item_id' => $ebayChange['id'], 'listing_product' => array('instance' => $tempListingProductModel, 'changes' => $tempEbayChanges), 'listings_products_variations' => array());
     //--------------------------
     // Cancel when have not eBay variations
     //--------------------------
     if (!isset($ebayChange['variations']) || is_null($ebayChange['variations'])) {
         return $changedListingsProducts;
     }
     //--------------------------
     // Get listings products variations
     //-----------------------
     $tempVariations = $tempListingProductModel->getVariations(true);
     if (count($tempVariations) == 0) {
         return $changedListingsProducts;
     }
     //-----------------------
     // Get listings products variations with options
     //-----------------------
     $tempVariationsWithOptions = array();
     foreach ($tempVariations as $variation) {
         /** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
         $options = $variation->getOptions(true);
         if (count($options) == 0) {
             continue;
         }
         $tempVariationsWithOptions[] = array('variation' => $variation, 'options' => $options);
     }
     if (count($tempVariationsWithOptions) == 0) {
         return $changedListingsProducts;
     }
     //-----------------------
     // Search our variations for eBay variations
     //--------------------------
     foreach ($ebayChange['variations'] as $ebayVariation) {
         // Find our variation
         //--------------------------
         foreach ($tempVariationsWithOptions as $M2eProVariation) {
             $equalVariation = true;
             foreach ($M2eProVariation['options'] as $M2eProOptionValue) {
                 $haveOption = false;
                 foreach ($ebayVariation['specifics'] as $ebayOptionKey => $ebayOptionValue) {
                     if ($M2eProOptionValue->getData('attribute') == $ebayOptionKey && $M2eProOptionValue->getData('option') == $ebayOptionValue) {
                         $haveOption = true;
                         break;
                     }
                 }
                 if ($haveOption === false) {
                     $equalVariation = false;
                     break;
                 }
             }
             if ($equalVariation === true && count($M2eProVariation['options']) == count($ebayVariation['specifics'])) {
                 // Prepare eBay changes values
                 //--------------------------
                 $tempEbayChanges = array();
                 $tempEbayChanges['online_price'] = (double) $ebayVariation['price'] < 0 ? 0 : (double) $ebayVariation['price'];
                 $tempEbayChanges['online_qty'] = (int) $ebayVariation['quantity'] < 0 ? 0 : (int) $ebayVariation['quantity'];
                 $tempEbayChanges['online_qty_sold'] = (int) $ebayVariation['quantitySold'] < 0 ? 0 : (int) $ebayVariation['quantitySold'];
                 if ($tempEbayChanges['online_qty'] <= $tempEbayChanges['online_qty_sold']) {
                     $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_SOLD;
                 }
                 if ($tempEbayChanges['online_qty'] <= 0) {
                     $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED;
                 }
                 //--------------------------
                 // Add changed variation
                 //--------------------------
                 $changedListingsProducts['listings_products_variations'][] = array('instance' => $M2eProVariation, 'changes' => $tempEbayChanges);
                 //--------------------------
                 break;
             }
         }
         //--------------------------
     }
     return $changedListingsProducts;
 }
Beispiel #8
0
 protected function addBaseListingsLogsMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, $text, $type = Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, $priority = Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM, $isListingMode = true)
 {
     $action = $this->getListingsLogsCurrentAction();
     is_null($action) && ($action = Ess_M2ePro_Model_Listing_Log::ACTION_UNKNOWN);
     $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_UNKNOWN;
     if ($this->getStatusChanger() == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_UNKNOWN) {
         $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_UNKNOWN;
     } else {
         if ($this->getStatusChanger() == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) {
             $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_USER;
         } else {
             $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_EXTENSION;
         }
     }
     $logModel = Mage::getModel('M2ePro/Listing_Log');
     $logModel->setComponentMode(Ess_M2ePro_Helper_Component_Play::NICK);
     if ($isListingMode) {
         $logModel->addListingMessage($listingProduct->getListingId(), $initiator, $this->getLogsActionId(), $action, $text, $type, $priority);
     } else {
         $logModel->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), $initiator, $this->getLogsActionId(), $action, $text, $type, $priority);
     }
 }
Beispiel #9
0
 /**
  * @param Ess_M2ePro_Model_Listing_Product $listingProduct
  * @param $message
  * @param int $type
  * @param int $priority
  */
 public function logListingProductMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, $message, $type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR, $priority = Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM)
 {
     $this->setStatusByMessageType($type);
     $this->getListingLog()->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), $this->initiator, $this->actionId, $this->action, $message, $type, $priority);
 }
 private function logChangeOfStatus(Ess_M2ePro_Model_Listing_Product $listingProduct, $status)
 {
     $message = '';
     switch ($status) {
         case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
             // M2ePro_TRANSLATIONS
             // Item status was successfully changed to "Listed".
             $message = 'Item status was successfully changed to "Listed".';
             break;
         case Ess_M2ePro_Model_Listing_Product::STATUS_HIDDEN:
             // M2ePro_TRANSLATIONS
             // Item status was successfully changed to "Listed(Hidden)".
             $message = 'Item status was successfully changed to "Listed(Hidden)".';
             break;
         case Ess_M2ePro_Model_Listing_Product::STATUS_SOLD:
             // M2ePro_TRANSLATIONS
             // Item status was successfully changed to "Sold".
             $message = 'Item status was successfully changed to "Sold".';
             break;
         case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
             // M2ePro_TRANSLATIONS
             // Item status was successfully changed to "Stopped".
             $message = 'Item status was successfully changed to "Stopped".';
             break;
         case Ess_M2ePro_Model_Listing_Product::STATUS_FINISHED:
             // M2ePro_TRANSLATIONS
             // Item status was successfully changed to "Finished".
             $message = 'Item status was successfully changed to "Finished".';
             break;
     }
     $log = Mage::getModel('M2ePro/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_CHANGE_STATUS_ON_CHANNEL, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
 }
 private function logListingProductMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, $action, $oldValue, $newValue)
 {
     // M2ePro_TRANSLATIONS
     // From [%from%] to [%to%].
     $log = Mage::getModel('M2ePro/Listing_Log');
     $log->setComponentMode($listingProduct->getComponentMode());
     $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, NULL, $action, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%].', array('from' => $oldValue, 'to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
 }
 private function logListingProductMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, $action, $oldValue, $newValue, $messagePostfix = '')
 {
     // M2ePro_TRANSLATIONS
     // From [%from%] to [%to%].
     $log = Mage::getModel('M2ePro/' . 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 = Mage::getModel('M2ePro/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, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::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, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW, $additionalData);
         return;
     }
     $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, NULL, $action, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
 }
Beispiel #13
0
 private function logListingProductMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, $action, $oldValue, $newValue, $messagePostfix = '')
 {
     // M2ePro_TRANSLATIONS
     // From [%from%] to [%to%].
     if ($listingProduct->isComponentModeEbay()) {
         $log = Mage::getModel('M2ePro/Listing_Log');
         $log->setComponentMode($listingProduct->getComponentMode());
     } else {
         $log = Mage::getModel('M2ePro/' . 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;
     }
     $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, NULL, $action, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
 }