7 replies [Last post]
damian.pop's picture
Offline
Joined: 07/02/2010
Juice: 10
Was this information Helpful?

I need a catalog category page to display products of all it's subcategories too.
I think that's how most ecommerce sites works, but I can't find the way to do it with ubercart.

Any help will be greatly appreciated!

damian.pop's picture
Offline
Joined: 07/02/2010
Juice: 10
Re: Catalog: How to display products of category and subcategori

Please, any comments?? I'm sure that many people must have gone through this same problem before.

end user's picture
Offline
Joined: 01/11/2008
Juice: 1198
Re: Catalog: How to display products of category and subcategori

I guess you could create a view with a pager that lists all the products from the subcats and then insert the view into a template file of the main category, below the sub category listing.

http://drupal.org/node/223440

damian.pop's picture
Offline
Joined: 07/02/2010
Juice: 10
Re: Re: Catalog: How to display products of category and subcate

Well, I finally managed to do so.
I've created a new view called 'uc_products_categ' showing the list of products of a category (taken by parameter) and its subcategories, and then I overrided the function 'theme_uc_catalog_browse' with a function that renders the view, something like this:

function mytheme_uc_catalog_browse($tid = 0) {
drupal_add_css(drupal_get_path('module', 'uc_catalog') .'/uc_catalog.css');

$output = '';
$catalog = uc_catalog_get_page((int)$tid);
drupal_set_title(check_plain($catalog->name));

//load the view by name
$view = views_get_view('uc_products_categ');
//render the view
$output .= $view->execute_display('default', array($tid));

return $output;
}

Hope this would be useful for anybody.

remaye's picture
Offline
Joined: 01/08/2010
Juice: 53
Ubercart default catalog

I'm not sure if it is what you want, but it's seems this is covered by Ubercart default catalog.
You just have to select both category AND subcategory for each product and it's done :
it display all products from all subcategories when a category is selected
and of course only products of subcategory when a subcategory is selected.

sashomi's picture
Offline
Joined: 06/19/2008
Juice: 29
Re: Ubercart default catalog

This works, if you don't display the count of the products in the categories. If you use this, you'll see that categories have 2 times more products than the products in all subcategories. It has something to do with taxonomy_term_count_nodes from drupal core, but I still don't find fix for this stupid thing. It counts products twice, because they actually are in the parent category and in the child category as well. I like this option to view count of products in each category ...

dainis's picture
Offline
Joined: 12/14/2010
Juice: 32
Re: Re: Re: Catalog: How to display products of category and sub

That is exactly what I am looking for Smiling
damian, can you please tell what setting you use for uc_products_categ view? I cant figure out how to display all product from taxonomy term Sad

u280ks's picture
Offline
Joined: 12/19/2009
Juice: 17
Hi, I've setup a custom view

Hi,
I've setup a custom view to replace the default ubercart catalog page, and I would like to use the default Taxonomy Catalog Block (in matter of simplicity) for the store product navigation. I've spend many hours reading articles, blogs and forums on how to replace the default Ubercart Catalog Page with a custom view and couldn't find anything that is well documented (I mean written for Drupal-Ubercart beginer).
However I did try the code that damian.pop provide and it is working very well, with one exception:
I'm using the default Taxonomy Catalog Block from Ubercart and it's structured like:

Catalog
- category 01
-- sub-category 01-01
-- sub-category 01-02
-category 02
-- sub-category 02-01
...
etc.

My suffering is that I can't manage to display (to assign) a view for the Catalog page and the Categories pages which are not a product listings but just images of sub-categories. Those pages are blank.

Any help or pointing me to the right direction is highly appreciated.
Thank you for your time.