I have a large database of products and to keep things organized I assigned them only to the category they apply to and not their parents. This of course has the side effect of empty parent category pages, aside from the category header which contains the description. To address this I decided to use Toolkit randomcat to load a few products from each of the subcategories. It actually works great unless those subcategories have children of their own which is frequently the case.
The next step was to traverse down the tree a level with subcat and try to pull those products out. I managed to get those out too but since it runs inside the foreach loop it's returning three items from each of those sub-subcategories which isn't what I had in mind. To visualize the goal here's a dummy category structure to reference...
Shirts (parent cat)
- Mens (subcat)
- - Big & Tall (subcat2)
- - Short & Small (subcat2)
- Womens (subcat)
- Childrens (subcat)
When the functions run it returns the subcat title and three random products beneath it from that category, except for Mens. There it would originally return nothing but with the subcat function it's now returning three for each of the categories beneath it. However, what I've been trying to do is get it to just grab three random products from the subcat2 categories combined.
I've seen some other posts that all get up to the same point before factoring in the subcat2 level and then a post about bestsellers stating it doesn't work on multiple categories. That got me wondering if the same applies to randomcat or if a work around is possible. I've tried a number of different things with vassign and cxpc added to the mix and it still returns three products for each subcat2 category (or none because I'm trying stuff I know can't possibly work).
So, I guess I'm wondering now if it's possible to dump the products from all subcat2 categories into a variable and then call on that with randomcat, obviously outside of the foreach to avoid looping through and displaying them all. The last resort is to use alternate display pages with a massive product update to add additional parent category assignments. This is a major task though so I want to make sure I'm not missing something in my use of subcat and randomcat first.
As always, your knowledge and tips are greatly appreciated.
Thanks,
Tim
The next step was to traverse down the tree a level with subcat and try to pull those products out. I managed to get those out too but since it runs inside the foreach loop it's returning three items from each of those sub-subcategories which isn't what I had in mind. To visualize the goal here's a dummy category structure to reference...
Shirts (parent cat)
- Mens (subcat)
- - Big & Tall (subcat2)
- - Short & Small (subcat2)
- Womens (subcat)
- Childrens (subcat)
When the functions run it returns the subcat title and three random products beneath it from that category, except for Mens. There it would originally return nothing but with the subcat function it's now returning three for each of the categories beneath it. However, what I've been trying to do is get it to just grab three random products from the subcat2 categories combined.
I've seen some other posts that all get up to the same point before factoring in the subcat2 level and then a post about bestsellers stating it doesn't work on multiple categories. That got me wondering if the same applies to randomcat or if a work around is possible. I've tried a number of different things with vassign and cxpc added to the mix and it still returns three products for each subcat2 category (or none because I'm trying stuff I know can't possibly work).
So, I guess I'm wondering now if it's possible to dump the products from all subcat2 categories into a variable and then call on that with randomcat, obviously outside of the foreach to avoid looping through and displaying them all. The last resort is to use alternate display pages with a massive product update to add additional parent category assignments. This is a major task though so I want to make sure I'm not missing something in my use of subcat and randomcat first.
As always, your knowledge and tips are greatly appreciated.
Thanks,
Tim
Comment