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

Изменить вид корзины, разбивка по категориям


Recommended Posts

Здравствуйте!

Подскажите пожалуйста, как в корзине сделали группировку товаров по категориям?

Вот сайт пример: assorti62.ru

Работаем с  моделью system/library/cart/cart.php, контроллером  catalog/controller/checkout/cart.php, а так же с catalog/view/theme/*/template/checkout/cart.tpl (в этом непосредственно настраиваем вывод)

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) {
$query = $this->db->query("SELECT DISTINCT *, (SELECT GROUP_CONCAT(cd1.name ORDER BY level SEPARATOR '  >  ') FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "category_description cd1 ON (cp.path_id = cd1.category_id AND cp.category_id != cp.path_id) WHERE cp.category_id = c.category_id AND cd1.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY cp.category_id) AS path, (SELECT DISTINCT keyword FROM " . DB_PREFIX . "url_alias WHERE query = 'category_id=" . (int)$category_id . "') AS keyword FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd2 ON (c.category_id = cd2.category_id) WHERE c.category_id = '" . (int)$category_id . "' AND cd2.language_id = '" . (int)$this->config->get('config_language_id') . "'");
return $query->row;
	}
} 

в catalog/controller/checkout/cart.php

 

после $data['column_name'] = $this->language->get('column_name');

вставляю $data['column_category'] = $this->language->get('column_category');

 

после $product_total = 0;

вставляю $category_name = $this->model_catalog_custom->getproductcategory($product['product_id']);

далее добавляю в

$data['products'][] = array(

'category_name'=>$category_name,

 

И вот как сформировать вид корзины?

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • 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.