OpenCart 🇺🇦

Схема

public mixed create ( )

Аргументы

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

Описание

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

Исходный код

if ($this->checkConfig() == true) {
	if (!empty($this->request->get['product_id'])) {
		//load the language
		$this->data = array_merge($this->data, $this->load->language('openbay/ebay_new'));

		//load the models
		$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_template');
		$this->load->model('openbay/ebay_product');
		$this->load->model('openbay/ebay_profile');

		//set the title and page info
		$this->document->setTitle($this->data['lang_page_title']);
		$this->document->addStyle('view/stylesheet/openbay.css');
		$this->document->addScript('view/javascript/openbay/faq.js');

		$this->template         = 'openbay/ebay_new.tpl';
		$this->children         = array('common/header','common/footer');
		$this->data['action']   = $this->url->link('openbay/openbay/create', 'token=' . $this->session->data['token'], 'SSL');
		$this->data['cancel']   = $this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'], 'SSL');
		$this->data['token']    = $this->session->data['token'];
		$product_info           = $this->model_catalog_product->getProduct($this->request->get['product_id']);

		//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;

		if ($this->openbay->addonLoad('openstock') && $product_info['has_option'] == 1) {
			$this->load->model('openstock/openstock');
			$this->data['addon']['openstock'] = true;
			$product_info['options'] = $this->model_openstock_openstock->getProductOptionStocks($this->request->get['product_id']);
			$product_info['option_grp'] = $this->model_openbay_ebay_product->getProductOptions($this->request->get['product_id']);
		}

		// get the product tax rate from opencart
		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;
		}

		//get the popular categories the user has used
		$product_info['popular_cats'] = $this->model_openbay_ebay->getPopularCategories();

		//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);

		//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);
		$this->data['data']['shipping_international_zones']     = $this->model_openbay_ebay->getShippingLocations();

		//get theme 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);

		//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);

		//product attributes - this is just a direct pass through used with the template tag
		$product_info['attributes'] = base64_encode(json_encode($this->model_openbay_ebay->getProductAttributes($this->request->get['product_id'])));

		//post edit link
		$product_info['edit_link'] = $this->url->link('openbay/openbay/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $this->request->get['product_id'], 'SSL');

		//images
		$product_images = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
		$product_info['product_images'] = array();

		if (!empty($product_info['image'])) {
			$product_info['product_images'][] = array(
				'image' => $product_info['image'],
				'preview' => $this->model_tool_image->resize($product_info['image'], 100, 100),
				'full' => HTTPS_CATALOG . 'image/' . $product_info['image']
			);
		}

		foreach ($product_images as $product_image) {
			if ($product_image['image'] && file_exists(DIR_IMAGE . $product_image['image'])) {
				$image = $product_image['image'];
			} else {
				$image = 'no_image.jpg';
			}

			$product_info['product_images'][] = array(
				'image' => $image,
				'preview' => $this->model_tool_image->resize($image, 100, 100),
				'full' => HTTPS_CATALOG . 'image/' . $image
			);
		}

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

		$product_info['defaults']['ebay_payment_types']     = $this->config->get('ebay_payment_types');
		$product_info['defaults']['paypal_address']         = $this->config->get('field_payment_paypal_address');
		$product_info['defaults']['payment_instruction']    = $this->config->get('field_payment_instruction');
		$product_info['defaults']['payment_immediate']      = $this->config->get('payment_immediate');

		$product_info['defaults']['gallery_height']         = '400';
		$product_info['defaults']['gallery_width']          = '400';
		$product_info['defaults']['thumb_height']           = '100';
		$product_info['defaults']['thumb_width']            = '100';


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

		if (isset($this->error['warning'])) {
			$this->data['error_warning'] = $this->error['warning'];
		} else {
			$this->data['error_warning'] = '';
		}

		if($product_info['quantity'] < 1 && (!isset($product_info['has_option']) || $product_info['has_option'] == 0)) {
			$this->data['error_warning'] = $this->language->get('lang_error_no_stock');
		}

		$this->data['no_image'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);

		$this->data['product'] = $product_info;

		$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']));
	}
}