VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Cococoder on December 04, 2020, 11:38:36 AM

Title: Only last child category products are shown in the top category view front end
Post by: Cococoder on December 04, 2020, 11:38:36 AM
PHP 7.3.2
Virtuemart 3.8.6
Joomla 3.9.3

Issue: Only the product of the last child category are shown when browsing any top level category in the front end.
Ex: Top category "Chairs". Subcategories: "Wooden chairs", "metal chairs", "Plastic chairs". Only the product in the sub categories "plastic chairs" are displayed when viewing the "chairs" category. Product in the "chairs" category are also displayed but not the product in the two other subcateogries. 
Expected behavior: All products from all child category for a given category should be shown when "Show products of subcategories" is enabled.
tested with default template vmbeez3, all plugins disabled -> issue persists
Same issue on two sites (production and test site).


Title: Re: Only last child category products are shown in the top category view front end
Post by: Phoenix616 on December 10, 2020, 15:22:25 PM
I am experiencing the same issue on the same Virtuemart and Joomla versions.


I looked into the code and found the cause for this. The error is due to this change (https://dev.virtuemart.net/projects/virtuemart/repository/diff/trunk/virtuemart/administrator/components/com_virtuemart/models/product.php?utf8=%E2%9C%93&rev=10367&rev_to=10331) which resulted in the child categories no longer being appended on line 470 (https://dev.virtuemart.net/projects/virtuemart/repository/entry/trunk/virtuemart/administrator/components/com_virtuemart/models/product.php#L470) but $cats being set to only the last child category. Using $cats .= $childcat->virtuemart_category_id .','; (with a .= to append) similarly to the previous version instead solves the issue.
Title: Re: Only last child category products are shown in the top category view front end
Post by: jenkinhill on December 10, 2020, 15:49:46 PM
That correction is already included in com_virtuemart.3.8.7.10374 and subsequent test versions.
Title: Re: Only last child category products are shown in the top category view front end
Post by: Cococoder on January 08, 2021, 10:57:58 AM
Yep thanks.  I followed up with another thread about this issue.