J!3.8.12
VM: 3.2.14
Hi guys..
First of all, i dont know if this is a bug or a feature of virtuemart.
My problem is this:
Im using a layout of mod_virtuemart_category (template override) to show all categories and their products in a sidebar. This works great, gives good overview of page and everything. Today i wanted to add search functionality because sometimes it can be nice to actually search for something. The problem is however that the search functionality sets some INTERNAL fields in the VM objects that means that my product $ids in sidebar is collapsed to only show products that is fits the search keywords.
Im using this code in mod_virtuemart_category
foreach ($categories as $category) {
$active_menu = '';
$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
// $nemprint_products = $productModel->getProductsInCategory ($category->virtuemart_category_id); // my first try that actually works WITHOUT search functionality
// $nemprint_products = $productModel->getProductListing(TRUE, FALSE,TRUE, TRUE,FALSE, TRUE, $category->virtuemart_category_id, FALSE, 0); // when studying getProuctsInCategory I Found This Function
$nemprint_products = $productModel->sortSearchListQuery (FALSE, $category->virtuemart_category_id, FALSE, FALSE); // // when studying getSearchListQuery i found this function
// var_dump($nemprint_products);
$cattext = $category->category_name;
//if ($active_category_id == $category->virtuemart_category_id) $active_menu = 'class="active"';
if (in_array( $category->virtuemart_category_id, $parentCategories)) $active_menu = 'active';
}
So the question is... am i doing something wrong?
Should i code my own module to make sure that i have a "clean" search query
Thanks
Wel
just one parameter in sortSerachListQuery is a problem
Quote from: welrachid on September 17, 2018, 11:06:46 AM
foreach ($categories as $category) {
$active_menu = '';
$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
$nemprint_products = $productModel->sortSearchListQuery (FALSE, $category->virtuemart_category_id, FALSE, FALSE); // // when studying getSearchListQuery i found this function
[/quote]
Just use for this $category->virtuemart_category_id just 0.
Hi Milbo
Thanks for your time. That doesnt make sense, but i tried it anyway. all categories are empty.
see result here: https://prnt.sc/kw8zi0
What i want to achive is this: https://prnt.sc/kw907j
This is only possible if i iterate over all categories and then fetch products from within each category. Thats why i dont think $category->virtuemart_category_id = 0 makes sense in this case.
It seems like there is some internal thing going on that sets some filters up that i cannot bypass in any of the calls i make.. ??
Quote from: welrachid on September 19, 2018, 16:06:44 PM
Thats why i dont think $category->virtuemart_category_id = 0 makes sense in this case.
It seems like there is some internal thing going on that sets some filters up that i cannot bypass in any of the calls i make.. ??
category id = 0 means "all" categories. 0 is the root.
Hi Milbo.
Thanks for your time. I gave up.
For everyone else that might have the same problem as me. I just made my own calls to the db. This might be more expensive, but i've already spent too much time with this small issue.
foreach ($categories as $category) {
$active_menu = '';
$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
// $nemprint_products = $productModel->getProductsInCategory ($category->virtuemart_category_id);
$wsy_query = $wsy_db->getQuery(true);
$wsy_query->select($wsy_db->quoteName(array('virtuemart_product_id')));
$wsy_query->from($wsy_db->quoteName('#__virtuemart_product_categories'));
$wsy_query->where($wsy_db->quoteName('virtuemart_category_id') . '='. $wsy_db->quote($category->virtuemart_category_id));
$wsy_query->order('ordering ASC');
$wsy_db->setQuery($wsy_query);
$nemprint_product_ids = $wsy_db->loadObjectList();
$nemprint_products = array();
foreach($nemprint_product_ids as $nemprint_product_id){
$nemprint_products[] = $productModel->getProduct ($nemprint_product_id->virtuemart_product_id, TRUE, TRUE, TRUE, 1,0);
}
$cattext = $category->category_name;
//if ($active_category_id == $category->virtuemart_category_id) $active_menu = 'class="active"';
if (in_array( $category->virtuemart_category_id, $parentCategories)) $active_menu = 'active';
}
/Wel