Answer the question
In order to leave comments, you need to log in
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: )
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
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 questionAsk a Question
731 491 924 answers to any question