Need help from who know how do this.
How to show each subcategory products on category page in grid style ?
This solve may be intresting many people.
Thanks.
That wouldnt be hard to accomplish but Im not sure how practical it would be, what would you do about the pagination then?If you were to paginate the subcategories you would end up with uneven pages and the visitor wouldnt have access to certain categories 2nd or 3rd or so on page.Or you are thinking about showing 1-2 products from that subcategory as an intro?
Not as an intro, i want to be showing all products for each subcategory in grid style (about 10-15 for each subcategory). And I may not use pagination, for except to increase a number of limit products on page.
(sorry for my english!)
I can to modify .tpl file, but i don't know php , so as to modify category.php file.
Can you help me?
(sorry for my english!)
I can to modify .tpl file, but i don't know php , so as to modify category.php file.
Can you help me?
Edit catalog/controller/product/category.php and find the line (you will find it twice, I am reffering to the first one):
below it add the code:
in the above code you can notice the line:
then find the line:
and below it add the line:
The next file is catalog/view/theme/yourtheme/template/product/category.tpl and find the code:
and replace it with:
This modification doesnt interfeere with the default product list (for example if the category that contains these subcategories also have product they will still be displayed below all this).
Code: Select all
$product_total = $this->model_catalog_product->getTotalProducts($data);
Code: Select all
$subproducts = array();
$productdata = array(
'filter_category_id' => $result['category_id'],
'sort' => $sort,
'order' => $order,
'start' => 0,
'limit' => 15
);
$productresults = $this->model_catalog_product->getProducts($productdata);
foreach ($productresults as $productresult) {
if ($productresult['image']) {
$image = $this->model_tool_image->resize($productresult['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
} else {
$image = false;
}
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($productresult['price'], $productresult['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}
if ((float)$productresult['special']) {
$special = $this->currency->format($this->tax->calculate($productresult['special'], $productresult['tax_class_id'], $this->config->get('config_tax')));
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$productresult['special'] ? $productresult['special'] : $productresult['price']);
} else {
$tax = false;
}
if ($this->config->get('config_review_status')) {
$rating = (int)$productresult['rating'];
} else {
$rating = false;
}
$subproducts[] = array(
'product_id' => $productresult['product_id'],
'thumb' => $image,
'name' => $productresult['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($productresult['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $productresult['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$productresult['reviews']),
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $productresult['product_id'] . $url)
);
}
, 15 reffers to the number of products it shows for each category, you can change that if you wish.'limit' => 15
then find the line:
Code: Select all
'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
Code: Select all
'subproducts' => $subproducts,
Code: Select all
<?php if ($categories) { ?>
<h2><?php echo $text_refine; ?></h2>
<div class="category-list">
<?php if (count($categories) <= 5) { ?>
<ul>
<?php foreach ($categories as $category) { ?>
<li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
<?php } ?>
</ul>
<?php } else { ?>
<?php for ($i = 0; $i < count($categories);) { ?>
<ul>
<?php $j = $i + ceil(count($categories) / 4); ?>
<?php for (; $i < $j; $i++) { ?>
<?php if (isset($categories[$i])) { ?>
<li><a href="<?php echo $categories[$i]['href']; ?>"><?php echo $categories[$i]['name']; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
Code: Select all
<?php if ($categories) { ?>
<?php foreach ($categories as $category) { ?>
<h2><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></h2>
<?php if ($category['subproducts']) { ?>
<div class="product-list">
<?php foreach ($category['subproducts'] as $product) { ?>
<div>
<?php if ($product['thumb']) { ?>
<div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
<?php } ?>
<div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
<div class="description"><?php echo $product['description']; ?></div>
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
<?php if ($product['tax']) { ?>
<br />
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
<?php } ?>
</div>
<?php } ?>
<?php if ($product['rating']) { ?>
<div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
<?php } ?>
<div class="cart">
<input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />
</div>
<div class="wishlist"><a onclick="addToWishList('<?php echo $product['product_id']; ?>');"><?php echo $button_wishlist; ?></a></div>
<div class="compare"><a onclick="addToCompare('<?php echo $product['product_id']; ?>');"><?php echo $button_compare; ?></a></div>
</div>
<?php } ?>
</div>
<?php } ?>
<?php } ?>
florinsith , huge humane thanks for help !!!
it is important to be understand principle necessary modifications in .php file for me. At the next, i must to finish modifications myself for my features of the site template.
(sorry for my English, i hope you are undestand me)
it is important to be understand principle necessary modifications in .php file for me. At the next, i must to finish modifications myself for my features of the site template.
(sorry for my English, i hope you are undestand me)
Who is online
Users browsing this forum: No registered users and 17 guests