OpenCart 🇺🇦

Схема

public mixed createBulk ( )

Аргументы

Аргумент Возможный тип Описание
У метода нет аргументов

Описание

Метод пока еще не документирован.

Исходный код

if ($this->checkConfig() == true) {
	if(!empty($this->request->post['selected'])) {
		$this->data = array_merge($this->data, $this->load->language('openbay/ebay_newbulk'));

		$this->load->model('catalog/product');
		$this->load->model('tool/image');
		$this->load->model('catalog/manufacturer');
		$this->load->model('openbay/ebay');
		$this->load->model('openbay/ebay_profile');

		$this->data['error_warning'] = array();

		$activeList = $this->model_openbay_ebay->getLiveListingArray();

		$products = array();

		if ($this->openbay->addonLoad('openstock')) {
			$openstock = 1;
		}else{
			$openstock = 0;
		}

		foreach ($this->request->post['selected'] as $product_id) {
			if(!array_key_exists($product_id, $activeList)) {

				$prod = $this->model_catalog_product->getProduct($product_id);

				if($openstock == 1 && isset($prod['has_option']) && $prod['has_option'] == 1) {
					$this->data['error_warning']['os'] = $this->language->get('lang_error_variants');
				}else{
					if($prod['quantity'] > 0) {
						if ($prod['image'] && file_exists(DIR_IMAGE . $prod['image'])) {
							$prod['image'] = $this->model_tool_image->resize($prod['image'], 80, 80);
						} else {
							$prod['image'] = $this->model_tool_image->resize('no_image.jpg', 80, 80);
						}

						$products[] = $prod;
					}else{
						$this->data['error_warning']['stock'] = $this->language->get('lang_error_stock');
					}
				}
			}else{
				$this->data['error_warning']['exists'] = $this->language->get('lang_exists');
			}
		}

		$this->data['count'] = count($products);
		$this->data['token'] = $this->session->data['token'];
		$this->data['listing_link'] = $this->config->get('openbaypro_ebay_itm_link');

		$plan = $this->model_openbay_ebay->getMyPlan();

		if($plan['plan']['listing_bulk'] == 1) {
			if($this->data['count'] == 0) {
				$this->data['error_fail'][] = $this->language->get('lang_error_no_product');
			}else{
				if(($plan['plan']['listing_limit'] == 0) || (($plan['usage']['items'] + $this->data['count']) <= $plan['plan']['listing_limit'])) {
					if($this->data['count'] > 5) {
						$this->data['error_warning']['count'] = sprintf($this->language->get('lang_error_count'), $this->data['count']);
					}

					//load the settings from eBay
					$setting = array();

					$setting['dispatch_times'] = $this->openbay->ebay->getSetting('dispatch_time_max');
					if(is_array($setting['dispatch_times'])) { ksort($setting['dispatch_times']); }

					$setting['countries'] = $this->openbay->ebay->getSetting('countries');
					if(is_array($setting['countries'])) { ksort($setting['countries']); }

					$setting['returns'] = $this->openbay->ebay->getSetting('returns');

					if(empty($setting['dispatch_times']) || empty($setting['countries']) || empty($setting['returns'])){
						$this->session->data['warning'] = $this->language->get('lang_error_missing_settings');
						$this->redirect($this->url->link('openbay/openbay/viewSync&token=' . $this->session->data['token'], 'SSL'));
					}

					$this->data['setting'] = $setting;

					//get generic profiles
					$product_info['profiles_generic'] = $this->model_openbay_ebay_profile->getAll(3);
					//get default generic profile
					$product_info['profiles_generic_def'] = $this->model_openbay_ebay_profile->getDefault(3);
					if($product_info['profiles_generic_def'] === false) {
						$this->data['error_fail'][] = $this->language->get('lang_error_generic_profile');
					}

					//get shipping profiles
					$product_info['profiles_shipping'] = $this->model_openbay_ebay_profile->getAll(0);
					//get default shipping profile
					$product_info['profiles_shipping_def'] = $this->model_openbay_ebay_profile->getDefault(0);
					//check it has a default profile
					if($product_info['profiles_shipping_def'] === false) {
						$this->data['error_fail'][] = $this->language->get('lang_error_ship_profile');
					}

					//get returns profiles
					$product_info['profiles_returns'] = $this->model_openbay_ebay_profile->getAll(1);
					//get default returns profile
					$product_info['profiles_returns_def'] = $this->model_openbay_ebay_profile->getDefault(1);
					//check it has a default profile
					if($product_info['profiles_returns_def'] === false) {
						$this->data['error_fail'][] = $this->language->get('lang_error_return_profile');
					}

					//get returns profiles
					$product_info['profiles_theme'] = $this->model_openbay_ebay_profile->getAll(2);
					//get default returns profile
					$product_info['profiles_theme_def'] = $this->model_openbay_ebay_profile->getDefault(2);
					//check it has a default profile
					if($product_info['profiles_theme_def'] === false) {
						$this->data['error_fail'][] = $this->language->get('lang_error_theme_profile');
					}

					// get the product tax rate
					if (isset($product_info['tax_class_id'])) {
						$product_info['defaults']['tax'] = $this->model_openbay_ebay_product->getTaxRate($product_info['tax_class_id']);
					} else {
						$product_info['defaults']['tax'] = 0.00;
					}

					$this->data['products'] = $products;

					$product_info['manufacturers']  = $this->model_catalog_manufacturer->getManufacturers();
					$product_info['payments']       = $this->model_openbay_ebay->getPaymentTypes();
					$product_info['store_cats']     = $this->model_openbay_ebay->getSellerStoreCategories();

					$product_info['defaults']['ebay_template'] = $this->config->get('ebay_template');

					$product_info['defaults']['listing_duration'] = $this->config->get('openbaypro_duration');
					if ($product_info['defaults']['listing_duration'] == '') {
						$product_info['defaults']['listing_duration'] = 'Days_30';
					}

					$this->data['default'] = $product_info;
				}else{
					$this->data['error_fail']['plan'] = sprintf($this->language->get('lang_item_limit'), $this->url->link('openbay/openbay/viewSubscription', 'token=' . $this->session->data['token'], 'SSL'));
				}
			}
		}else{
			$this->data['error_fail']['plan'] = sprintf($this->language->get('lang_bulk_plan_error'), $this->url->link('openbay/openbay/viewSubscription', 'token=' . $this->session->data['token'], 'SSL'));
		}

		$this->document->setTitle($this->data['lang_page_title']);
		$this->document->addStyle('view/stylesheet/openbay.css');
		$this->document->addScript('view/javascript/openbay/faq.js');
		$this->document->addScript('view/javascript/openbay/openbay.js');
		$this->template = 'openbay/ebay_new_bulk.tpl';

		$this->children = array(
			'common/header',
			'common/footer'
		);
		$this->response->setOutput($this->render(true), $this->config->get('config_compression'));
	}else{
		$this->redirect($this->url->link('extension/openbay/itemList&token=' . $this->session->data['token']));
	}
}