示例#1
0
 protected function getResponserParams()
 {
     $params = parent::getResponserParams();
     if (!is_null($this->marketplace)) {
         $params['marketplace_id'] = $this->marketplace->getId();
     }
     if (!is_null($this->account)) {
         $params['account_id'] = $this->account->getId();
     }
     return $params;
 }
示例#2
0
 protected function saveDetailsToDb(\Ess\M2ePro\Model\Marketplace $marketplace, array $details)
 {
     $connection = $this->resourceConnection->getConnection();
     $tableMarketplaces = $this->resourceConnection->getTableName('m2epro_amazon_dictionary_marketplace');
     $tableShippingOverride = $this->resourceConnection->getTableName('m2epro_amazon_dictionary_shipping_override');
     $connection->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);
     $connection->insert($tableMarketplaces, $data);
     $this->getHelper('Component\\Amazon\\Vocabulary')->setServerData($details['vocabulary']);
     $connection->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']);
         $connection->insert($tableShippingOverride, $insertData);
     }
 }
 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);
 }
示例#4
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 = $this->getHelper('Module')->getConfig()->getGroupValue($group, 'use_first_street_line_as_company');
     if ($useFirstStreetLineAsCompany && count($parsedAddress['street']) > 1) {
         $parsedAddress['company'] = array_shift($parsedAddress['street']);
     }
     return $parsedAddress;
 }
示例#5
0
 protected function receiveFromEbay(\Ess\M2ePro\Model\Marketplace $marketplace, $partNumber)
 {
     $dispatcherObj = $this->modelFactory->getObject('Ebay\\Connector\\Dispatcher');
     $connectorObj = $dispatcherObj->getVirtualConnector('marketplace', 'get', 'motorsKtypes', array('part_number' => $partNumber), NULL, $marketplace->getId());
     $dispatcherObj->process($connectorObj);
     $response = $connectorObj->getResponseData();
     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;
 }
示例#6
0
 protected function saveDetailsToDb(\Ess\M2ePro\Model\Marketplace $marketplace, array $details)
 {
     $connWrite = $this->resourceConnection->getConnection();
     $tableMarketplaces = $this->resourceConnection->getTableName('m2epro_ebay_dictionary_marketplace');
     $tableShipping = $this->resourceConnection->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);
     }
     // ---------------------------------------
 }
示例#7
0
 protected function saveSpecificsToDb(\Ess\M2ePro\Model\Marketplace $marketplace, array $specifics)
 {
     $totalCountItems = count($specifics);
     if ($totalCountItems <= 0) {
         return;
     }
     $connWrite = $this->resourceConnection->getConnection();
     $tableSpecifics = $this->resourceConnection->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);
         }
     }
 }
示例#8
0
 public function setMarketplaceFilter(\Ess\M2ePro\Model\Marketplace $marketplace)
 {
     $this->joinActionData();
     $this->addFieldToFilter('mapa.marketplace_id', (int) $marketplace->getId());
     return $this;
 }
示例#9
0
 protected function saveCategoriesToDb(\Ess\M2ePro\Model\Marketplace $marketplace, array $categories)
 {
     if (count($categories) <= 0) {
         return;
     }
     $connWrite = $this->resourceConnection->getConnection();
     $tableCategories = $this->resourceConnection->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);
         }
     }
 }
示例#10
0
 function __construct(\Ess\M2ePro\Model\Marketplace $marketplace, \Ess\M2ePro\Model\Account $account, \Ess\M2ePro\Helper\Factory $helperFactory, \Ess\M2ePro\Model\Factory $modelFactory, array $params)
 {
     $this->marketplace = !is_null($marketplace->getId()) ? $marketplace : NULL;
     $this->account = !is_null($account->getId()) ? $account : NULL;
     parent::__construct($helperFactory, $modelFactory, $params);
 }
示例#11
0
 protected function saveCategoriesToDb(\Ess\M2ePro\Model\Marketplace $marketplace, array $categories)
 {
     $totalCountCategories = count($categories);
     if ($totalCountCategories <= 0) {
         return;
     }
     $connWrite = $this->resourceConnection->getConnection();
     $tableCategories = $this->resourceConnection->getTableName('m2epro_amazon_dictionary_category');
     $iteration = 0;
     $iterationsForOneStep = 1000;
     $percentsForOneStep = $this->getPercentsInterval() / 2 / ($totalCountCategories / $iterationsForOneStep);
     $insertData = array();
     for ($i = 0; $i < $totalCountCategories; $i++) {
         $data = $categories[$i];
         $isLeaf = $data['is_leaf'];
         $insertData[] = array('marketplace_id' => $marketplace->getId(), 'category_id' => $data['id'], 'parent_category_id' => $data['parent_id'], 'browsenode_id' => $isLeaf ? $data['browsenode_id'] : NULL, 'product_data_nicks' => $isLeaf ? json_encode($data['product_data_nicks']) : NULL, 'title' => $data['title'], 'path' => $data['path'], 'keywords' => $isLeaf ? json_encode($data['keywords']) : NULL, 'is_leaf' => $isLeaf);
         if (count($insertData) >= 100 || $i >= $totalCountCategories - 1) {
             $connWrite->insertMultiple($tableCategories, $insertData);
             $insertData = array();
         }
         if (++$iteration % $iterationsForOneStep == 0) {
             $percentsShift = $iteration / $iterationsForOneStep * $percentsForOneStep;
             $this->getActualLockItem()->setPercents($this->getPercentsStart() + $this->getPercentsInterval() / 2 + $percentsShift);
         }
     }
 }