A
A
Anatoly Filippov2016-12-21 21:50:39
PHP
Anatoly Filippov, 2016-12-21 21:50:39

How to group items in cart by parent category in Opencart 2?

Hello! Can you please tell me how they grouped goods by category in the opencart basket? And as I understand it, it is by the parent, since the product can be in two or more categories. Here is an example site: assorti62.ru (Cart screen: 62f4b69249934406bee1f6f15a046c7c.jpg)
As I understand it, you need to work with the cart.php controller and the cart.tpl model.
That is, rip out the id of the parent category from the product, compare if anyone else has one, make a new array and output in tpl that data? But how to do this I generally xs, especially in php a little less than zero. Or maybe you met some kind of module or modification? I would be very grateful
Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
demkas, 2017-12-20
@demkas

class ModelCatalogCustom extends Model {
public function getproductcategory($product_id){
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'" );
$category = $this->getCategory($query->row['category_id']);
return $category['name'];
}
public function getCategory($category_id) {
"' AND cd2.language_id = '" . (int)$this->config->get('config_language_id') . "'");
return $query->row;
}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question