protected function logSuccessfulOperation(Ess_M2ePro_Model_Marketplace $marketplace) { // M2ePro_TRANSLATIONS // The "Categories" action for Rakuten Marketplace: "%mrk%" has been successfully completed. $tempString = Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('The "Categories" action for Rakuten Marketplace: "%mrk%" has been successfully completed.', array('mrk' => $marketplace->getTitle())); $this->getLog()->addMessage($tempString, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW); }
protected function logSuccessfulOperation(Ess_M2ePro_Model_Marketplace $marketplace) { // M2ePro_TRANSLATIONS // The "Details" Action for %amazon% Marketplace: "%mrk%" has been successfully completed. $tempString = Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('The "Details" Action for %amazon% Marketplace: "%mrk%" has been successfully completed.', array('!amazon' => Mage::helper('M2ePro/Component_Amazon')->getTitle(), 'mrk' => $marketplace->getTitle())); $this->getLog()->addMessage($tempString, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW); }
public function process() { if (!is_null($this->account) && !is_null($this->marketplace)) { /** @var $amazonAccount Ess_M2ePro_Model_Amazon_Account */ $amazonAccount = $this->account->getChildObject(); $marketplaceDataTemp = $amazonAccount->getMarketplaceItem($this->marketplace->getId()); if (!is_null($marketplaceDataTemp)) { $this->requestExtraData['account'] = $marketplaceDataTemp['server_hash']; } } parent::process(); }
public function process() { if (!is_null($this->marketplace)) { $this->requestExtraData['marketplace'] = $this->marketplace->getNativeId(); } if (!is_null($this->account)) { $this->requestExtraData['account'] = $this->account->getChildObject()->getServerHash(); } if (!is_null($this->mode)) { $this->requestExtraData['mode'] = $this->mode; } parent::process(); }
private function parseShippingAddress(array $shippingData, Ess_M2ePro_Model_Marketplace $marketplace) { $location = isset($shippingData['location']) ? $shippingData['location'] : array(); $address = isset($shippingData['address']) ? $shippingData['address'] : array(); $parsedAddress = array('county' => isset($location['county']) ? trim($location['county']) : '', 'country_code' => isset($location['country_code']) ? trim($location['country_code']) : '', 'state' => isset($location['state']) ? trim($location['state']) : '', 'city' => isset($location['city']) ? trim($location['city']) : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'recipient_name' => isset($shippingData['buyer']) ? trim($shippingData['buyer']) : '', 'phone' => isset($shippingData['phone']) ? $shippingData['phone'] : '', 'company' => '', 'street' => array(isset($address['first']) ? $address['first'] : '', isset($address['second']) ? $address['second'] : '', isset($address['third']) ? $address['third'] : '')); $parsedAddress['street'] = array_filter($parsedAddress['street']); $group = '/amazon/order/settings/marketplace_' . $marketplace->getId() . '/'; $useFirstStreetLineAsCompany = Mage::helper('M2ePro/Module')->getConfig()->getGroupValue($group, 'use_first_street_line_as_company'); if ($useFirstStreetLineAsCompany && count($parsedAddress['street']) > 1) { $parsedAddress['company'] = array_shift($parsedAddress['street']); } return $parsedAddress; }
public function setLocks($hash) { $this->listingProduct->addObjectLock(NULL, $hash); $this->listingProduct->addObjectLock('in_action', $hash); $this->listingProduct->addObjectLock('search_action', $hash); $this->listingProduct->getListing()->addObjectLock(NULL, $hash); $this->listingProduct->getListing()->addObjectLock('products_in_action', $hash); $this->listingProduct->getListing()->addObjectLock('products_search_action', $hash); $this->account->addObjectLock('products_in_action', $hash); $this->account->addObjectLock('products_search_action', $hash); $this->marketplace->addObjectLock('products_in_action', $hash); $this->marketplace->addObjectLock('products_search_action', $hash); $processingStatus = Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_SEARCH_STATUS_PROCESSING; $this->listingProduct->getChildObject()->setData('general_id_search_status', $processingStatus)->save(); }
protected function setMarketplaceByOtherListingProduct(Ess_M2ePro_Model_Listing_Other $otherListing) { if (!is_null($this->marketplace) && $this->marketplace->getId() == $otherListing->getMarketplaceId()) { return; } $this->marketplace = Mage::helper('M2ePro/Component_Amazon')->getObject('Marketplace', $otherListing->getMarketplaceId()); }
protected function getResponserParams() { $tempProductsData = array(); foreach ($this->listingsProducts as $listingProduct) { $tempProductsData[$listingProduct->getId()] = isset($this->listingProductRequestsData[$listingProduct->getId()]) ? $this->listingProductRequestsData[$listingProduct->getId()] : array(); } return array('account_id' => $this->account->getId(), 'marketplace_id' => $this->marketplace->getId(), 'logs_action_id' => $this->logsActionId, 'status_changer' => $this->params['status_changer'], 'params' => $this->params, 'products' => $tempProductsData); }
public function setLocks($hash) { /** @var $lockItem Ess_M2ePro_Model_LockItem */ $lockItem = Mage::getModel('M2ePro/LockItem'); $tempNick = Ess_M2ePro_Model_Ebay_Synchronization_Tasks_OtherListings_Update::LOCK_ITEM_PREFIX; $tempNick .= '_' . $this->account->getId(); $lockItem->setNick($tempNick); $lockItem->create(); $this->account->addObjectLock(NULL, $hash); $this->account->addObjectLock('synchronization', $hash); $this->account->addObjectLock('synchronization_ebay', $hash); $this->account->addObjectLock(Ess_M2ePro_Model_Ebay_Synchronization_Tasks_OtherListings_Update::LOCK_ITEM_PREFIX, $hash); $this->marketplace->addObjectLock(NULL, $hash); $this->marketplace->addObjectLock('synchronization', $hash); $this->marketplace->addObjectLock('synchronization_ebay', $hash); $this->marketplace->addObjectLock(Ess_M2ePro_Model_Ebay_Synchronization_Tasks_OtherListings_Update::LOCK_ITEM_PREFIX, $hash); }
protected function addMotorsSpecificsData(Ess_M2ePro_Model_Listing_Product $listingProduct, Ess_M2ePro_Model_Marketplace $marketplace, Ess_M2ePro_Model_Ebay_Template_Category $categoryTemplate, array &$requestData) { if ($marketplace->getId() != Ess_M2ePro_Helper_Component_Ebay::MARKETPLACE_MOTORS) { return; } $categoryId = $categoryTemplate->getMainCategory(); $categoryData = $marketplace->getChildObject()->getCategory($categoryId); $features = !empty($categoryData['features']) ? (array) json_decode($categoryData['features'], true) : array(); $attributes = !empty($features['parts_compatibility_attributes']) ? $features['parts_compatibility_attributes'] : array(); if (empty($attributes)) { return; } $categoryTemplate->getMagentoProduct()->clearNotFoundAttributes(); $specifics = Mage::helper('M2ePro/Component_Ebay_MotorsSpecifics')->getSpecifics($listingProduct); if ($specifics === false) { return; } $notFoundAttributes = $categoryTemplate->getMagentoProduct()->getNotFoundAttributes(); if (!empty($notFoundAttributes)) { Mage::getModel('M2ePro/Connector_Server_Ebay_Item_Helper')->addNotFoundAttributesMessage($listingProduct, Mage::helper('M2ePro')->__('Compatibility'), $notFoundAttributes); return; } $requestData['motors_specifics'] = array(); foreach ($specifics as $specific) { $compatibilityList = array(); $compatibilityData = $specific->getCompatibilityData(); foreach ($compatibilityData as $key => $value) { if ($value == '--') { unset($compatibilityData[$key]); continue; } $name = $key; foreach ($attributes as $attribute) { if ($attribute['title'] == $key) { $name = $attribute['ebay_id']; break; } } $compatibilityList[] = array('name' => $name, 'value' => $value); } $requestData['motors_specifics'][] = $compatibilityList; } }
public function setLocks($hash) { $tempListings = array(); foreach ($this->listingsProducts as $listingProduct) { /** @var $listingProduct Ess_M2ePro_Model_Listing_Product */ $listingProduct->addObjectLock(NULL, $hash); $listingProduct->addObjectLock('in_action', $hash); $listingProduct->addObjectLock('search_action', $hash); $processingStatus = Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_SEARCH_STATUS_PROCESSING; $listingProduct->getChildObject()->setData('general_id_search_status', $processingStatus)->save(); if (isset($tempListings[$listingProduct->getListingId()])) { continue; } $listingProduct->getListing()->addObjectLock(NULL, $hash); $listingProduct->getListing()->addObjectLock('products_in_action', $hash); $listingProduct->getListing()->addObjectLock('products_search_action', $hash); $tempListings[$listingProduct->getListingId()] = true; } $this->account->addObjectLock('products_in_action', $hash); $this->account->addObjectLock('products_search_action', $hash); $this->marketplace->addObjectLock('products_in_action', $hash); $this->marketplace->addObjectLock('products_search_action', $hash); }
protected function setLocks($hash) { $tempListings = array(); foreach ($this->listingsProducts as $listingProduct) { /** @var $listingProduct Ess_M2ePro_Model_Listing_Product */ $listingProduct->addObjectLock(NULL, $hash); $listingProduct->addObjectLock('in_action', $hash); $listingProduct->addObjectLock('translation_action', $hash); if (isset($tempListings[$listingProduct->getListingId()])) { continue; } $listingProduct->getListing()->addObjectLock(NULL, $hash); $listingProduct->getListing()->addObjectLock('products_in_action', $hash); $listingProduct->getListing()->addObjectLock('products_translation_action', $hash); $tempListings[$listingProduct->getListingId()] = true; } $this->account->addObjectLock('products_in_action', $hash); $this->account->addObjectLock('products_translation_action', $hash); $this->marketplace->addObjectLock('products_in_action', $hash); $this->marketplace->addObjectLock('products_translation_action', $hash); }
public function setLocks($hash) { /** @var $lockItem Ess_M2ePro_Model_LockItem */ $lockItem = Mage::getModel('M2ePro/LockItem'); $lockItemPrefix = Ess_M2ePro_Model_Play_Synchronization_Tasks_Orders_Receive::LOCK_ITEM_PREFIX; $nick = $lockItemPrefix . '_' . $this->account->getId() . '_' . $this->marketplace->getId(); $lockItem->setNick($nick); $lockItem->create(); $this->account->addObjectLock(NULL, $hash); $this->account->addObjectLock('synchronization', $hash); $this->account->addObjectLock('synchronization_play', $hash); $this->account->addObjectLock($lockItemPrefix, $hash); $this->marketplace->addObjectLock(NULL, $hash); $this->marketplace->addObjectLock('synchronization', $hash); $this->marketplace->addObjectLock('synchronization_play', $hash); $this->marketplace->addObjectLock($lockItemPrefix, $hash); }
public function setLocks($hash) { /** @var $lockItem Ess_M2ePro_Model_LockItem */ $lockItem = Mage::getModel('M2ePro/LockItem'); $tempNick = Ess_M2ePro_Model_Play_Synchronization_Tasks_Defaults_UpdateListingsProducts::LOCK_ITEM_PREFIX; $tempNick .= '_' . $this->account->getId() . '_' . $this->marketplace->getId(); $lockItem->setNick($tempNick); $lockItem->create(); $this->account->addObjectLock(NULL, $hash); $this->account->addObjectLock('synchronization', $hash); $this->account->addObjectLock('synchronization_play', $hash); $this->account->addObjectLock(Ess_M2ePro_Model_Play_Synchronization_Tasks_Defaults_UpdateListingsProducts::LOCK_ITEM_PREFIX, $hash); $this->marketplace->addObjectLock(NULL, $hash); $this->marketplace->addObjectLock('synchronization', $hash); $this->marketplace->addObjectLock('synchronization_play', $hash); $this->marketplace->addObjectLock(Ess_M2ePro_Model_Play_Synchronization_Tasks_Defaults_UpdateListingsProducts::LOCK_ITEM_PREFIX, $hash); /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */ $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write'); $tempTable = Mage::getSingleton('core/resource')->getTableName('m2epro_play_processed_inventory'); $connWrite->delete($tempTable, array('`hash` = ?' => (string) $hash)); }
private function processAccountMarketplace(Ess_M2ePro_Model_Account $account, Ess_M2ePro_Model_Marketplace $marketplace) { $title = 'Starting account "%s" and marketplace "%s"'; $title = sprintf($title, $account->getTitle(), $marketplace->getTitle()); $this->_profiler->addTitle($title); $this->_profiler->addTimePoint(__METHOD__ . 'send' . $account->getId(), 'Update orders on Rakuten.com'); $status = 'Task "%s" for Rakuten.com "%s" Account and "%s" marketplace is started. Please wait...'; $status = Mage::helper('M2ePro')->__($status, $this->name, $account->getTitle(), $marketplace->getTitle()); $this->_lockItem->setStatus($status); $changesCollection = Mage::getModel('M2ePro/Order_Change')->getCollection(); $changesCollection->addAccountFilter($account->getId()); $changesCollection->addProcessingAttemptDateFilter(); $changesCollection->addFieldToFilter('component', Ess_M2ePro_Helper_Component_Buy::NICK); $changesCollection->addFieldToFilter('action', Ess_M2ePro_Model_Order_Change::ACTION_UPDATE_SHIPPING); $changesCollection->getSelect()->group(array('order_id')); if ($changesCollection->getSize() == 0) { return; } // Update orders shipping status on Rakuten.com //--------------------------- $params = array(); foreach ($changesCollection as $change) { $changeParams = $change->getParams(); $params[] = array('change_id' => $change->getId(), 'order_id' => $change->getOrderId(), 'buy_order_id' => $changeParams['buy_order_id'], 'buy_order_item_id' => $changeParams['buy_order_item_id'], 'qty' => $changeParams['qty'], 'tracking_type' => $changeParams['tracking_type'], 'tracking_number' => $changeParams['tracking_number'], 'ship_date' => $changeParams['ship_date']); } if (count($params) == 0) { return; } Mage::getResourceModel('M2ePro/Order_Change')->incrementAttemptCount($changesCollection->getAllIds()); $entity = 'orders'; $type = 'update'; $name = 'shipping'; /** @var $dispatcherObject Ess_M2ePro_Model_Connector_Server_Buy_Dispatcher */ $dispatcherObject = Mage::getModel('M2ePro/Connector_Server_Buy_Dispatcher'); $dispatcherObject->processConnector($entity, $type, $name, $params, $marketplace, $account); //--------------------------- $this->_profiler->saveTimePoint(__METHOD__ . 'send' . $account->getId()); $this->_profiler->addEol(); }
private function updateAccountMarketplace(Ess_M2ePro_Model_Account $accountObj, Ess_M2ePro_Model_Marketplace $marketplaceObj) { $this->_profiler->addTitle('Starting account "' . $accountObj->getTitle() . '" and marketplace "' . $marketplaceObj->getTitle() . '"'); $this->_profiler->addTimePoint(__METHOD__ . 'send' . $accountObj->getId(), 'Get inventory from Amazon'); $tempString = 'Task "3rd Party Listings Synchronization" for Amazon account: '; $tempString .= '"%s" and marketplace "%s" is started. Please wait...'; $this->_lockItem->setStatus(Mage::helper('M2ePro')->__($tempString, $accountObj->getTitle(), $marketplaceObj->getTitle())); // Get all changes on Amazon for account //--------------------------- $dispatcherObject = Mage::getModel('M2ePro/Connector_Server_Amazon_Dispatcher'); $dispatcherObject->processConnector('tasks', 'otherListings', 'requester', array(), $marketplaceObj, $accountObj, 'Ess_M2ePro_Model_Amazon_Synchronization'); //--------------------------- $this->_profiler->saveTimePoint(__METHOD__ . 'send' . $accountObj->getId()); $this->_profiler->addEol(); }
private function processAccountMarketplace(Ess_M2ePro_Model_Account $account, Ess_M2ePro_Model_Marketplace $marketplace) { $title = 'Starting account "%s" and marketplace "%s%'; $title = sprintf($title, $account->getTitle(), $marketplace->getTitle()); $this->_profiler->addTitle($title); $this->_profiler->addTimePoint(__METHOD__ . 'send' . $account->getId(), 'Get orders from Play'); $status = 'Task "%s" for Play.com "%s" Account and "%s" marketplace is started. Please wait...'; $status = Mage::helper('M2ePro')->__($status, $this->name, $account->getTitle(), $marketplace->getTitle()); $this->_lockItem->setStatus($status); //------------------------------ $fromDate = $this->prepareFromDate($account->getData('orders_last_synchronization')); $params = array('from_date' => $fromDate); if (is_null($account->getData('orders_last_synchronization'))) { $account->setData('orders_last_synchronization', $fromDate)->save(); } //------------------------------ // Get open orders from Play.com for account //--------------------------- /** @var $dispatcherObject Ess_M2ePro_Model_Connector_Server_Play_Dispatcher */ $dispatcherObject = Mage::getModel('M2ePro/Connector_Server_Play_Dispatcher'); $prefix = 'Ess_M2ePro_Model_Play_Synchronization'; $dispatcherObject->processConnector('tasks', 'orders_receive', 'requester', $params, $marketplace, $account, $prefix); //--------------------------- $this->_profiler->saveTimePoint(__METHOD__ . 'send' . $account->getId()); $this->_profiler->addEol(); }
private function processAccountMarketplace(Ess_M2ePro_Model_Account $account, Ess_M2ePro_Model_Marketplace $marketplace) { $title = 'Starting account "' . $account->getTitle() . '" and marketplace "' . $marketplace->getTitle() . '"'; $this->_profiler->addTitle($title); $this->_profiler->addTimePoint(__METHOD__ . 'send' . $account->getId(), 'Update orders on Amazon'); $status = 'Task "%s" for Amazon "%s" Account and "%s" marketplace is started. Please wait...'; $status = Mage::helper('M2ePro')->__($status, $this->name, $account->getTitle(), $marketplace->getTitle()); $this->_lockItem->setStatus($status); $changesCollection = Mage::getModel('M2ePro/Order_Change')->getCollection(); $changesCollection->addAccountFilter($account->getId()); $changesCollection->addProcessingAttemptDateFilter(); $changesCollection->addFieldToFilter('component', Ess_M2ePro_Helper_Component_Amazon::NICK); $changesCollection->addFieldToFilter('action', Ess_M2ePro_Model_Order_Change::ACTION_UPDATE_SHIPPING); $changesCollection->setPageSize(self::MAX_UPDATES_PER_TIME); $changesCollection->getSelect()->group(array('order_id')); if ($changesCollection->getSize() == 0) { return; } // Update orders shipping status on Rakuten.com //--------------------------- $items = array(); foreach ($changesCollection as $change) { $changeParams = $change->getParams(); $items[] = array('order_id' => $change->getOrderId(), 'change_id' => $change->getId(), 'amazon_order_id' => $changeParams['amazon_order_id'], 'tracking_number' => $changeParams['tracking_number'], 'carrier_name' => $changeParams['carrier_name'], 'fulfillment_date' => $changeParams['fulfillment_date'], 'shipping_method' => isset($changeParams['shipping_method']) ? $changeParams['shipping_method'] : null, 'items' => $changeParams['items']); } if (count($items) == 0) { return; } Mage::getResourceModel('M2ePro/Order_Change')->incrementAttemptCount($changesCollection->getAllIds()); /** @var $dispatcherObject Ess_M2ePro_Model_Connector_Server_Amazon_Dispatcher */ $dispatcherObject = Mage::getModel('M2ePro/Connector_Server_Amazon_Dispatcher'); $dispatcherObject->processConnector('orders', 'update', 'items', array('items' => $items), $marketplace, $account); //--------------------------- $this->_profiler->saveTimePoint(__METHOD__ . 'send' . $account->getId()); $this->_profiler->addEol(); }
private function updateAccountMarketplace(Ess_M2ePro_Model_Account $accountObj, Ess_M2ePro_Model_Marketplace $marketplaceObj) { $this->_profiler->addTitle('Starting account "' . $accountObj->getTitle() . '" and marketplace "' . $marketplaceObj->getTitle() . '"'); $this->_profiler->addTimePoint(__METHOD__ . 'send' . $accountObj->getId(), 'Get orders from Amazon'); //->__('Task "Orders Synchronization" for Amazon account: "%s" and marketplace "%s" is started. Please wait...') $tempString = 'Task "Orders Synchronization" for Amazon account: '; $tempString .= '"%s" and marketplace "%s" is started. Please wait...'; $this->_lockItem->setStatus(Mage::helper('M2ePro')->__($tempString, $accountObj->getTitle(), $marketplaceObj->getTitle())); // Get orders from Amazon for account //--------------------------- $fromDate = $this->prepareFromDate($accountObj->getData('orders_last_synchronization')); $params = array('from_date' => $fromDate); if (is_null($accountObj->getData('orders_last_synchronization'))) { $accountObj->setData('orders_last_synchronization', $fromDate)->save(); } $dispatcherObject = Mage::getModel('M2ePro/Amazon_Connector')->getDispatcher(); $dispatcherObject->processConnector('tasks', 'orders', 'requester', $params, $marketplaceObj, $accountObj, 'Ess_M2ePro_Model_Amazon_Synchronization'); //--------------------------- $this->_profiler->saveTimePoint(__METHOD__ . 'send' . $accountObj->getId()); $this->_profiler->addEol(); }
protected function receiveFromEbay(Ess_M2ePro_Model_Marketplace $marketplace, Ess_M2ePro_Model_Account $account) { $policies = Mage::getModel('M2ePro/Connector_Ebay_Dispatcher')->processVirtual('account', 'get', 'policies', array(), 'policies', $marketplace->getId(), $account->getId(), NULL); is_null($policies) && ($policies = array()); $this->getActualOperationHistory()->addText('Total received policies from eBay: ' . count($policies)); return $policies; }
private function processAccountMarketplaceInventoryTitle(Ess_M2ePro_Model_Account $accountObj, Ess_M2ePro_Model_Marketplace $marketplaceObj) { $firstSynchronizationTime = $accountObj->getChildObject()->getOtherListingsFirstSynchronization(); if (is_null($firstSynchronizationTime) || strtotime($firstSynchronizationTime) + 3 * 3600 > Mage::helper('M2ePro')->getCurrentGmtDate(true)) { return; } $this->_profiler->addTitle('Starting account "' . $accountObj->getTitle() . '" and marketplace "' . $marketplaceObj->getTitle() . '"'); $this->_profiler->addTimePoint(__METHOD__ . 'send' . $accountObj->getId(), 'Get inventory from Buy'); $tempString = Mage::helper('M2ePro')->__('Task "3rd Party Listings Synchronization" for Rakuten.com account: '); $tempString .= Mage::helper('M2ePro')->__('"%s" and marketplace "%s" is started. Please wait...', $accountObj->getTitle(), Mage::helper('M2ePro')->__($marketplaceObj->getTitle())); $this->_lockItem->setStatus($tempString); $updateByPagesSettings = $accountObj->getChildObject()->getDecodedOtherListingsUpdateTitlesSettings(); if (is_null($updateByPagesSettings) || (int) $updateByPagesSettings['next_status'] <= 2 && (int) $updateByPagesSettings['next_page'] < 10000) { $this->updateInventoryTitlesByPages($accountObj, $marketplaceObj); } else { $this->updateInventoryTitlesBySkus($accountObj, $marketplaceObj); } $this->_profiler->saveTimePoint(__METHOD__ . 'send' . $accountObj->getId()); $this->_profiler->addEol(); }
private function updateAccountMarketplace(Ess_M2ePro_Model_Account $account, Ess_M2ePro_Model_Marketplace $marketplace) { $this->_profiler->addTitle('Starting account "' . $account->getTitle() . '" and marketplace "' . $marketplace->getTitle() . '"'); $this->_profiler->addTimePoint(__METHOD__ . 'send' . $account->getId(), 'Get orders from Amazon'); //->__('Task "%s" for Amazon account: "%s" and marketplace "%s" is started. Please wait...') $status = 'Task "%s" for Amazon account: "%s" and marketplace "%s" is started. Please wait...'; $status = Mage::helper('M2ePro')->__($status, $this->name, $account->getTitle(), $marketplace->getTitle()); $this->_lockItem->setStatus($status); // Get orders from Amazon for account //--------------------------- $fromDate = $this->prepareFromDate($account->getData('orders_last_synchronization')); $params = array('from_date' => $fromDate); if (is_null($account->getData('orders_last_synchronization'))) { $account->setData('orders_last_synchronization', $fromDate)->save(); } $entity = 'tasks'; $type = 'orders'; $name = 'requester'; $prefix = 'Ess_M2ePro_Model_Amazon_Synchronization'; $dispatcherObject = Mage::getModel('M2ePro/Connector_Server_Amazon_Dispatcher'); $dispatcherObject->processConnector($entity, $type, $name, $params, $marketplace, $account, $prefix); //--------------------------- $this->_profiler->saveTimePoint(__METHOD__ . 'send' . $account->getId()); $this->_profiler->addEol(); }
protected function logSuccessfulOperation(Ess_M2ePro_Model_Marketplace $marketplace) { // ->__('The "Specifics" Action for Amazon Marketplace: "%mrk%" has been successfully completed.'); $tempString = Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('The "Specifics" Action for Amazon Marketplace: "%mrk%" has been successfully completed.', array('mrk' => $marketplace->getTitle())); $this->getLog()->addMessage($tempString, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW); }
private function processAccountMarketplace(Ess_M2ePro_Model_Account $account, Ess_M2ePro_Model_Marketplace $marketplace) { $title = 'Starting account "' . $account->getTitle() . '" and marketplace "' . $marketplace->getTitle() . '"'; $this->_profiler->addTitle($title); $this->_profiler->addTimePoint(__METHOD__ . 'send' . $account->getId(), 'Update orders on Buy'); $statusString = 'Task "Orders Update Synchronization" for Rakuten.com "%s" Account and "%s" marketplace '; $statusString .= 'is started. Please wait...'; $status = Mage::helper('M2ePro')->__($statusString, $account->getTitle(), $marketplace->getTitle()); $this->_lockItem->setStatus($status); $changesCollection = Mage::getModel('M2ePro/Order_Change')->getCollection(); $changesCollection->addAccountFilter($account->getId()); $changesCollection->addFieldToFilter('action', Ess_M2ePro_Model_Order_Change::ACTION_UPDATE_SHIPPING); if ($changesCollection->getSize() == 0) { return; } // Update orders shipping status on Rakuten.com //--------------------------- $params = array(); foreach ($changesCollection as $change) { $changeParams = $change->getParams(); $params[] = array('order_id' => $change->getOrderId(), 'buy_order_id' => $changeParams['buy_order_id'], 'buy_order_item_id' => $changeParams['buy_order_item_id'], 'qty' => $changeParams['qty'], 'tracking_type' => $changeParams['tracking_type'], 'tracking_number' => $changeParams['tracking_number'], 'ship_date' => $changeParams['ship_date']); } /** @var $dispatcherObject Ess_M2ePro_Model_Connector_Server_Buy_Dispatcher */ $dispatcherObject = Mage::getModel('M2ePro/Buy_Connector')->getDispatcher(); $dispatcherObject->processConnector('orders', 'update', 'shipping', $params, $marketplace, $account); $changesCollection->walk('delete'); //--------------------------- $this->_profiler->saveTimePoint(__METHOD__ . 'send' . $account->getId()); $this->_profiler->addEol(); }
private function processAccountMarketplace(Ess_M2ePro_Model_Account $account, Ess_M2ePro_Model_Marketplace $marketplace) { $title = 'Starting account "' . $account->getTitle() . '" and marketplace "' . $marketplace->getTitle() . '"'; $this->_profiler->addTitle($title); $this->_profiler->addTimePoint(__METHOD__ . 'send' . $account->getId(), 'Get orders from Buy'); $status = 'Task "%s" for Rakuten.com "%s" Account and "%s" marketplace is started. Please wait...'; $status = Mage::helper('M2ePro')->__($status, $this->name, $account->getTitle(), $marketplace->getTitle()); $this->_lockItem->setStatus($status); // Get open orders from Rakuten.com for account //--------------------------- $entity = 'tasks'; $type = 'orders_receive'; $name = 'requester'; $prefix = 'Ess_M2ePro_Model_Buy_Synchronization'; /** @var $dispatcherObject Ess_M2ePro_Model_Connector_Server_Buy_Dispatcher */ $dispatcherObject = Mage::getModel('M2ePro/Connector_Server_Buy_Dispatcher'); $dispatcherObject->processConnector($entity, $type, $name, array(), $marketplace, $account, $prefix); //--------------------------- $this->_profiler->saveTimePoint(__METHOD__ . 'send' . $account->getId()); $this->_profiler->addEol(); }
private function updateAccountMarketplace(Ess_M2ePro_Model_Account $accountObj, Ess_M2ePro_Model_Marketplace $marketplaceObj) { $this->_profiler->addTitle('Starting account "' . $accountObj->getTitle() . '" and marketplace "' . $marketplaceObj->getTitle() . '"'); $this->_profiler->addTimePoint(__METHOD__ . 'send' . $accountObj->getId(), 'Get inventory from Buy'); $status = 'Task "Update Listings Products" for Rakuten.com account: "%s" and marketplace "%s" '; $status .= 'is started. Please wait...'; $this->_lockItem->setStatus(Mage::helper('M2ePro')->__($status, $accountObj->getTitle(), $marketplaceObj->getTitle())); // Get all changes on Buy for account //--------------------------- $dispatcherObject = Mage::getModel('M2ePro/Connector_Server_Buy_Dispatcher'); $dispatcherObject->processConnector('defaults', 'updateListingsProducts', 'requester', array(), $marketplaceObj, $accountObj, 'Ess_M2ePro_Model_Buy_Synchronization_Tasks'); //--------------------------- $this->_profiler->saveTimePoint(__METHOD__ . 'send' . $accountObj->getId()); $this->_profiler->addEol(); }
private function getListingsProductForUpdate(Ess_M2ePro_Model_Account $accountObj, Ess_M2ePro_Model_Marketplace $marketplaceObj) { $listingTable = Mage::getResourceModel('M2ePro/Listing')->getMainTable(); /** @var $listingsCollection Mage_Core_Model_Mysql4_Collection_Abstract */ $listingsCollection = Mage::helper('M2ePro/Component_Play')->getCollection('Listing_Product'); $listingsCollection->getSelect()->join(array('l' => $listingTable), 'main_table.listing_id = l.id', array()); $listingsCollection->getSelect()->where('l.marketplace_id = ?', $marketplaceObj->getId()); $listingsCollection->getSelect()->where('l.account_id = ?', $accountObj->getId()); $listingsCollection->getSelect()->where('`second_table`.`link_info` IS NULL'); $listingsCollection->getSelect()->where('`second_table`.`play_listing_id` IS NOT NULL'); $listingsCollection->getSelect()->limit(5); return $listingsCollection; }