News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

VirtueMart is not Filtering Products Correctly

Started by sohopros, May 12, 2022, 20:29:53 PM

Previous topic - Next topic

sohopros

Joomla! v3.10.9
VirtueMart v4.0.0

When we log into our site Administrator area for Virtuemart Products, we see the correct number of products. When we interact with the filter system, we can only see a small number of unpublished products. After this, we cannot view any published products. This makes it impossible to edit the products on our site. Clearing our session cookie and logging in again is the only way to see any products (the ones on the first page).

Is this a known issue? is there a fix?
thank you,

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

sohopros

#2
Yes. We updated to VM 4.0.2 but still have the same problem

sandomatyas

same issue in 4.0.2
It might related to the category filter.
In VirtueMartModelProduct.sortSearchListQuery() there is a code part:
if (!empty($virtuemart_category_id )) {
$joinCategory = TRUE;

When I dump $virtuemart_category_id it's
Array
(
    [0] => 0
)

So it might get's the first level categories because my query is like this:

SELECT SQL_CALC_FOUND_ROWS  p.`virtuemart_product_id`, l.product_name, l.slug, l.product_s_desc
FROM `#__virtuemart_products` as p   
LEFT JOIN `#__virtuemart_products_en_gb` as l ON l.`virtuemart_product_id` = p.`virtuemart_product_id`
LEFT JOIN `#__virtuemart_product_categories` as pc ON p.`virtuemart_product_id` = `pc`.`virtuemart_product_id` 
LEFT JOIN `#__virtuemart_categories_en_gb` as cl ON cl.`virtuemart_category_id` = `pc`.`virtuemart_category_id`
LEFT JOIN `#__virtuemart_product_manufacturers` ON p.`virtuemart_product_id` = `#__virtuemart_product_manufacturers`.`virtuemart_product_id` 
LEFT JOIN `#__virtuemart_manufacturers_en_gb` as m ON m.`virtuemart_manufacturer_id` = `#__virtuemart_product_manufacturers`.`virtuemart_manufacturer_id`
WHERE ((l.`product_name` LIKE "%foo%" OR `p`.product_sku LIKE "%foo%" OR l.`slug` LIKE "%foo%" OR l.`product_s_desc` LIKE "%foo%" OR `l`.`metadesc` LIKE "%foo%" OR `p`.product_mpn LIKE "%foo%" OR `category_name` LIKE "%foo%" OR `category_description` LIKE "%foo%" OR `mf_name` LIKE "%foo%")
AND  `pc`.`virtuemart_category_id` IN (402,379,228,224,297,261,251,338,218,385,274,291,330,221,256,369,300,329,239,287,214,312,216,326,242,317,408,324,226,237,259,232,212,306,266,276,347,230,0) )
group by p.`virtuemart_product_id`
group by p.`virtuemart_product_id`
ORDER BY p.`created_on` DESC, p.`virtuemart_product_id` DESC


I put a simple $virtuemart_category_id = array_filter($virtuemart_category_id); before if (!empty($virtuemart_category_id )) { and it solved the problem temporarly

GJC Web Design

this was an unintended consequence of the setting "Show products of subcategories"

This is only intended to be used on the Frontend and only recently has there been a non hidden config for this which I guess is why it has only been found.

the fix is done for the next release but in the meantime u can patch with administrator\components\com_virtuemart\models\product.php ~ line 559

new code should be

if(VmConfig::get('show_subcat_products',false) and $isSite){
$catmodel = VmModel::getModel ('category');
$cats = '';
foreach($virtuemart_category_id as $catId){
$childcats = $catmodel->getChildCategoryList(1, $catId,null, null, true);
foreach($childcats as $k=>$childcat){
if(!empty($childcat->virtuemart_category_id)){
$cats .= $childcat->virtuemart_category_id .',';
}
}
$cats .= $catId;
}
$cats = trim($cats,',');
} else {
$cats = implode(',', $virtuemart_category_id);
}


and $isSite has been added
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation