It would be very nice, if there would be a possibility to have new products in categories or subcategories. Actually if there are some root categories with some subcategories a customer has to click through a lot of categories to see products. The only place actually to see products is on the home page.
A good candidate for such a function would be the new products part. It would be very nice if that part could display in every category (from root to subcategory) a few new products.
An example: There is a root category with printers. The root category has subcategories: Laser, Inkjet. Those subcategories have other subcategories like Color Laser, Mono Laser, Laser Multifunction, Inkjet, Inkjet Multifunction a.s.o. Until the third subcategory a customer does not see even one product, just links to other categories and a few category pictures. So a customer needs to click into root category, subcategory1, subcategory 2 a.s.o. to see a few products. that is not very interesting for customers.
A good candidate for such a function would be the new products part. It would be very nice if that part could display in every category (from root to subcategory) a few new products.
An example: There is a root category with printers. The root category has subcategories: Laser, Inkjet. Those subcategories have other subcategories like Color Laser, Mono Laser, Laser Multifunction, Inkjet, Inkjet Multifunction a.s.o. Until the third subcategory a customer does not see even one product, just links to other categories and a few category pictures. So a customer needs to click into root category, subcategory1, subcategory 2 a.s.o. to see a few products. that is not very interesting for customers.
There is nothing to prevent you from making a product belong to more than one category, e.g. it couyld belong to a whole category chain.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Dear J. Neuhoff,
it is true to make a product visible in more than one category. this happens by clicking in the admin under products and activating some categories. The problem is that if you have a lot of daily changing products with a lot of categories and subcategories, you make take more than one day to do so. And if the daily product import (automated by a cron script, which pulls those data from a distributor) of about 40 000 products with a lot of categories and subcategories it takes the whole day to click around in the admin area.
If the new products would be a content module with some more logic, it could be integrated with an <?php include (....); ?> and would be able to show new products in categories. Actually it is not a module or block, it is just a part of the home.php.
And it is not very customer friendly to show only categories and subcategories a.s.o. without showing a few products (new ones for example).
OpenCart is a new shopping cart which should be a little bit better than older solutions like oscommerce. But for that case oscommerce does a much better job and that is only because the new products is implemented as a module and not as part of the home.php code.
it is true to make a product visible in more than one category. this happens by clicking in the admin under products and activating some categories. The problem is that if you have a lot of daily changing products with a lot of categories and subcategories, you make take more than one day to do so. And if the daily product import (automated by a cron script, which pulls those data from a distributor) of about 40 000 products with a lot of categories and subcategories it takes the whole day to click around in the admin area.
If the new products would be a content module with some more logic, it could be integrated with an <?php include (....); ?> and would be able to show new products in categories. Actually it is not a module or block, it is just a part of the home.php.
And it is not very customer friendly to show only categories and subcategories a.s.o. without showing a few products (new ones for example).
OpenCart is a new shopping cart which should be a little bit better than older solutions like oscommerce. But for that case oscommerce does a much better job and that is only because the new products is implemented as a module and not as part of the home.php code.
Dear Qphoria,
your question to my question is exactly the thing I mean. There should be a block module for new products, which could be integrated in other than home page (oscommerce is an example, it is very old but the new products module there operates very nice).
We loose a lot of promotion possibilities if me do not show products to the customers. From the customer point of view OpenCart does not invite to add some other products to the cart. the customer has to click from root category through a lot of subcategories before he may see products.
your question to my question is exactly the thing I mean. There should be a block module for new products, which could be integrated in other than home page (oscommerce is an example, it is very old but the new products module there operates very nice).
We loose a lot of promotion possibilities if me do not show products to the customers. From the customer point of view OpenCart does not invite to add some other products to the cart. the customer has to click from root category through a lot of subcategories before he may see products.
Not to threadjack, but I thought it was close enough...
I would be thrilled in the category.tpl would show the sub categories at the top as it does now, and the second table showed not only products within the current category, but all applicable sub categories as well.
This functionality would basically make the sub-catagories more like filters than a directory structure, which I think is the more common approach in today's e-commerce.
I guess I'm going to have to edit the catagory model "getProductsByCategoryId" to find the category's child categories and pull those products as well. A recursive function of something.. Has anyone already done this?
This approach just seems to make more sense then having to apply several category selections when entering the product.
I would be thrilled in the category.tpl would show the sub categories at the top as it does now, and the second table showed not only products within the current category, but all applicable sub categories as well.
This functionality would basically make the sub-catagories more like filters than a directory structure, which I think is the more common approach in today's e-commerce.
I guess I'm going to have to edit the catagory model "getProductsByCategoryId" to find the category's child categories and pull those products as well. A recursive function of something.. Has anyone already done this?
This approach just seems to make more sense then having to apply several category selections when entering the product.
Newbie
cowpoke McStink wrote: I would be thrilled in the category.tpl would show the sub categories at the top as it does now, and the second table showed not only products within the current category, but all applicable sub categories as well.
Doesn't it already do this? Or you mean you want ALL sub-subs-subs to show on this page?
Like:
-------------------------------------
| direct subs of this category |
++++++++++++++++++++++++++++
| Products in this category |
+++++++++++++++++++++++++++
| subs of sub-categories |
---------------------------------------
Unfortunately, It doesn't..
I mean like this:
-------------------------------------
| direct subs of this category |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| Products in this category and products in all sub cats and sub sub cats....|
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I want a listing of every product in the current directory and all products within any sub category of the current directory.
For instance, take the following scenario..
A. Animals (main category)
1. Cats (Sub Category)
a. male (Sub Sub Category)
- Garfield (Product)
- Simba
b. female
- Nermal
2. Dogs
a. male
- Santas Little Helper
- Cujo
b. female
- bitch 1
- bitch 2
3. Goats
a. Milking
- LadyGoat1
b. Non-Milking
-Billy
If this is our category/product listing and I navigate to the Animals category I will get a listing of sub categories only.. I think the customer should see both the sub categories, and all animals (paginated if necessary)
- Garfield (Product)
- Simba
- Nermal
- Santas Little Helper
- Cujo
- bitch 1
- bitch 2
- LadyGoat1
-Billy
If the customer drills down to the Dogs sub category.. they should see the male and female sub categories AND all products within those directories..
- Santas Little Helper
- Cujo
- bitch 1
- bitch 2
I think this makes sense... but hey, maybe I'm just crazy! I think that the requirement of the admin to manually add the specific and all parent categories is contrary to the easy to use tone of the rest of the framework.
But I'm not bitching.... I'm a fixer not a complainer, so after I take the time to write some horrible looking code that gets the job done, I'll post it here for the real pros to clean up.
-Cowpoke
I mean like this:
-------------------------------------
| direct subs of this category |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| Products in this category and products in all sub cats and sub sub cats....|
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I want a listing of every product in the current directory and all products within any sub category of the current directory.
For instance, take the following scenario..
A. Animals (main category)
1. Cats (Sub Category)
a. male (Sub Sub Category)
- Garfield (Product)
- Simba
b. female
- Nermal
2. Dogs
a. male
- Santas Little Helper
- Cujo
b. female
- bitch 1
- bitch 2
3. Goats
a. Milking
- LadyGoat1
b. Non-Milking
-Billy
If this is our category/product listing and I navigate to the Animals category I will get a listing of sub categories only.. I think the customer should see both the sub categories, and all animals (paginated if necessary)
- Garfield (Product)
- Simba
- Nermal
- Santas Little Helper
- Cujo
- bitch 1
- bitch 2
- LadyGoat1
-Billy
If the customer drills down to the Dogs sub category.. they should see the male and female sub categories AND all products within those directories..
- Santas Little Helper
- Cujo
- bitch 1
- bitch 2
I think this makes sense... but hey, maybe I'm just crazy! I think that the requirement of the admin to manually add the specific and all parent categories is contrary to the easy to use tone of the rest of the framework.
But I'm not bitching.... I'm a fixer not a complainer, so after I take the time to write some horrible looking code that gets the job done, I'll post it here for the real pros to clean up.
-Cowpoke
Newbie
Alright,
True to my word I am back with some code that changes the category view to show all products within that category, and ALL sub categories to that category.
Here is what I did:
Add the following functions within the catalog\model\product.php file:
Then open up catalog\model\catalog\category.php and add the following function:
Finally, make the following changes to you catalog\controller\product\category.php file:
Around line 91, change the function name that fetches the $product_total like so:
Just below that after the data['products'] is declared around line 113 add the following:
Finally, close up the foreach loop we added by adding the appropriate } after the data['products'] array is filled in and before the "config customer price" stuff kicks in.
I think that is it. I'm using version 1.3.2
If I have left anything out, go ahead and yell at me. If your utter lack of PHP experience makes this modification too difficult for you, don't yell at me, just go get more experience.
-Cowpoke
True to my word I am back with some code that changes the category view to show all products within that category, and ALL sub categories to that category.
Here is what I did:
Add the following functions within the catalog\model\product.php file:
Code: Select all
public function buildWhereClause($parent_id = 0) {
$results = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->language->getId() . "' ORDER BY c.sort_order");
$num_rows = count($results->rows);
If ($num_rows != 0) {
foreach ($results->rows as $result) {
$this->where_clause .= "OR p.status = '1' AND p.date_available <= NOW() AND p2c.category_id = '" . (int)$result['category_id'] . "' ";
$this->buildWhereClause($result['category_id']);
}
}
}
public function getTotalProductsByCategoryIdwithSubs($category_id = 0) {
$this->buildWhereClause($category_id);
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_to_category p2c LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2c.category_id = '" . (int)$category_id . "'" . $this->where_clause);
return $query->row['total'];
}
Code: Select all
public function getCategoriesandSubs($parent_id = 0) {
static $cat_branch = array();
$results = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->language->getId() . "' ORDER BY c.sort_order");
$num_rows = count($results->rows);
If ($numcata_rows != 0) {
foreach ($results->rows as $result) {
$cat_branch[] = $result['category_id'];
$this->getCategoriesandSubs($result['category_id']);
}
}
$num_subcats = count($cat_branch);
return $cat_branch;
}
Around line 91, change the function name that fetches the $product_total like so:
Code: Select all
$product_total = $this->model_catalog_product->getTotalProductsByCategoryIdwithSubs($category_id);
Code: Select all
$sub_cats = $this->model_catalog_category->getCategoriesandSubs($category_id);
array_unshift($sub_cats, $category_id);
foreach ($sub_cats as $category_id) {
I think that is it. I'm using version 1.3.2
If I have left anything out, go ahead and yell at me. If your utter lack of PHP experience makes this modification too difficult for you, don't yell at me, just go get more experience.
-Cowpoke
Newbie
I made a mistake in copying one of the snippets above.
The catalog\model\catalog\category.php file function should not have the extra "cata" in the middle of my $num_rows variable. Use this instead..
The catalog\model\catalog\category.php file function should not have the extra "cata" in the middle of my $num_rows variable. Use this instead..
Code: Select all
public function getCategoriesandSubs($parent_id = 0) {
static $cat_branch = array();
$results = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->language->getId() . "' ORDER BY c.sort_order");
$num_rows = count($results->rows);
If ($num_rows != 0) {
foreach ($results->rows as $result) {
$cat_branch[] = $result['category_id'];
$this->getCategoriesandSubs($result['category_id']);
}
}
$num_subcats = count($cat_branch);
return $cat_branch;
}
Newbie
Thanks! This worked for me
I was going to write it myself, but saw it here and couldn't avoid some C&P, to make it work on 1.4.8, I had to change the way it references to the language:
Change from "(int)$this->language->getId()" to "(int)$this->config->get('config_language_id')" everywhere it's referenced.
Greetings,
Victor

Change from "(int)$this->language->getId()" to "(int)$this->config->get('config_language_id')" everywhere it's referenced.
Greetings,
Victor
I am not sure if anyone will see this since the thread is so old but i think the code here is close to being able to help...
You can see what i want it to do here http://thepondshop.com/index.php?route= ... ry&path=36 but i want it to do this on all pages? if you hover over the category Pond and Lake Aerators it shows the sub categories but i want to be able to do this on all pages such as home, other categories, etc...
Any help would be greatly appreciated!
Thanks
You can see what i want it to do here http://thepondshop.com/index.php?route= ... ry&path=36 but i want it to do this on all pages? if you hover over the category Pond and Lake Aerators it shows the sub categories but i want to be able to do this on all pages such as home, other categories, etc...
Any help would be greatly appreciated!
Thanks
Who is online
Users browsing this forum: No registered users and 23 guests