OpenCart 🇺🇦

Схема

public mixed itemList ( )

Аргументы

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

Описание

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

Исходный код

$this->document->addScript('view/javascript/openbay/openbay.js');
$this->document->addScript('view/javascript/openbay/faq.js');
$this->document->addStyle('view/stylesheet/openbay.css');

$this->data = array_merge($this->data, $this->load->language('catalog/product'));
$this->data = array_merge($this->data, $this->load->language('extension/default'));
$this->data = array_merge($this->data, $this->load->language('openbay/openbay_itemlist'));

$this->document->setTitle($this->language->get('heading_title'));

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

if ($this->openbay->addonLoad('openstock')) {
	$this->load->model('openstock/openstock');
	$openstock_installed = true;
} else {
	$openstock_installed = false;
}

$this->data['category_list'] = $this->model_catalog_category->getCategories(array());
$this->data['manufacturer_list'] = $this->model_catalog_manufacturer->getManufacturers(array());

if (isset($this->request->get['filter_name'])) {
	$filter_name = $this->request->get['filter_name'];
} else {
	$filter_name = null;
}

if (isset($this->request->get['filter_model'])) {
	$filter_model = $this->request->get['filter_model'];
} else {
	$filter_model = null;
}

if (isset($this->request->get['filter_price'])) {
	$filter_price = $this->request->get['filter_price'];
} else {
	$filter_price = null;
}

if (isset($this->request->get['filter_price_to'])) {
	$filter_price_to = $this->request->get['filter_price_to'];
} else {
	$filter_price_to = null;
}

if (isset($this->request->get['filter_quantity'])) {
	$filter_quantity = $this->request->get['filter_quantity'];
} else {
	$filter_quantity = null;
}

if (isset($this->request->get['filter_quantity_to'])) {
	$filter_quantity_to = $this->request->get['filter_quantity_to'];
} else {
	$filter_quantity_to = null;
}

if (isset($this->request->get['filter_status'])) {
	$filter_status = $this->request->get['filter_status'];
} else {
	$filter_status = null;
}

if (isset($this->request->get['filter_sku'])) {
	$filter_sku = $this->request->get['filter_sku'];
} else {
	$filter_sku = null;
}

if (isset($this->request->get['filter_desc'])) {
	$filter_desc = $this->request->get['filter_desc'];
} else {
	$filter_desc = null;
}

if (isset($this->request->get['filter_category'])) {
	$filter_category = $this->request->get['filter_category'];
} else {
	$filter_category = null;
}

if (isset($this->request->get['filter_manufacturer'])) {
	$filter_manufacturer = $this->request->get['filter_manufacturer'];
} else {
	$filter_manufacturer = null;
}

if (isset($this->request->get['filter_marketplace'])) {
	$filter_marketplace = $this->request->get['filter_marketplace'];
} else {
	$filter_marketplace = null;
}

if (isset($this->request->get['sort'])) {
	$sort = $this->request->get['sort'];
} else {
	$sort = 'pd.name';
}

if (isset($this->request->get['order'])) {
	$order = $this->request->get['order'];
} else {
	$order = 'ASC';
}

if (isset($this->request->get['page'])) {
	$page = $this->request->get['page'];
} else {
	$page = 1;
}

$url = '';

if (isset($this->request->get['filter_name'])) {
	$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_model'])) {
	$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_price'])) {
	$url .= '&filter_price=' . $this->request->get['filter_price'];
}

if (isset($this->request->get['filter_price_to'])) {
	$url .= '&filter_price_to=' . $this->request->get['filter_price_to'];
}

if (isset($this->request->get['filter_quantity'])) {
	$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}

if (isset($this->request->get['filter_quantity_to'])) {
	$url .= '&filter_quantity_to=' . $this->request->get['filter_quantity_to'];
}

if (isset($this->request->get['filter_status'])) {
	$url .= '&filter_status=' . $this->request->get['filter_status'];
}

if (isset($this->request->get['filter_sku'])) {
	$url .= '&filter_sku=' . $this->request->get['filter_sku'];
}

if (isset($this->request->get['filter_desc'])) {
	$url .= '&filter_desc=' . $this->request->get['filter_desc'];
}

if (isset($this->request->get['filter_category'])) {
	$url .= '&filter_category=' . $this->request->get['filter_category'];
}

if (isset($this->request->get['filter_manufacturer'])) {
	$url .= '&filter_manufacturer=' . $this->request->get['filter_manufacturer'];
}

if (isset($this->request->get['filter_marketplace'])) {
	$url .= '&filter_marketplace=' . $this->request->get['filter_marketplace'];
}

if (isset($this->request->get['sort'])) {
	$url .= '&sort=' . $this->request->get['sort'];
}

if (isset($this->request->get['order'])) {
	$url .= '&order=' . $this->request->get['order'];
}

if (isset($this->request->get['page'])) {
	$url .= '&page=' . $this->request->get['page'];
}

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

$this->data['breadcrumbs'][] = array(
	'text'      => $this->language->get('text_home'),
	'href'      => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
	'separator' => false
);

$this->data['breadcrumbs'][] = array(
	'text'      => $this->language->get('heading_title'),
	'href'      => $this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'] . $url, 'SSL'),
	'separator' => ' :: '
);

if ($this->config->get('amazon_status')) {
	$this->data['href_amazon_bulk_list'] = $this->url->link('openbay/amazon/bulkListProducts', 'token=' . $this->session->data['token'] . $url, 'SSL');
} else {
	$this->data['href_amazon_bulk_list'] = '';
}

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

$filter_market_id = '';
$filter_market_name = '';

$ebay_status = array(
	0 => 'ebay_inactive',
	1 => 'ebay_active',
);

if(in_array($filter_marketplace, $ebay_status)){
	$filter_market_name = 'ebay';
	$filter_market_id = array_search($filter_marketplace, $ebay_status);
}

$amazon_status = array(
	0 => 'amazon_unlisted',
	1 => 'amazon_saved',
	2 => 'amazon_uploaded',
	3 => 'amazon_ok',
	4 => 'amazon_error',
	5 => 'amazon_linked',
	6 => 'amazon_not_linked',
);

if(in_array($filter_marketplace, $amazon_status)){
	$filter_market_name = 'amazon';
	$filter_market_id = array_search($filter_marketplace, $amazon_status);
}

$amazonus_status = array(
	0 => 'amazonus_unlisted',
	1 => 'amazonus_saved',
	2 => 'amazonus_uploaded',
	3 => 'amazonus_ok',
	4 => 'amazonus_error',
	5 => 'amazonus_linked',
	6 => 'amazonus_not_linked',
);

if(in_array($filter_marketplace, $amazonus_status)){
	$filter_market_name = 'amazonus';
	$filter_market_id = array_search($filter_marketplace, $amazonus_status);
}

$data = array(
	'filter_name'	        => $filter_name,
	'filter_model'	        => $filter_model,
	'filter_price'	        => $filter_price,
	'filter_price_to'	    => $filter_price_to,
	'filter_quantity'       => $filter_quantity,
	'filter_quantity_to'    => $filter_quantity_to,
	'filter_status'         => $filter_status,
	'filter_sku'            => $filter_sku,
	'filter_desc'           => $filter_desc,
	'filter_category'       => $filter_category,
	'filter_manufacturer'   => $filter_manufacturer,
	'filter_market_name'    => $filter_market_name,
	'filter_market_id'      => $filter_market_id,
	'sort'                  => $sort,
	'order'                 => $order,
	'start'                 => ($page - 1) * $this->config->get('config_admin_limit'),
	'limit'                 => $this->config->get('config_admin_limit')
);

if($this->config->get('openbay_status') != '1' && $data['filter_market_name'] == 'ebay') {
	$this->redirect($this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'], 'SSL'));
	return;
}

if($this->config->get('amazon_status') != '1' && $data['filter_market_name'] == 'amazon') {
	$this->redirect($this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'], 'SSL'));
	return;
}

if($this->config->get('amazonus_status') != '1' && $data['filter_market_name'] == 'amazonus') {
	$this->redirect($this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'], 'SSL'));
	return;
}

$this->data['marketplace_statuses'] = array(
	'ebay' => $this->config->get('openbay_status'),
	'amazon' => $this->config->get('amazon_status'),
	'amazonus' => $this->config->get('amazonus_status'),
);

$product_total = $this->model_openbay_openbay->getTotalProducts($data);

$results = $this->model_openbay_openbay->getProducts($data);

foreach ($results as $result) {
	$edit = $this->url->link('catalog/product/update', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL');

	if ($result['image'] && file_exists(DIR_IMAGE . $result['image'])) {
		$image = $this->model_tool_image->resize($result['image'], 40, 40);
	} else {
		$image = $this->model_tool_image->resize('no_image.jpg', 40, 40);
	}

	$special = false;

	$product_specials = $this->model_catalog_product->getProductSpecials($result['product_id']);

	foreach ($product_specials  as $product_special) {
		if (($product_special['date_start'] == '0000-00-00' || $product_special['date_start'] < date('Y-m-d')) && ($product_special['date_end'] == '0000-00-00' || $product_special['date_end'] > date('Y-m-d'))) {
			$special = $product_special['price'];

			break;
		}
	}

	$markets = array();

	if ($this->config->get('openbay_status') == '1') {
		$this->load->model('openbay/ebay');

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

		if(!array_key_exists($result['product_id'], $activeList)) {
			$markets[] = array(
				'name'      => 'eBay',
				'img'       => HTTPS_SERVER.'view/image/openbay/ebay_nolink.png',
				'text'      => $this->language->get('lang_openbay_new'),
				'href'      => $this->url->link('openbay/openbay/create', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL'),
			);
		} else {
			$markets[] = array(
				'name'      => 'eBay',
				'img'       => HTTPS_SERVER.'view/image/openbay/ebay_ok.png',
				'text'      => $this->language->get('lang_openbay_edit'),
				'href'      => $this->url->link('openbay/openbay/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL'),
			);
		}
	}

	if ($this->config->get('amazon_status') == '1') {
		$this->load->model('openbay/amazon');
		$amazon_status = $this->model_openbay_amazon->getProductStatus($result['product_id']);

		if($amazon_status == 'processing') {
			$markets[] = array(
				'name'      => 'Amazon EU',
				'img'       => HTTPS_SERVER.'view/image/openbay/amazon_pending.png',
				'text'      => $this->language->get('lang_openbay_processing'),
				'href'      => '',
			);
		} else if ($amazon_status == 'linked' || $amazon_status == 'ok' || $amazon_status == 'saved') {
			$markets[] = array(
				'name'      => 'Amazon EU',
				'img'       => HTTPS_SERVER.'view/image/openbay/amazon_ok.png',
				'text'      => $this->language->get('lang_openbay_edit'),
				'href'      => $this->url->link('openbay/amazon_listing/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL'),
			);
		} else if ($amazon_status == 'error_quick' || $amazon_status == 'error_advanced' || $amazon_status == 'error_few') {
			$markets[] = array(
				'name'      => 'Amazon EU',
				'img'       => HTTPS_SERVER.'view/image/openbay/amazon_error.png',
				'text'      => $this->language->get('lang_openbay_fix'),
				'href'      => $this->url->link('openbay/amazon_listing/create', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL'),
			);
		} else {
			$markets[] = array(
				'name'      => 'Amazon EU',
				'img'       => HTTPS_SERVER.'view/image/openbay/amazon_nolink.png',
				'text'      => $this->language->get('lang_openbay_new'),
				'href'      => $this->url->link('openbay/amazon_listing/create', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL'),
			);
		}
	}

	if ($this->config->get('amazonus_status') == '1') {
		$this->load->model('openbay/amazonus');
		$amazonus_status = $this->model_openbay_amazonus->getProductStatus($result['product_id']);

		if($amazonus_status == 'processing') {
			$markets[] = array(
				'name'      => 'Amazon US',
				'img'       => HTTPS_SERVER.'view/image/openbay/amazon_pending.png',
				'text'      => $this->language->get('lang_openbay_processing'),
				'href'      => '',
			);
		} else if ($amazonus_status == 'linked' || $amazonus_status == 'ok' || $amazonus_status == 'saved') {
			$markets[] = array(
				'name'      => 'Amazon US',
				'img'       => HTTPS_SERVER.'view/image/openbay/amazon_ok.png',
				'text'      => $this->language->get('lang_openbay_edit'),
				'href'      => $this->url->link('openbay/amazonus_listing/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL'),
			);
		} else if ($amazonus_status == 'error_quick' || $amazonus_status == 'error_advanced' || $amazonus_status == 'error_few') {
			$markets[] = array(
				'name'      => 'Amazon US',
				'img'       => HTTPS_SERVER.'view/image/openbay/amazon_error.png',
				'text'      => $this->language->get('lang_openbay_fix'),
				'href'      => $this->url->link('openbay/amazonus_listing/create', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL'),
			);
		} else {
			$markets[] = array(
				'name'      => 'Amazon US',
				'img'       => HTTPS_SERVER.'view/image/openbay/amazon_nolink.png',
				'text'      => $this->language->get('lang_openbay_new'),
				'href'      => $this->url->link('openbay/amazonus_listing/create', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL'),
			);
		}
	}

	if(!isset($result['has_option'])) {
		$result['has_option'] = 0;
	}

	$this->data['products'][] = array(
		'markets'   => $markets,
		'product_id' => $result['product_id'],
		'name'       => $result['name'],
		'model'      => $result['model'],
		'price'      => $result['price'],
		'special'    => $special,
		'image'      => $image,
		'quantity'   => $result['quantity'],
		'status'     => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
		'selected'   => isset($this->request->post['selected']) && in_array($result['product_id'], $this->request->post['selected']),
		'edit'       => $edit,
		'has_option' => $openstock_installed ? $result['has_option'] : 0,
		'vCount'     => $openstock_installed ? $this->model_openstock_openstock->countVariation($result['product_id']) : '',
		'vsCount'    => $openstock_installed ? $this->model_openstock_openstock->countVariationStock($result['product_id']) : '',
	);
}

$this->data['token'] = $this->session->data['token'];

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

if (isset($this->session->data['success'])) {
	$this->data['success'] = $this->session->data['success'];

	unset($this->session->data['success']);
} else {
	$this->data['success'] = '';
}

$url = '';

if (isset($this->request->get['filter_name'])) {
	$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_model'])) {
	$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_price'])) {
	$url .= '&filter_price=' . $this->request->get['filter_price'];
}

if (isset($this->request->get['filter_price_to'])) {
	$url .= '&filter_price_to=' . $this->request->get['filter_price_to'];
}

if (isset($this->request->get['filter_quantity'])) {
	$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}

if (isset($this->request->get['filter_quantity_to'])) {
	$url .= '&filter_quantity_to=' . $this->request->get['filter_quantity_to'];
}

if (isset($this->request->get['filter_status'])) {
	$url .= '&filter_status=' . $this->request->get['filter_status'];
}

if (isset($this->request->get['filter_sku'])) {
	$url .= '&filter_sku=' . $this->request->get['filter_sku'];
}

if (isset($this->request->get['filter_desc'])) {
	$url .= '&filter_desc=' . $this->request->get['filter_desc'];
}

if (isset($this->request->get['filter_category'])) {
	$url .= '&filter_category=' . $this->request->get['filter_category'];
}

if (isset($this->request->get['filter_manufacturer'])) {
	$url .= '&filter_manufacturer=' . $this->request->get['filter_manufacturer'];
}

if (isset($this->request->get['filter_marketplace'])) {
	$url .= '&filter_marketplace=' . $this->request->get['filter_marketplace'];
}

if ($order == 'ASC') {
	$url .= '&order=DESC';
} else {
	$url .= '&order=ASC';
}

if (isset($this->request->get['page'])) {
	$url .= '&page=' . $this->request->get['page'];
}

$this->data['sort_name'] = $this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'] . '&sort=pd.name' . $url, 'SSL');
$this->data['sort_model'] = $this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'] . '&sort=p.model' . $url, 'SSL');
$this->data['sort_price'] = $this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'] . '&sort=p.price' . $url, 'SSL');
$this->data['sort_quantity'] = $this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'] . '&sort=p.quantity' . $url, 'SSL');
$this->data['sort_status'] = $this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'] . '&sort=p.status' . $url, 'SSL');
$this->data['sort_order'] = $this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'] . '&sort=p.sort_order' . $url, 'SSL');

$url = '';

if (isset($this->request->get['filter_name'])) {
	$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_model'])) {
	$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_price'])) {
	$url .= '&filter_price=' . $this->request->get['filter_price'];
}

if (isset($this->request->get['filter_price_to'])) {
	$url .= '&filter_price_to=' . $this->request->get['filter_price_to'];
}

if (isset($this->request->get['filter_quantity'])) {
	$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}

if (isset($this->request->get['filter_quantity_to'])) {
	$url .= '&filter_quantity_to=' . $this->request->get['filter_quantity_to'];
}

if (isset($this->request->get['filter_status'])) {
	$url .= '&filter_status=' . $this->request->get['filter_status'];
}

if (isset($this->request->get['filter_sku'])) {
	$url .= '&filter_sku=' . $this->request->get['filter_sku'];
}

if (isset($this->request->get['filter_desc'])) {
	$url .= '&filter_desc=' . $this->request->get['filter_desc'];
}

if (isset($this->request->get['filter_category'])) {
	$url .= '&filter_category=' . $this->request->get['filter_category'];
}

if (isset($this->request->get['filter_manufacturer'])) {
	$url .= '&filter_manufacturer=' . $this->request->get['filter_manufacturer'];
}

if (isset($this->request->get['filter_marketplace'])) {
	$url .= '&filter_marketplace=' . $this->request->get['filter_marketplace'];
}

if (isset($this->request->get['sort'])) {
	$url .= '&sort=' . $this->request->get['sort'];
}

if (isset($this->request->get['order'])) {
	$url .= '&order=' . $this->request->get['order'];
}

$pagination = new Pagination();
$pagination->total = $product_total;
$pagination->page = $page;
$pagination->limit = $this->config->get('config_admin_limit');
$pagination->text = $this->language->get('text_pagination');
$pagination->url = $this->url->link('extension/openbay/itemList', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');

$this->data['pagination'] = $pagination->render();

$this->data['filter_name'] = $filter_name;
$this->data['filter_model'] = $filter_model;
$this->data['filter_price'] = $filter_price;
$this->data['filter_price_to'] = $filter_price_to;
$this->data['filter_quantity'] = $filter_quantity;
$this->data['filter_quantity_to'] = $filter_quantity_to;
$this->data['filter_status'] = $filter_status;
$this->data['filter_sku'] = $filter_sku;
$this->data['filter_desc'] = $filter_desc;
$this->data['filter_category'] = $filter_category;
$this->data['filter_manufacturer'] = $filter_manufacturer;
$this->data['filter_marketplace'] = $filter_marketplace;

$this->data['sort'] = $sort;
$this->data['order'] = $order;

$this->template = 'openbay/openbay_itemlist.tpl';
$this->children = array(
	'common/header',
	'common/footer'
);

$this->response->setOutput($this->render());