Ejemplo n.º 1
0
 protected function saveDetailsToDb(Ess_M2ePro_Model_Marketplace $marketplace, array $details)
 {
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $coreResourceModel = Mage::getSingleton('core/resource');
     $tableMarketplaces = $coreResourceModel->getTableName('m2epro_ebay_dictionary_marketplace');
     $tableShipping = $coreResourceModel->getTableName('m2epro_ebay_dictionary_shipping');
     // Save marketplaces
     // ---------------------------------------
     $connWrite->delete($tableMarketplaces, array('marketplace_id = ?' => $marketplace->getId()));
     $insertData = array('marketplace_id' => $marketplace->getId(), 'client_details_last_update_date' => isset($details['last_update']) ? $details['last_update'] : NULL, 'server_details_last_update_date' => isset($details['last_update']) ? $details['last_update'] : NULL, 'dispatch' => json_encode($details['dispatch']), 'packages' => json_encode($details['packages']), 'return_policy' => json_encode($details['return_policy']), 'listing_features' => json_encode($details['listing_features']), 'payments' => json_encode($details['payments']), 'shipping_locations' => json_encode($details['shipping_locations']), 'shipping_locations_exclude' => json_encode($details['shipping_locations_exclude']), 'tax_categories' => json_encode($details['tax_categories']), 'charities' => json_encode($details['charities']));
     if (isset($details['additional_data'])) {
         $insertData['additional_data'] = json_encode($details['additional_data']);
     }
     unset($details['categories_version']);
     $connWrite->insert($tableMarketplaces, $insertData);
     // ---------------------------------------
     // Save shipping
     // ---------------------------------------
     $connWrite->delete($tableShipping, array('marketplace_id = ?' => $marketplace->getId()));
     foreach ($details['shipping'] as $data) {
         $insertData = array('marketplace_id' => $marketplace->getId(), 'ebay_id' => $data['ebay_id'], 'title' => $data['title'], 'category' => json_encode($data['category']), 'is_flat' => $data['is_flat'], 'is_calculated' => $data['is_calculated'], 'is_international' => $data['is_international'], 'data' => json_encode($data['data']));
         $connWrite->insert($tableShipping, $insertData);
     }
     // ---------------------------------------
 }
 protected function saveDetailsToDb(Ess_M2ePro_Model_Marketplace $marketplace, array $details)
 {
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $tableMarketplaces = Mage::getSingleton('core/resource')->getTableName('m2epro_amazon_dictionary_marketplace');
     $connWrite->delete($tableMarketplaces, array('marketplace_id = ?' => $marketplace->getId()));
     $data = array('marketplace_id' => $marketplace->getId(), 'nodes' => json_encode($details));
     $connWrite->insert($tableMarketplaces, $data);
 }
Ejemplo n.º 3
0
 protected function saveDetailsToDb(Ess_M2ePro_Model_Marketplace $marketplace, array $details)
 {
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $tableMarketplaces = Mage::getSingleton('core/resource')->getTableName('m2epro_amazon_dictionary_marketplace');
     $connWrite->delete($tableMarketplaces, array('marketplace_id = ?' => $marketplace->getId()));
     $data = array('marketplace_id' => $marketplace->getId(), 'client_details_last_update_date' => isset($details['last_update']) ? $details['last_update'] : NULL, 'server_details_last_update_date' => isset($details['last_update']) ? $details['last_update'] : NULL, 'product_data' => isset($details['product_data']) ? json_encode($details['product_data']) : NULL, 'vocabulary' => isset($details['vocabulary']) ? json_encode($details['vocabulary']) : NULL);
     $connWrite->insert($tableMarketplaces, $data);
 }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
 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());
 }
Ejemplo n.º 6
0
 protected function saveDetailsToDb(Ess_M2ePro_Model_Marketplace $marketplace, array $details)
 {
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $tableMarketplaces = Mage::getSingleton('core/resource')->getTableName('m2epro_amazon_dictionary_marketplace');
     $tableShippingOverride = Mage::getSingleton('core/resource')->getTableName('m2epro_amazon_dictionary_shipping_override');
     $connWrite->delete($tableMarketplaces, array('marketplace_id = ?' => $marketplace->getId()));
     $data = array('marketplace_id' => $marketplace->getId(), 'client_details_last_update_date' => isset($details['last_update']) ? $details['last_update'] : NULL, 'server_details_last_update_date' => isset($details['last_update']) ? $details['last_update'] : NULL, 'product_data' => isset($details['product_data']) ? json_encode($details['product_data']) : NULL);
     $connWrite->insert($tableMarketplaces, $data);
     Mage::helper('M2ePro/Component_Amazon_Vocabulary')->setServerData($details['vocabulary']);
     $connWrite->delete($tableShippingOverride, array('marketplace_id = ?' => $marketplace->getId()));
     foreach ($details['shipping_overrides'] as $data) {
         $insertData = array('marketplace_id' => $marketplace->getId(), 'location' => $data['location'], 'service' => $data['service'], 'option' => $data['option']);
         $connWrite->insert($tableShippingOverride, $insertData);
     }
 }
Ejemplo n.º 7
0
 public function setLocks($hash)
 {
     /** @var $lockItem Ess_M2ePro_Model_LockItem */
     $lockItem = Mage::getModel('M2ePro/LockItem');
     $tempNick = Ess_M2ePro_Model_Buy_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_buy', $hash);
     $this->account->addObjectLock(Ess_M2ePro_Model_Buy_Synchronization_Tasks_Defaults_UpdateListingsProducts::LOCK_ITEM_PREFIX, $hash);
     $this->marketplace->addObjectLock(NULL, $hash);
     $this->marketplace->addObjectLock('synchronization', $hash);
     $this->marketplace->addObjectLock('synchronization_buy', $hash);
     $this->marketplace->addObjectLock(Ess_M2ePro_Model_Buy_Synchronization_Tasks_Defaults_UpdateListingsProducts::LOCK_ITEM_PREFIX, $hash);
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
 protected function saveCategoriesToDb(Ess_M2ePro_Model_Marketplace $marketplace, array $categories)
 {
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $tableCategories = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_dictionary_category');
     $connWrite->delete($tableCategories, array('marketplace_id = ?' => $marketplace->getId()));
     $iteration = 0;
     $iterationsForOneStep = 1000;
     $percentsForOneStep = $this->getPercentsInterval() / 2 / (count($categories) / $iterationsForOneStep);
     foreach ($categories as $data) {
         $insertData = array('marketplace_id' => $marketplace->getId(), 'category_id' => $data['category_id'], 'title' => $data['title'], 'parent_category_id' => $data['parent_id'], 'level' => $data['level'], 'is_leaf' => $data['is_leaf'], 'features' => json_encode($data['features']), 'attribute_set_id' => $data['attribute_set_id']);
         $connWrite->insert($tableCategories, $insertData);
         if (++$iteration % $iterationsForOneStep == 0) {
             $percentsShift = $iteration / $iterationsForOneStep * $percentsForOneStep;
             $this->getActualLockItem()->setPercents($this->getPercentsStart() + $this->getPercentsInterval() / 2 + $percentsShift);
         }
     }
 }
Ejemplo n.º 11
0
 protected function saveSpecificsToDb(Ess_M2ePro_Model_Marketplace $marketplace, array $specifics)
 {
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $tableSpecifics = Mage::getSingleton('core/resource')->getTableName('m2epro_amazon_dictionary_specific');
     $connWrite->delete($tableSpecifics, array('marketplace_id = ?' => $marketplace->getId()));
     if (!count($specifics)) {
         return;
     }
     $iteration = 0;
     $iterationsForOneStep = 1000;
     $percentsForOneStep = $this->getPercentsInterval() / 2 / (count($specifics) / $iterationsForOneStep);
     foreach ($specifics as $data) {
         $insertData = array('marketplace_id' => $marketplace->getId(), 'specific_id' => $data['id'], 'parent_specific_id' => $data['parent_id'], 'xsd_hash' => $data['xsd_hash'], 'title' => $data['title'], 'xml_tag' => $data['xml_tag'], 'xpath' => $data['xpath'], 'type' => (int) $data['type'], 'values' => $data['values'], 'recommended_values' => $data['recommended_values'], 'params' => $data['params'], 'data_definition' => $data['data_definition'], 'min_occurs' => (int) $data['min_occurs'], 'max_occurs' => (int) $data['max_occurs']);
         $connWrite->insert($tableSpecifics, $insertData);
         if (++$iteration % $iterationsForOneStep == 0) {
             $percentsShift = $iteration / $iterationsForOneStep * $percentsForOneStep;
             $this->getActualLockItem()->setPercents($this->getPercentsStart() + $this->getPercentsInterval() / 2 + $percentsShift);
         }
     }
 }
 protected function receiveFromEbay(Ess_M2ePro_Model_Marketplace $marketplace, $partNumber)
 {
     $dispatcherObj = Mage::getModel('M2ePro/Connector_Ebay_Dispatcher');
     $connectorObj = $dispatcherObj->getVirtualConnector('marketplace', 'get', 'motorsKtypes', array('part_number' => $partNumber), NULL, $marketplace->getId());
     $response = $dispatcherObj->process($connectorObj);
     if (is_null($response) || empty($response['data'])) {
         $response = array();
     }
     $dataCount = isset($response['data']) ? count($response['data']) : 0;
     $this->getActualOperationHistory()->addText("Total received parts from eBay: {$dataCount}");
     return $response;
 }
Ejemplo n.º 13
0
 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));
 }
Ejemplo n.º 14
0
 protected function saveCategoriesToDb(Ess_M2ePro_Model_Marketplace $marketplace, array $categories)
 {
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $tableCategories = Mage::getSingleton('core/resource')->getTableName('m2epro_amazon_dictionary_category');
     $connWrite->delete($tableCategories, array('marketplace_id = ?' => $marketplace->getId()));
     if (!count($categories)) {
         return;
     }
     $iteration = 0;
     $iterationsForOneStep = 1000;
     $percentsForOneStep = $this->getPercentsInterval() / 2 / (count($categories) / $iterationsForOneStep);
     foreach ($categories as $data) {
         $insertData = array('category_id' => $data['id'], 'marketplace_id' => $marketplace->getId(), 'parent_category_id' => $data['parent_id'], 'node_hash' => $data['node_hash'], 'xsd_hash' => $data['xsd_hash'], 'title' => $data['title'], 'path' => $data['path'], 'item_types' => $data['item_types'], 'browsenode_id' => $data['browsenode_id'], 'is_listable' => $data['is_listable'], 'sorder' => $data['sorder']);
         $connWrite->insert($tableCategories, $insertData);
         if (++$iteration % $iterationsForOneStep == 0) {
             $percentsShift = $iteration / $iterationsForOneStep * $percentsForOneStep;
             $this->getActualLockItem()->setPercents($this->getPercentsStart() + $this->getPercentsInterval() / 2 + $percentsShift);
         }
     }
 }
Ejemplo n.º 15
0
 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;
 }
Ejemplo n.º 16
0
 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;
     }
 }
Ejemplo n.º 17
0
 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;
 }
Ejemplo n.º 18
0
 protected function saveSpecificsToDb(Ess_M2ePro_Model_Marketplace $marketplace, array $parts)
 {
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $tableMotorsSpecifics = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_dictionary_motor_specific');
     $iteration = 0;
     $iterationsForOneStep = 1000;
     $totalCountItems = 0;
     foreach ($parts as $part) {
         $totalCountItems += count($part['items']);
     }
     $percentsForOneStep = $this->getPercentsInterval() / 2 / ($totalCountItems / $iterationsForOneStep);
     foreach ($parts as $part) {
         foreach ($part['items'] as $item) {
             $insertData = array('epid' => $item['ePID'], 'marketplace_id' => $marketplace->getId(), 'product_type' => (int) $part['product_type'], 'make' => $item['Make'], 'model' => $item['Model'], 'year' => $item['Year'], 'trim' => isset($item['Trim']) ? $item['Trim'] : NULL, 'engine' => isset($item['Engine']) ? $item['Engine'] : NULL, 'submodel' => isset($item['Submodel']) ? $item['Submodel'] : NULL);
             $connWrite->insert($tableMotorsSpecifics, $insertData);
             if (++$iteration % $iterationsForOneStep == 0) {
                 $percentsShift = $iteration / $iterationsForOneStep * $percentsForOneStep;
                 $this->getActualLockItem()->setPercents($this->getPercentsStart() + $this->getPercentsInterval() / 2 + $percentsShift);
             }
         }
     }
 }
Ejemplo n.º 19
0
 protected function deleteAllCategories(Ess_M2ePro_Model_Marketplace $marketplace)
 {
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $tableCategories = Mage::getSingleton('core/resource')->getTableName('m2epro_amazon_dictionary_category');
     $connWrite->delete($tableCategories, array('marketplace_id = ?' => $marketplace->getId()));
 }
 protected function saveCategoriesToDb(Ess_M2ePro_Model_Marketplace $marketplace, array $categories)
 {
     if (count($categories) <= 0) {
         return;
     }
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $tableCategories = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_dictionary_category');
     $iteration = 0;
     $iterationsForOneStep = 1000;
     $categoriesCount = count($categories);
     $percentsForOneStep = $this->getPercentsInterval() / 2 / ($categoriesCount / $iterationsForOneStep);
     $insertData = array();
     for ($i = 0; $i < $categoriesCount; $i++) {
         $data = $categories[$i];
         $insertData[] = array('marketplace_id' => $marketplace->getId(), 'category_id' => $data['category_id'], 'parent_category_id' => $data['parent_id'], 'title' => $data['title'], 'path' => $data['path'], 'is_leaf' => $data['is_leaf'], 'features' => $data['is_leaf'] ? json_encode($data['features']) : NULL);
         if (count($insertData) >= 100 || $i >= $categoriesCount - 1) {
             $connWrite->insertMultiple($tableCategories, $insertData);
             $insertData = array();
         }
         if (++$iteration % $iterationsForOneStep == 0) {
             $percentsShift = $iteration / $iterationsForOneStep * $percentsForOneStep;
             $this->getActualLockItem()->setPercents($this->getPercentsStart() + $this->getPercentsInterval() / 2 + $percentsShift);
         }
     }
 }
Ejemplo n.º 21
0
 protected function saveSpecificsToDb(Ess_M2ePro_Model_Marketplace $marketplace, array $specifics)
 {
     $totalCountItems = count($specifics);
     if ($totalCountItems <= 0) {
         return;
     }
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $tableSpecifics = Mage::getSingleton('core/resource')->getTableName('m2epro_amazon_dictionary_specific');
     $iteration = 0;
     $iterationsForOneStep = 1000;
     $percentsForOneStep = $this->getPercentsInterval() / 2 / ($totalCountItems / $iterationsForOneStep);
     $insertData = array();
     for ($i = 0; $i < $totalCountItems; $i++) {
         $data = $specifics[$i];
         $insertData[] = array('marketplace_id' => $marketplace->getId(), 'specific_id' => $data['id'], 'parent_specific_id' => $data['parent_id'], 'product_data_nick' => $data['product_data_nick'], 'title' => $data['title'], 'xml_tag' => $data['xml_tag'], 'xpath' => $data['xpath'], 'type' => (int) $data['type'], 'values' => json_encode($data['values']), 'recommended_values' => json_encode($data['recommended_values']), 'params' => json_encode($data['params']), 'data_definition' => json_encode($data['data_definition']), 'min_occurs' => (int) $data['min_occurs'], 'max_occurs' => (int) $data['max_occurs']);
         if (count($insertData) >= 100 || $i >= $totalCountItems - 1) {
             $connWrite->insertMultiple($tableSpecifics, $insertData);
             $insertData = array();
         }
         if (++$iteration % $iterationsForOneStep == 0) {
             $percentsShift = $iteration / $iterationsForOneStep * $percentsForOneStep;
             $this->getActualLockItem()->setPercents($this->getPercentsStart() + $this->getPercentsInterval() / 2 + $percentsShift);
         }
     }
 }
Ejemplo n.º 22
0
 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;
 }
Ejemplo n.º 23
0
 protected function saveKtypesToDb(Ess_M2ePro_Model_Marketplace $marketplace, array $data)
 {
     /** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
     $tableMotorsKtype = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_dictionary_motor_ktype');
     $iteration = 0;
     $iterationsForOneStep = 1000;
     $totalCountItems = count($data['items']);
     $percentsForOneStep = $this->getPercentsInterval() / 2 / ($totalCountItems / $iterationsForOneStep);
     $itemsForInsert = array();
     for ($i = 0; $i < $totalCountItems; $i++) {
         $item = $data['items'][$i];
         $itemsForInsert[] = array('marketplace_id' => $marketplace->getId(), 'ktype' => (int) $item['ktype'], 'make' => $item['make'], 'model' => $item['model'], 'variant' => $item['variant'], 'body_style' => $item['body_style'], 'type' => $item['type'], 'from_year' => (int) $item['from_year'], 'to_year' => (int) $item['to_year'], 'engine' => $item['engine']);
         if (count($itemsForInsert) >= 100 || $i >= $totalCountItems - 1) {
             $connWrite->insertMultiple($tableMotorsKtype, $itemsForInsert);
             $itemsForInsert = array();
         }
         if (++$iteration % $iterationsForOneStep == 0) {
             $percentsShift = $iteration / $iterationsForOneStep * $percentsForOneStep;
             $this->getActualLockItem()->setPercents($this->getPercentsStart() + $this->getPercentsInterval() / 2 + $percentsShift);
         }
     }
 }