Y
Y
Yastr2016-11-24 12:41:01
CMS
Yastr, 2016-11-24 12:41:01

How to find out if a product has been added to comparison in opencart?

The category works like this.
controller

$in_compare = 0;
if (isset($this->session->data['compare'])) {
  $key = array_search($result['product_id'], $this->session->data['compare']);
  if ($key !== false) {
    $in_compare = 1;
  }
}
$data['in_compare'] = $in_compare;

in the product card, $this->session->data does not contain comparison information.
Can you please tell me how can I implement this check in the product card?
opencart 2.3

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yastr, 2016-11-24
@Yastr

wrote a question and realized that everything is simple) it was necessary to load $this->load->model('catalog/category');

D
djabric, 2018-08-14
@djabric

where exactly to put $this->load->model('catalog/category'); ?
No matter how much I fight, the check in the product card does not work in any way :(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question