VirtueMart Forum
VirtueMart 2 + 3 => Templating & Layouts => Topic started by: vanaveno on February 11, 2012, 09:21:41 am
-
I need to display all products under the sub-categories of the current category too.
Example: Category tree is:
main-category1 (show all of products)
-subcategory1 (only products subcategory -1)
-subcategory2 (only products subcategory -2)
....
Now I get only menu of subcategories I not see products. Is it possible to change this I want to see products not menu subcategory.
I thing there is similar solution of this problem, but it is at VM 1.
http://forum.virtuemart.net/index.php?topic=20837.0
But I need it for VM2. Thanks for respond.
-
Hi,
I as well would love a solution for this. I was able to get this to work very well with"
http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-navigation/6775
But now that I've moved the site to VM 2 this is no longer an option. Any clues or tips on this?
=-s-=
-
Same problem here, if someone could help
Thanks
-
Same issue here. Nobody a solution for this? :-\
-
I don't have a solution either. Anyone???? :-\
-
So... I'm PHP beginner... but... this works for me... :)
After the setKeyWord function in \administrator\components\com_virtuemart\models\product.php place:
function untreeCat($vm_catid, &$ccont){
$dbx = JFactory::getDBO();
$q = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$dbx->setQuery($q);
$dby = $dbx->query();
if (!$dby->num_rows) {
return;
} else {
while($tt = $dby->fetch_row()) {
array_push($ccont, $tt[0]);
$kat = $tt[0];
$this->untreeCat($kat, $ccont);
}
}
}
Then search for this:
if ($virtuemart_category_id>0){
$joinCategory = true ;
$where[] = ' `#__virtuemart_product_categories`.`virtuemart_category_id` = '.$virtuemart_category_id;
}
... and replace it with following:
if ($virtuemart_category_id>0){
$joinCategory = true ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}
EDIT: There was one missing row in the code here. So I replaced the last part by the Piszi's version. (tested and works)
-
Actually I think you could make your code more compact if you concat your category id-s, than your query will result only one line or nothing.
So you could do a query like this:
$query = 'SELECT GROUP_CONCAT(`category_child_id` SEPARATOR ", ") FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
This will return something like this: 1, 2, 3, ...
Oh and your $where[] mod has a syntax error
If you put a comma in the query and you doesn't have a child category than you will get a MySQL error because of that comma.
So you should make your code like this:
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
Otherwise great work!
-
I modified the VM1 version only. The syntax error is caused by one missing row in the code here. ( $qkat = str_replace(',)', ')', $qkat); ) Don't know why it diappeared... ???
I replaced that part of code by your version. Thanks.
-
Can you please send me product.php
on my site i'm getting
Notice: Trying to get property of non-object in E:\xampp\htdocs\elifeaftercheckout\administrator\components\com_virtuemart\models\product.php on line 172
its not working :'(
Thank you
Rupesh
Actually I think you could make your code more compact if you concat your category id-s, than your query will result only one line or nothing.
So you could do a query like this:
$query = 'SELECT GROUP_CONCAT(`category_child_id` SEPARATOR ", ") FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
This will return something like this: 1, 2, 3, ...
Oh and your $where[] mod has a syntax error
If you put a comma in the query and you doesn't have a child category than you will get a MySQL error because of that comma.
So you should make your code like this:
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
Otherwise great work!
-
see i uploaded it to live but still it shows subcategory!
http://elifeshopping.com/index.php?option=com_virtuemart&view=category&virtuemart_category_id=1&lang=en
-
i tried this fix as well and could see now change. I'm in vm 2.8 and joomla 2.5.6.
-
Still looking for this solution.. Does someone have found a way to get this done?
-
I need to display all products under the sub-categories of the current category too.
Example: Category tree is:
main-category1 (show all of products)
-subcategory1 (only products subcategory -1)
-subcategory2 (only products subcategory -2)
....
Now I get only menu of subcategories I not see products. Is it possible to change this I want to see products not menu subcategory.
I thing there is similar solution of this problem, but it is at VM 1.
http://forum.virtuemart.net/index.php?topic=20837.0
But I need it for VM2. Thanks for respond.
Tested this under joomla 2.5.7 with VM 2.0.10.
Within Joomla if you create a menu item that will show every subcategory with the products choose VirtueMart Categories Layout as a link from that menu
for every subcategory make a submenu item that links to every single category layout.
Hence: main-category1 (show all of the products) - link this one to VirtueMart Categories Layout -> This will display all the products of all categories.
-subcategory1 (only products subcategory -1) - Link this one to VirtueMart » Category Layout (subcategory 1)
-subcategory2 (only products subcategory -2) - Link this one to VirtueMart » Category Layout (subcategory 2)
Now depending on the amount of products you'll get a set of pages (default 10 products per page). Just enhance this number to display more products per page.
hope this helped.
-
I need to display all products under the sub-categories of the current category too.
Example: Category tree is:
main-category1 (show all of products)
-subcategory1 (only products subcategory -1)
-subcategory2 (only products subcategory -2)
....
Now I get only menu of subcategories I not see products. Is it possible to change this I want to see products not menu subcategory.
I thing there is similar solution of this problem, but it is at VM 1.
http://forum.virtuemart.net/index.php?topic=20837.0
But I need it for VM2. Thanks for respond.
Tested this under joomla 2.5.7 with VM 2.0.10.
Within Joomla if you create a menu item that will show every subcategory with the products choose VirtueMart Categories Layout as a link from that menu
for every subcategory make a submenu item that links to every single category layout.
Hence: main-category1 (show all of the products) - link this one to VirtueMart Categories Layout -> This will display all the products of all categories.
-subcategory1 (only products subcategory -1) - Link this one to VirtueMart » Category Layout (subcategory 1)
-subcategory2 (only products subcategory -2) - Link this one to VirtueMart » Category Layout (subcategory 2)
Now depending on the amount of products you'll get a set of pages (default 10 products per page). Just enhance this number to display more products per page.
hope this helped.
I know this solution! just ping me i will help you!
-
So... I'm PHP beginner... but... this works for me... :)
After the setKeyWord function in \administrator\components\com_virtuemart\models\product.php place:
function untreeCat($vm_catid, &$ccont){
$dbx = JFactory::getDBO();
$q = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$dbx->setQuery($q);
$dby = $dbx->query();
if (!$dby->num_rows) {
return;
} else {
while($tt = $dby->fetch_row()) {
array_push($ccont, $tt[0]);
$kat = $tt[0];
$this->untreeCat($kat, $ccont);
}
}
}
Then search for this:
if ($virtuemart_category_id>0){
$joinCategory = true ;
$where[] = ' `#__virtuemart_product_categories`.`virtuemart_category_id` = '.$virtuemart_category_id;
}
... and replace it with following:
if ($virtuemart_category_id>0){
$joinCategory = true ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}
EDIT: There was one missing row in the code here. So I replaced the last part by the Piszi's version. (tested and works)
Thanks for this solution, i made the following changes to make this work in Joomla 2.5.7 and Virtumart 2.0.11d.
function untreeCat($vm_catid, &$ccont){
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$db->setQuery($query);
$db->query();
$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($ccont, $row[0]);
$kat = $row[0];
$this->untreeCat($kat, $ccont);
}
}
}
if ($virtuemart_category_id > 0){
$joinCategory = TRUE ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}
-
THANK YOU!! Big help for me! This is worked in Joomla 2.5.7 with VirtueMart 2.
So... I'm PHP beginner... but... this works for me... :)
After the setKeyWord function in \administrator\components\com_virtuemart\models\product.php place:
function untreeCat($vm_catid, &$ccont){
$dbx = JFactory::getDBO();
$q = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$dbx->setQuery($q);
$dby = $dbx->query();
if (!$dby->num_rows) {
return;
} else {
while($tt = $dby->fetch_row()) {
array_push($ccont, $tt[0]);
$kat = $tt[0];
$this->untreeCat($kat, $ccont);
}
}
}
Then search for this:
if ($virtuemart_category_id>0){
$joinCategory = true ;
$where[] = ' `#__virtuemart_product_categories`.`virtuemart_category_id` = '.$virtuemart_category_id;
}
... and replace it with following:
if ($virtuemart_category_id>0){
$joinCategory = true ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}
EDIT: There was one missing row in the code here. So I replaced the last part by the Piszi's version. (tested and works)
Thanks for this solution, i made the following changes to make this work in Joomla 2.5.7 and Virtumart 2.0.11d.
function untreeCat($vm_catid, &$ccont){
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$db->setQuery($query);
$db->query();
$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($ccont, $row[0]);
$kat = $row[0];
$this->untreeCat($kat, $ccont);
}
}
}
if ($virtuemart_category_id > 0){
$joinCategory = TRUE ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}
-
great post. And how can I fix this code to show the products not from the child category, and within this category of children categories.
Example directory has http://www.lit-kom.ru/catalog/печи_баные/
there child categories and displayed their findings and their product has child categories.
thank you in advance
-
Great post, the modified product.php works fine for me on J2.5.7 and VM2.0.12b.
Only one downside:
When I'm in the browsepage of a Level A category all products from Level B subcategories are displayed just fine, but the select manufacturer box does not give any values of manufacturers from the subcategory products.
Anyone an idea how to hack this ?
-
Hi
I just saw this thread, maybe you can help me.
I'm setting up a site that has 2 main categories (no products in these) each with subcategories with products. It's a migration from J 1.5 and VM 1.1.19 and I want to keep the underlying logic of categories and "product types"
-) Categories: I want to display the category and subcategories just lik VM does, using the category view. When the user clicks on a subcat, he then sees the corresponding products. This is because we have two main aggregating categories, each with 4+ subcategories and each subcategory with a lot of products.
-) "Product type view": We've moved from product types to custom fields and bought an AJAX filter. So far, so good, when in a subcategory it correctly filters and displays the products according to custom fields. However, I need a view for the products in the subcategories for each of the two main big categories - they are the main aggregators and I want to filter from them.
I followed the steps in this thread and in fact it works, but for the wrong views that I need.
Right now the "category" view displays both subcategories and products from them.
What I need is:
- the "category" view to display just the subcategories when in the main category and the products when in the subcategory - just like the original version.
- And the "categories" view (the one that just displays the subcategories), or some new view, to display the products from subcategories without displaying the category description or its subcategories images.
If anyone can help with some hints....
Thanks in advance and best regards,
Alexandre
-
Hello,
I'm working at J2.5.8 and the newest VM2.0.16. I modified the VM according with the posted solution.
Thanks for this solution, i made the following changes to make this work in Joomla 2.5.7 and Virtumart 2.0.11d.
function untreeCat($vm_catid, &$ccont){
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$db->setQuery($query);
$db->query();
$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($ccont, $row[0]);
$kat = $row[0];
$this->untreeCat($kat, $ccont);
}
}
}
if ($virtuemart_category_id > 0){
$joinCategory = TRUE ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}
Unfortunately it doesn't work. I'm bad at PHP. I can only state that the code in VM2.0.16 was changed.
Instead of this (Virtumart 2.0.11):
if ($virtuemart_category_id>0){
$joinCategory = true ;
$where[] = ' `#__virtuemart_product_categories`.`virtuemart_category_id` = '.$virtuemart_category_id;
}
there is ((Virtumart 2.0.16):
if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
}
If someone could help...
Thanks in advance
-
I've tried to do something on one's own. I've changed `#__virtuemart_product_categories` in
if ($virtuemart_category_id > 0){
$joinCategory = TRUE ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `#__virtuemart_product_categories`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}
to `pc` and it works. Almost works... When it displays product details page, it also displays (at the bottom of the page) all subcategories (images)...
Anybody help?
-
Everybody who want to reach the same results but without manual PHP code modification, you might see the following page:
http://www.kainhofer.com/virtuemart-2-extensions/vm2-auto-categories-plugin.html (http://www.kainhofer.com/virtuemart-2-extensions/vm2-auto-categories-plugin.html)
Very easy configuration and what is the most important - it works (at least for me...) in Joomla 2.5.8 and Virtumart 2.0.16.
-
Hi,
I am new to virtuemart. I use virtuemart 1.1.x,
Please help me for showing all products on product detail page.
Example: Category tree is:
main-category1 (show all of products)
-subcategory1 (only products subcategory -1)
- product 1
- product 3
- product 3
-subcategory2 (only products subcategory -2)
on "product 1" detail page, i want all other products are listed below to "product 1" of "category1"
Help me please
Thanks
-
@dharmendrarao VM1.1 is no longer supported. http://forum.virtuemart.net/index.php?topic=106865.0
There is still a 1.1 section of the forum for those who still have a site with the old versions, so you could try posting there.
-
Hi All,
This is my first post here and firstly I would like to thank to all who helps on this forum as I found it extremely helpful.
I'm new in Virtuemart and trying to display the products from the category(ies) selected below the category list. I can see the solution presented here is working for some but not for all. My question is has anyone managed to get it working on Joomla! 2.5.8 and Viruemart 2.0.18a?
A bit off-topic question but - is it possible to display subcategories as a list of links (ie. Category1 | Category2 | Category3 ) no images just text?
I'll appreciate any help.
-
Don't know if topic is obsolete, but here is the working code for the latest version of Virtuemart.
After the setKeyWord function in \administrator\components\com_virtuemart\models\product.php place:
function untreeCat($vm_catid, &$ccont){
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$db->setQuery($query);
$db->query();
$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($ccont, $row[0]);
$kat = $row[0];
$this->untreeCat($kat, $ccont);
}
}
}
Then search for this:
if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
}
... and replace it with following:
if ($virtuemart_category_id > 0){
$joinCategory = TRUE ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `pc`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}
Best regards,
franci77
-
Thank you franci,
This worked like a charm, i need a little bit change to be exactly what i want.
Is there a way to do the same but instead of talking about subcategory products, i would like to display all products inside each category in the main Categories view.
I try to explain it in a different way, now we display the subcategories product inside the category view. Can i display categories products in the categories view?
Is it possible to do that ? what should i change and in which file then?
-
Okay, at least is there a way to Display the Subcategory name, now i get displayed all the products but i would like to have the subcategory name displayed before its products. For example:
Category 1
Products of category 1
Subcategory 1
Products of subcategory 1
etc.
Anyone have a clue which code i have to change?
-
Hi MasterDKLB,
I understand what you need, tried to do it, but I couldn't figure it out.
I am quite a beginner in PHP, maybe someone with more experience will hopefully help you out.
Regards,
franci77
-
Thank you franci77 for your help, it works for me like a charm.
Thanks again
-
Hi,
Even though this code update actually works, there is a problem that the subcategories products aren't actually assigned to parent categories, and because of that if anyone noticed, you can't filter products by manufacturers.
Besides, the file got overwritten, when you updated VM.
So I found another solution. There is a plugin: http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-categories/23074
The plugin will assign all subcategory's products also to parent categories. So you will have subcategory's products also displayed when you are on parent category view. And now you can also filter them by manufacturers and you don't have to worry about the updates.
Note that product.php should be in default state. And BACKUP your database BEFORE you assign products to parent categories in case you don't like the results.
Best regards,
Franci
-
Great Post matearts ;D
-
Thanks Guys, you are all awesome!! Worked like a bomb!! Anyway do you think this could be done as an override?
Perhaps Ivus will know. Thing is there are a couple of places I cant override, like if I put this (above fix) into:
templates/my_template/html/com_virtuemart/models it doesnt do anything, I actually have to put it in the admin folder.
I also have the same problem over writing the featured products if I put the single.php file into:
templates/my_template/html/mod_virtuemart_product/ it wont override either?
I know I went a little off topic here but I would like to override the fix, anyone know where I am going wrong?
-
Maybe JHacks extension could automate such tasks (files in models folder etc), how do you think?
As for "mod_virtuemart_product" case:
what are you doing and what is going wrong?
-
HI Maxim,
To explain, If I create a featured products module, in the drop down parameters you can select which php file to use eg: single, default etc. so to do a template override, I used templates\my_template\html\mod_virtuemart_product\tmpl\singlejofeat.php, but In the module I cannot select the file that I created which is: singlejofeat.php unless I have it in modules/mod_virtuemart_product/singlejofeat.php, not ideal if I update VM, any ideas?
Regards,
Jo
-
I doubt that VM update will overwrite file like modules/mod_virtuemart_product/singlejofeat.php. Just use for 'singlejofeat.php' file enough unique filename.
Could you have 'singlejofeat.php' in modules/mod_virtuemart_product/singlejofeat.php just for fashion?
Any way instead that file another one tween in templates\my_template\html\mod_virtuemart_product\tmpl\ will be used.
-
Hi there, I have tried this and it didnt do anything when displaying in category view. My sub categories were exactly the same in its parent category page.
What I am trying to do is this layout:
Category Title
Sub Category Title
Product 1 Product 2 Product 3
Sub Category Title
Product 1 Product 2 Product 3
Ultimately this would be on the site I am working on as:
Notebook Bags
Ultrabook Bags
Product 1 Product 2 Product 3
Macbook Bags
Product 1 Product 2 Product 3
I don't want to display any products from parent category (well I won't have any there anyway :)) and the sub categories need to have their titles and products listed below. I want to display the hierarchy like this page: http://www.incipio.com/cases/iphone-cases/iphone-5-cases.html
I have also attached an image that is how I would like to have it to better explain.
Thanks :)
[attachment cleanup by admin]
-
Did you have any success with your "Only Sub-categories in Category view" thread?
-
No one except you had replied unfortunately :(
-
So what is the current status of your issue?
-
The current status is my template looks like my attached image now. But I need it to look like the my earlier attached image which is my 2nd attached image here.
The sub categories only list their picture and name. I need only the name (title) of the sub category/s to be listed in the parent category view and their products listed under each sub category title.
All I need is the parent title to be at the top, then the pagnation. Under that to be sub category titles, and under each sub-cat title is their products. As mentioned like in the link from Incipios page.
Thanks.
[attachment cleanup by admin]
-
To get rid of category images you need to edit template override.
Have you any success with adding products with this:
OK thanks I have found it that way via google. I will try altering the code to do that and inspect that thread.
?
-
getting rid of the parent category image is not the problem, I can do that.
I need this layout:
Category Title (sleeves)
1st Sub Category Title (iPad)
Product 1 Product 2 Product 3
2nd Sub Category Title (iPad mini)
Product 1 Product 2 Product 3
So far the current layout is the sub categories at the top. And they do not list any products under them.
-
Surely this is possible? Can someone please help with this?
-
Thank you much for this solution, is working like a char ;).
-
getting rid of the parent category image is not the problem, I can do that.
I need this layout:
Category Title (sleeves)
1st Sub Category Title (iPad)
Product 1 Product 2 Product 3
2nd Sub Category Title (iPad mini)
Product 1 Product 2 Product 3
So far the current layout is the sub categories at the top. And they do not list any products under them.
Did you ever achieved this?
-
Very cryptic. Is that just a statement or is it a question? Same problem as who? http://forum.virtuemart.net/index.php?topic=79799.0
-
If you want help at a bare minimum try to give full information
Does this still go for VM3?
Do u think that is a clear question? In this thread apart from totally unhelpful posts like "that worked - thanks" (what worked?) there are about 3 suggested solutions and ideas
So your questions refer to what exactly?
-
Hi GJC,
Sorry for wasting your time, the problem is no longer relevant.
I got things messed up after a long day, my fault.
-
Salam
after i do the hack i can't sort by manufacturer
any idea ???
thx
-
I just wanted to confirm that this CORE HACK still works in VM 3.0.12 on J! 3.4.5. Also it still is not possible to view manufacturers with this hack – which is only a small let-down in my case.
Why is this solution better than assigning each product to its parent category (there still is a working plugin doing that for you in VM3)? Because of SEO. With this hack you get fewer and more consistent URL to your product.
Don't know if topic is obsolete, but here is the working code for the latest version of Virtuemart.
After the setKeyWord function in \administrator\components\com_virtuemart\models\product.php place:
function untreeCat($vm_catid, &$ccont){
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$vm_catid.'"';
$db->setQuery($query);
$db->query();
$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($ccont, $row[0]);
$kat = $row[0];
$this->untreeCat($kat, $ccont);
}
}
}
Then search for this:
if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
}
... and replace it with following:
if ($virtuemart_category_id > 0){
$joinCategory = TRUE ;
$catscont = array();
$this->untreeCat($virtuemart_category_id, $catscont);
$qkat = ' `pc`.`virtuemart_category_id` IN('.$virtuemart_category_id;
foreach ($catscont as &$kat){
$qkat .= ', '.$kat;
}
$qkat .= ')';
$where[] = $qkat;
}
Best regards,
franci77
-
Hi,
This cannot be confirmed for VM 3.0.12 on Joom 3.4.5 as the product.php itself has different code:
The old if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
}
has now changed to
if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
if(true){
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
} else {
/*GJC add subcat products*/
$catmodel = VmModel::getModel ('category');
$childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);
$cats = $virtuemart_category_id;
foreach($childcats as $childcat){
$cats .= ','.$childcat->virtuemart_category_id;
}
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
}
} else if ($isSite) {
if (!VmConfig::get('show_uncat_parent_products',TRUE)) {
$joinCategory = TRUE;
$where[] = ' ((p.`product_parent_id` = "0" AND `pc`.`virtuemart_category_id` > "0") OR p.`product_parent_id` > "0") ';
}
if (!VmConfig::get('show_uncat_child_products',TRUE)) {
$joinCategory = TRUE;
$where[] = ' ((p.`product_parent_id` > "0" AND `pc`.`virtuemart_category_id` > "0") OR p.`product_parent_id` = "0") ';
}
}
Eireann75 how did you make it work?
Kind Regards
Theo
-
If you searched the forum a bit u would see that this ability is now in the core of 3.0.12
http://forum.virtuemart.net/index.php?topic=131667.msg454613
-
Not a helpful reply and the link certainly does not lead to an answer.
-
This cannot be confirmed for VM 3.0.12 on Joom 3.4.5 as the product.php itself has different code:
Simply replace the new block of code, and it will work. That solution offered in the new code doesn't load products from all sub categories, so I still prefer the old one.
-
Hi,
after "Surely this is possible? Can someone please help with this?" by Ninjab
and "Thank you much for this solution, is working like a char ;)." by Mana
but the solution is not given . can you give the solution like :
the above product to show on front end in joomla :
clicking on "+" will show the list of products as and clicking on (-) will hide .
Category Title (sleeves)
(-) 1st Sub Category Title (iPad)
----- Product 1
-----Product 2
------Product 3
(+) 2nd Sub Category Title (iPad mini)
( Product 1
Product 2
Product 3) this products will be hidden
on rollover product 1,or 2 or 3 display product information with image and clicking on product will show full content.
Thanks,
-
Does anyone got an answer ? I have the same problem :/