Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Контролер формирования URL левого и горизонтального меню


userAT
 Share

Recommended Posts

// Menu
		$this->load->model('catalog/category');

		$this->load->model('catalog/product');

		$data['categories'] = array();

		$categories = $this->model_catalog_category->getCategories(0);

		foreach ($categories as $category) {
			if ($category['top']) {
				// Level 2
				$children_data = array();

				$children = $this->model_catalog_category->getCategories($category['category_id']);

				foreach ($children as $child) {
					$filter_data = array(
						'filter_category_id'  => $child['category_id'],
						'filter_sub_category' => true
					);

					$children_data[] = array(
						'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
						'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
					);
				}

				// Level 1
				$data['categories'][] = array(
					'name'     => $category['name'],
					'children' => $children_data,
					'column'   => $category['column'] ? $category['column'] : 1,
					'href'     => $this->url->link('product/category', 'path=' . $category['category_id'])
				);
			}
		}

		$data['language'] = $this->load->controller('common/language');
		$data['currency'] = $this->load->controller('common/currency');
		$data['search'] = $this->load->controller('common/search');
		$data['cart'] = $this->load->controller('common/cart');

Код из header.php который лежит по пути /www/lorem.ru/catalog/controller/common/

 

Этот ли контролер отвечает за генерацию урлов левого и горизонтального меню или есть ещё что-то, что скрылось из виду ? 

Edited by userAT
Link to comment
Share on other sites


Горизонтальное меню категорий
\catalog\controller\common\header.php

 

Меню категорий слева (если включен модуль в схему)
\catalog\controller\module\category.php

Link to comment
Share on other sites


По горизонтальному в том то и проблема что оно не откликается не на что, в [name] проверяю .'111' никаких отголосков, соответственно обновляю модификаторы....вот и назрел вопрос, а левое наверное не вкл,. папки нет)

Спойлер

image.thumb.png.fa27f26bb497c1d1e7669543ccd2e678.png

20 минут назад, thentru сказал:

Горизонтальное меню категорий
\catalog\controller\common\header.php

 

Меню категорий слева (если включен модуль в схему)
\catalog\controller\module\category.php

 

Link to comment
Share on other sites


9 минут назад, thentru сказал:

Для вашего шаблона смотрите в модулях Мегаменю

и там был, никакого результата не дало, спасибо будем искать.

Link to comment
Share on other sites


9 минут назад, userAT сказал:

и там был, никакого результата не дало, спасибо будем искать

после изменений в нем нужно сбрасывать кэш

Link to comment
Share on other sites


<?php
class ModelExtensionModuleMegamenu extends Model {

	public function getItems()
	{
		$sort = "sort_order";
		$sql = "SELECT * FROM " . DB_PREFIX . "megamenu n LEFT JOIN " . DB_PREFIX . "megamenu_description nd ON n.id = nd.megamenu_id WHERE nd.language_id = '" . (int)$this->config->get('config_language_id') . "' and n.status='1' ORDER BY {$sort}";
		$query = $this->db->query($sql);
		return $query->rows;
	}

	public function getCategoryPath($category_id)
	{
		$sql = "SELECT path_id FROM " . DB_PREFIX . "category_path WHERE category_id='".$category_id."' ORDER BY LEVEL";
		$query = $this->db->query($sql);
		if ($query->rows) {
			$result = array();
			foreach($query->rows as $row) $result[] = $row['path_id'];
			return $result;
		}
		else return false;
	}

	public function parseHtml($item)
	{
		$this->load->model('tool/image');
		$result = array();
		$item['options'] = unserialize($item['options']);
		$result['type'] = "html";
		$result['href'] = (trim($item['link'])) ? $item['link'] : "javascript:void(0);";
		$result['name'] = $item['title'];
		$result['use_target_blank'] = $item['use_target_blank'];
		$result['html'] = $item['html'];
		$result['children'] = true;
		if ($item['thumb']) $result['thumb'] = $item['thumb'];
		else $result['thumb'] = "";
		if ($result['thumb']) {
			$result['thumb'] = $this->model_tool_image->resize($result['thumb'], 50, 50);
		}

		return $result;
	}

	public function parseLink($item)
	{
		$this->load->model('tool/image');
		$result = array();
		$item['options'] = unserialize($item['options']);
		$result['type'] = "link";
		$result['href'] = (trim($item['link'])) ? $item['link'] : "javascript:void(0);";
		$result['name'] = $item['title'];
		$result['use_target_blank'] = $item['use_target_blank'];
		$result['children'] = true;
		if ($item['thumb']) $result['thumb'] = $item['thumb'];
		else $result['thumb'] = "";
		if ($result['thumb']) {
			$result['thumb'] = $this->model_tool_image->resize($result['thumb'], 50, 50);
		}

		return $result;
	}

	public function parseInformation($item)
	{
		$this->load->model('tool/image');
		$this->load->model('catalog/information');
		$result = array();
		$item['options'] = unserialize($item['options']);
		$result['type'] = "information";
		$result['href'] = (trim($item['link'])) ? $item['link'] : "javascript:void(0);";
		$result['name'] = $item['title'];
		$result['use_target_blank'] = $item['use_target_blank'];
		$result['children'] = array();
		if ($item['use_add_html']) $result['add_html'] = $item['add_html'];
		else $result['add_html'] = "";
		if ($item['thumb']) $result['thumb'] = $item['thumb'];
		else $result['thumb'] = "";
		if ($result['thumb']) {
			$result['thumb'] = $this->model_tool_image->resize($result['thumb'], 50, 50);
		}

		if (is_array($item['options']['informations_list'])) {
			foreach($item['options']['informations_list'] as $information_id) {
				$information = $this->model_catalog_information->getInformation($information_id);
				if ($information) {
					$result['children'][] = array(
						'sort_order' => $information['sort_order'],
						'name' => $information['title'],
						'href' => $this->url->link('information/information', 'information_id=' . $information['information_id']) ,
					);
				}
			}
		}

		foreach($result['children'] as $key => $item) {
			$sort_order[$key] = $item['sort_order'];
		}

		array_multisort($sort_order, SORT_ASC, $result['children']);
		return $result;
	}

	public function parseAuth($item)
	{
		$this->load->model('tool/image');
		$result = array();
		$item['options'] = unserialize($item['options']);
		$result['type'] = "auth";
		$result['href'] = (trim($item['link'])) ? $item['link'] : "javascript:void(0);";
		$result['name'] = $item['title'];
		$result['use_target_blank'] = $item['use_target_blank'];
		$result['children'] = true;
		if ($item['thumb']) $result['thumb'] = $item['thumb'];
		else $result['thumb'] = "";
		if ($result['thumb']) {
			$result['thumb'] = $this->model_tool_image->resize($result['thumb'], 50, 50);
		}

		return $result;
	}

	public function parseProduct($item)
	{
		$this->load->model('catalog/product');
		$this->load->model('tool/image');
		$result = array();
		$item['options'] = unserialize($item['options']);
		$width = ((int)$item['options']['product_width'] > 0) ? (int)$item['options']['product_width'] : 50;
		$height = ((int)$item['options']['product_height'] > 0) ? (int)$item['options']['product_height'] : 50;
		$result['type'] = "product";
		$result['href'] = (trim($item['link'])) ? $item['link'] : "javascript:void(0);";
		$result['name'] = $item['title'];
		$result['use_target_blank'] = $item['use_target_blank'];
		if ($item['use_add_html']) $result['add_html'] = $item['add_html'];
		else $result['add_html'] = "";
		if ($item['thumb']) $result['thumb'] = $item['thumb'];
		else $result['thumb'] = "";
		if ($result['thumb']) {
			$result['thumb'] = $this->model_tool_image->resize($result['thumb'], 50, 50);
		}

		$result['children'] = array();
		if (is_array($item['options']['products_list'])) {
			foreach($item['options']['products_list'] as $product_id) {
				$product = $this->model_catalog_product->getProduct($product_id);
				if ($product) {
					$thumb = "";
					if (is_file(DIR_IMAGE . $product['image'])) {
						$thumb = $this->model_tool_image->resize($product['image'], $width, $height);
					}
					else {
						$thumb = $this->model_tool_image->resize('no_image.png', $width, $height);
					}

					if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
						$price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
					}
					else {
						$price = false;
					}

					if ((float)$product['special']) {
						$special = $this->currency->format($this->tax->calculate($product['special'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
					}
					else {
						$special = false;
					}

					$result['children'][] = array(
						'name' => $product['name'].'@',
						'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']) ,
						'thumb' => $thumb,
						'price' => $price,
						'special' => $special
					);
				}
			}
		}

		return $result;
	}

	public function parseManufacturer($item)
	{
		$this->load->model('catalog/manufacturer');
		$this->load->model('tool/image');
		$result = array();
		$item['options'] = unserialize($item['options']);
		$result['type'] = "manufacturer";
		$result['href'] = (trim($item['link'])) ? $item['link'] : "javascript:void(0);";
		$result['name'] = $item['title'];
		$result['use_target_blank'] = $item['use_target_blank'];
		if ($item['use_add_html']) $result['add_html'] = $item['add_html'];
		else $result['add_html'] = "";
		if ($item['thumb']) $result['thumb'] = $item['thumb'];
		else $result['thumb'] = "";
		if ($result['thumb']) {
			$result['thumb'] = $this->model_tool_image->resize($result['thumb'], 50, 50);
		}

		$result['children'] = array();
		if (is_array($item['options']['manufacturers_list'])) {
			foreach($item['options']['manufacturers_list'] as $manufacturer_id) {
				$manufacturer = $this->model_catalog_manufacturer->getManufacturer($manufacturer_id);
				if ($manufacturer) {
					$thumb = "";
					if (is_file(DIR_IMAGE . $manufacturer['image'])) {
						$thumb = $this->model_tool_image->resize($manufacturer['image'], 50, 50);
					}
					else {
						$thumb = $this->model_tool_image->resize('no_image.png', 50, 50);
					}

					$result['children'][] = array(
						'name' => $manufacturer['name'],
						'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id']) ,
						'thumb' => $thumb
					);
				}
			}
		}

		return $result;
	}

	public function aasort(&$array, $key)
	{
		$sorter = array();
		$ret = array();
		reset($array);
		foreach($array as $ii => $va) {
			$sorter[$ii] = $va[$key];
		}

		asort($sorter);
		foreach($sorter as $ii => $va) {
			$ret[$ii] = $array[$ii];
		}

		$array = $ret;
	}

	public function parseCategory($item)
	{
		$this->load->model('catalog/category');
		$this->load->model('tool/image');
		$result = array();
		$item['options'] = unserialize($item['options']);
		$result['type'] = "category";
		$result['subtype'] = $item['options']['variant_category'];
		$result['href'] = (trim($item['link'])) ? $item['link'] : "javascript:void(0);";
		$result['name'] = $item['title'];
		$result['use_target_blank'] = $item['use_target_blank'];
		if ($item['use_add_html']) $result['add_html'] = $item['add_html'];
		else $result['add_html'] = "";
		if ($item['thumb']) $result['thumb'] = $item['thumb'];
		else $result['thumb'] = "";
		if ($result['thumb']) {
			$result['thumb'] = $this->model_tool_image->resize($result['thumb'], 50, 50);
		}

		$result['name'] = $item['title'];
		$result['children'] = array();
		if (is_array($item['options']['categories_list'])) {
			$l = $item['options']['categories_list'];
			$category_list = array();
			foreach($item['options']['categories_list'] as $cat) {
				$category = $this->model_catalog_category->getCategory($cat);
				if ($category) {
					$category_list[] = $category;
				}
			}

			// $this->aasort($category_list, "sort_order");

			$sort_order = array();

			foreach ($category_list as $key => $value) {
				$sort_order[$key] = $value["sort_order"];
			}

			array_multisort($sort_order, SORT_ASC, $category_list);

			foreach($category_list as $category) {
				if ($category) {
					$thumb = "";
					if ($result['subtype'] == "full_image") {
						if (is_file(DIR_IMAGE . $category['image'])) {
							$thumb = $this->model_tool_image->resize($category['image'], 50, 50);
						}
						else {
							$thumb = $this->model_tool_image->resize('no_image.png', 50, 50);
						}
					}

					$children_data = array();
					if ($item['options']['category_show_subcategory']) {
						$children = $this->model_catalog_category->getCategories($category['category_id']);

						$sort_order = array();

						foreach ($children as $key => $value) {
							$sort_order[$key] = $value["sort_order"];
						}

						array_multisort($sort_order, SORT_ASC, $children);

						if ($children) {
							foreach($children as $child) {
								$filter_data = array(
									'filter_category_id' => $child['category_id'],
									'filter_sub_category' => false
								);
								// $path = $this->getCategoryPath($child['category_id']);
								if ($path) $path = implode("_", $path);
								$children_data[] = array(
									'name' => $child['name'],
									'href' => $this->url->link('product/category', 'path='  . $category['category_id'])
								);
							}
						}
					}

					// $path = $this->getCategoryPath($category['category_id']);
					if ($path) $path = implode("_", $path);
					$result['children'][] = array(
						'name' => $category['name'],
						'href' => $this->url->link('product/category', 'path=' . $category['category_id']) ,
						'children' => $children_data,
						'thumb' => $thumb
					);
				}
			}
		}

		return $result;
	}
}

Какие строки могут отвечать за левое меню..,?

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.