VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: sandomatyas on January 25, 2022, 16:39:17 PM

Title: Add stock filter to category view
Post by: sandomatyas on January 25, 2022, 16:39:17 PM
When I open a category page I can filter for manufacturer and set the ordering. Is there a method to add a new filter which shows the products currenty in stock? I'm sure it could be done with modifying the model but I was wondering if there is an other solution for that?
Title: Re: Add stock filter to category view
Post by: balai on January 25, 2022, 16:44:16 PM
Hi

There is a stock filter in Custom Filters, if you are interested.
https://breakdesigns.net/extensions/joomla/custom-filters
Title: Re: Add stock filter to category view
Post by: sandomatyas on January 25, 2022, 18:12:31 PM
Yes I know but how do you integrate it to the category layout? It has an own result page and category page has manufacturer filtering, ordering, pagination, nice url etc
Title: Re: Add stock filter to category view
Post by: GJC Web Design on January 25, 2022, 18:44:34 PM
I did it this way for a client that didn't want to modify any core and had only a few products..

In the display loop test for in stock and apply a class to the product display.
Then a bit of js and a form to show/hide that class with a hide out of stock button

the site didn't have many products and this method of course buggers up the pagination if used
Title: Re: Add stock filter to category view
Post by: pinochico on January 25, 2022, 19:12:15 PM
Quote from: sandomatyas on January 25, 2022, 18:12:31 PM
Yes I know but how do you integrate it to the category layout? It has an own result page and category page has manufacturer filtering, ordering, pagination, nice url etc

I don't understand.
Do you tried modul CFiltering == do you know demo an documentation or not?

Look at this:

https://www.kolo-park.cz/obchod/kola-a-elektrokola

Modul CF is above VM category and yes, checkbox for product in stock (Skladem) is created by custom develop

You can custom develop for core VM too, without CF, but I think is harder and why?
Title: Re: Add stock filter to category view
Post by: sandomatyas on January 26, 2022, 10:18:35 AM
yes, I use CF Filter for years, moreover I have some custom modified instances since breakdesigns isn't interested in some changes we need :)

I like your shop and template, it realy inspired me in my next projects :)

You use cf filter as a module (same way as we use it), but the customer asked to add as buttons next to the manufaturer filter, something like this: https://snipboard.io/dih5Rn.jpg
Sure, I can embed a module there, so I was just wondering if the webshop component allready has ability to show only the stocked products.
So far I see VirtueMart can't do it without 3rd party extension. No problem, just try to use core methods if it is available.
Title: Re: Add stock filter to category view
Post by: Studio 42 on January 26, 2022, 11:24:22 AM
You have this trigger in product model
      if ($this->searchplugin !== 0) {
         JPluginHelper::importPlugin('vmcustom');
         $dispatcher = JDispatcher::getInstance();
         $dispatcher->trigger('plgVmBeforeProductSearch', array(&$select, &$joinedTables, &$where, &$groupBy, &$orderBy,&$joinLang));
      }
searchplugin is set using
$this->searchplugin = vRequest::getInt ('custom_parent_id', 0);
But in wonder why ?
If the team remove the need of custom_parent_id, you can then set yourself the search query in the core
The only problem is that the $group is not send to the plugin. So the trigger sould have this parameter to know the context
$dispatcher->trigger('plgVmBeforeProductSearch', array(&$select, &$joinedTables, &$where, &$groupBy, &$orderBy,&$joinLang,$group));
Title: Re: Add stock filter to category view
Post by: sandomatyas on February 01, 2022, 08:06:47 AM
Quote from: pinochico on January 25, 2022, 19:12:15 PM
https://www.kolo-park.cz/obchod/kola-a-elektrokola

Hi
I noticed you have SEF urls for CF Filter results
https://www.kolo-park.cz/vysledky-vyhledavani/kola-a-elektrokola/skladem/akce/cena-od-8705/cena-do-67094
I've asked for this maybe a year or two back from breakdesigns but there was no core solution for that. Do you have a hint maybe how it could be done? Also like your dropdown/kind of megamenu solution for the parameters :)