Exemplo n.º 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;
 }
Exemplo n.º 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);
 }
 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);
 }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 5
0
 protected function createNewAmazonItem(Ess_M2ePro_Model_Listing_Product $listingProduct, $sku)
 {
     $dataForAdd = array('account_id' => (int) $listingProduct->getListing()->getAccountId(), 'marketplace_id' => (int) $listingProduct->getListing()->getMarketplaceId(), 'sku' => $sku, 'product_id' => (int) $listingProduct->getProductId(), 'store_id' => (int) $listingProduct->getListing()->getStoreId());
     if ($listingProduct->getChildObject()->isVariationMatched() && $listingProduct->getChildObject()->isVariationProduct()) {
         $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']);
     }
     return Mage::getModel('M2ePro/Amazon_Item')->setData($dataForAdd)->save()->getId();
 }
Exemplo n.º 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);
     $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);
     }
 }
 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;
 }
Exemplo n.º 8
0
 protected function isTheSameProductAlreadyListed(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $config = Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/ebay/connector/listing/', 'check_the_same_product_already_listed');
     if (!is_null($config) && $config != 1) {
         return false;
     }
     $listingProductCollection = Mage::helper('M2ePro/Component_Ebay')->getCollection('Listing_Product');
     $listingTable = Mage::getResourceModel('M2ePro/Listing')->getMainTable();
     $listingProductCollection->getSelect()->join(array('l' => $listingTable), '`main_table`.`listing_id` = `l`.`id`', array());
     $listingProductCollection->addFieldToFilter('status', array('neq' => Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED))->addFieldToFilter('product_id', $listingProduct->getProductId())->addFieldToFilter('account_id', $this->account->getId())->addFieldToFilter('marketplace_id', $this->marketplace->getId());
     $theSameListingProduct = $listingProductCollection->getFirstItem();
     if (!$theSameListingProduct->getId()) {
         return false;
     }
     $listing = $theSameListingProduct->getListing();
     $message = Mage::helper('M2ePro')->__('There is another item with the same eBay user ID, product ID and marketplace presented in "%s" (%d) Listing.', $listing->getTitle(), $listing->getId());
     $message = array(parent::MESSAGE_TEXT_KEY => $message, parent::MESSAGE_TYPE_KEY => parent::MESSAGE_TYPE_ERROR);
     $this->addListingsProductsLogsMessage($listingProduct, $message, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
     return true;
 }
Exemplo n.º 9
0
 protected function createNewAmazonItem(Ess_M2ePro_Model_Listing_Product $listingProduct, $sku)
 {
     $dataForAdd = array('account_id' => (int) $listingProduct->getListing()->getGeneralTemplate()->getAccountId(), 'marketplace_id' => (int) $listingProduct->getListing()->getGeneralTemplate()->getMarketplaceId(), 'sku' => $sku, 'product_id' => (int) $listingProduct->getProductId(), 'store_id' => (int) $listingProduct->getListing()->getStoreId());
     return Mage::getModel('M2ePro/Amazon_Item')->setData($dataForAdd)->save()->getId();
 }
 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);
 }
Exemplo n.º 11
0
 private function updateListingsProductChange(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     Mage::getModel('M2ePro/ProductChange')->addUpdateAction($listingProduct->getProductId(), Ess_M2ePro_Model_ProductChange::CREATOR_TYPE_SYNCHRONIZATION);
     $variations = $listingProduct->getVariations(true);
     foreach ($variations as $variation) {
         /** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
         $options = $variation->getOptions(true);
         foreach ($options as $option) {
             /** @var $option Ess_M2ePro_Model_Listing_Product_Variation_Option */
             Mage::getModel('M2ePro/ProductChange')->addUpdateAction($option->getProductId(), Ess_M2ePro_Model_ProductChange::CREATOR_TYPE_SYNCHRONIZATION);
         }
     }
 }
Exemplo n.º 12
0
 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);
 }
Exemplo n.º 13
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);
 }
Exemplo n.º 14
0
 private function duplicateListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $duplicatedListingProduct = $listingProduct->getListing()->addProduct($listingProduct->getProductId(), false, false);
     $variationManager = $listingProduct->getChildObject()->getVariationManager();
     if (!$variationManager->isVariationProduct()) {
         return $duplicatedListingProduct;
     }
     if ($listingProduct->isComponentModeAmazon()) {
         $duplicatedListingProductManager = $duplicatedListingProduct->getChildObject()->getVariationManager();
         if ($variationManager->isIndividualType() && $duplicatedListingProductManager->modeCanBeSwitched()) {
             $duplicatedListingProductManager->switchModeToAnother();
         }
     }
     return $duplicatedListingProduct;
 }
Exemplo n.º 15
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);
 }
Exemplo n.º 16
0
 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);
 }
 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);
 }
Exemplo n.º 18
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);
 }
Exemplo n.º 19
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);
 }
Exemplo n.º 20
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);
 }
Exemplo n.º 21
0
 protected function createNewEbayItemsId(Ess_M2ePro_Model_Listing_Product $listingProduct, $ebayRealItemId)
 {
     $dataForAdd = array('item_id' => (double) $ebayRealItemId, 'product_id' => (int) $listingProduct->getProductId(), 'store_id' => (int) $listingProduct->getListing()->getStoreId());
     return Mage::getModel('M2ePro/Ebay_Item')->setData($dataForAdd)->save()->getId();
 }
Exemplo n.º 22
0
 private function updateListingsProductChange(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     Mage::getModel('M2ePro/ProductChange')->addUpdateAction($listingProduct->getProductId(), Ess_M2ePro_Model_ProductChange::INITIATOR_INSPECTOR);
     foreach ($listingProduct->getVariations(true) as $variation) {
         /** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
         foreach ($variation->getOptions(true) as $option) {
             /** @var $option Ess_M2ePro_Model_Listing_Product_Variation_Option */
             Mage::getModel('M2ePro/ProductChange')->addUpdateAction($option->getProductId(), Ess_M2ePro_Model_ProductChange::INITIATOR_INSPECTOR);
         }
     }
 }