Jump to content
Sign in to follow this  

Сравнение товаров

Recommended Posts

Необходимо, чтобы сравнивались товары только одной категории.

Предположим на сайте есть две категории холодильники и телефоны.

Нужно чтобы холодильники сравнивались с холодильниками и наоборот.

Всем спасибо за ответы!

Share this post

Link to post
Share on other sites

Можно как бы так (




Ищем (~10 строка)

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

После добавляем

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


Ищем (~174 строка)

	public function add() {

В ней ищем (~193 строка)

		if ($product_info) {

После добавляем

			$in_category = array();
			$q = $this->db->query("SELECT p2c.`category_id`, cd.name FROM " . DB_PREFIX . "product_to_category p2c LEFT join " . DB_PREFIX . "category_description cd ON cd.category_id = p2c.`category_id` WHERE product_id = '".$product_id."' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
			if ($q->num_rows) {
				$rows = $q->rows;
				foreach ($rows as $row) {
					$el = array();
					$el['name'] = $row['name'];
					$el['cat_id'] = $row['category_id'];
					$el['href'] = $this->url->link('product/category', 'path=' . $row['category_id']);
					$in_category[] = $el;
			if (count($in_category)) {
				$mas = array();
				foreach ($in_category as $cat) {
					$mas[] = $cat['cat_id'];
			if ( !array_intersect($this->session->data['cat_id'],$mas) ) { $this->session->data['compare'] = array(); }
			$this->session->data['cat_id'] = $mas;


Сойдет такое решение?


З.Ы.: https://opencartforum.com/topic/19648-uznat-id-kategorii/?do=findComment&comment=144820

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.


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.