News:

Looking for documentation? Take a look on our wiki

Main Menu

Filtering products that are in more categries simultaneously

Started by roby.ds, March 28, 2019, 13:00:50 PM

Previous topic - Next topic

roby.ds

Hallo... I'm facing a difficult task I'm not able to solve:
I'm creating a recipes website where every VM product is a recipe.
I need to insert for each recipe all the ingredients needed to prepear it.
Then I have to give the users the possibility to filter the recipes by their ingredients: if one want to know which recipes he can make using some specific ingredients, he have to be able to filter the recepies by the ingridients he wants.
The system should be presenting as result all the recipes that contain the selected ingredients

For now I didn't find a way to do so because I can't put all the possible ingredients in different colums in the recipes DB as "custom field" (thei are too much, growing: thay can vary in number), and also the order of the ingredients in the recipe has to be free (es. eggs can be in second position or in fourth).

I'm using "custom filter" for now

I managed to solve part of the problem creating a VM Category called "Ingredients" and under that, a subcategory for each new ingredient used; For any ingredient present in a specific recipe I associate the recipe to the ingredient subcategory (Virtuemart allow you to associate an element to more then one category).
But I discovered that any filter module I analized where you can select more then one category at the same time doesn't "filter" categories... they aggregate them !! so if I select in a category checkbox list two different categories I will not see only the products that are present in both (so products thet are present in Category 1 "AND" in Category 2) but all the products present in the two (products present in Category 1 "OR" in Category 2) ... SO ALL OF THEM!....


Can somebody suggest me a solution or a different approch?
THX

Studio 42

I wrote a tag option in my shortcode plugin, a little doc can be see here https://shop.st42.fr/en/shorcodes-english-doc#searchable
The tags can be added by import directly in the plugin using product_name, product_sku, product_gtin or  product_mpn + choosen tag title + all tags
demo search module ("filter" button on bottom) here https://pro.st42.fr/en/android.
You can select in the module, the categories to display. So only this category are displayed, but you can select more then one.

roby.ds

Didn't understand the explanation... can you be more clear?....
I tryed in to select more categories in your demo but I don't se a filtering effect.. only aggregation.
Same thing with tags.
starting with first page I selected a tag and I had 9 elements... I selected the second tag and Fom 9 I had 49...  in the filtering logic I should have a number less than 9!

... maybe I didn't do the right thing though?

Lets make an example
Product 1: Ingredients > Lemon, mint
Product 2: Ingredients > Orange, Vanilla
Product 3: Ingredients > Orange, Lemon, Vodka

If I select "Lemon" and "Orange" in the filter I need to see ONLY "Product 3"


Studio 42

SO what you want is that filter is innverted.
This need a custom dev. most shop use aggregation. for example, if you have memory 16Gb and 32 GB when you select the 2 is not possible to have results.
In your case the logic need to be inverted.
So in your case you want that only recipes having Lemon and mint as Ingredients are displayed and not Lemon or mint.
Another solution is to set 1 tag per type only; but it's not really optimised.
And a simpler solution, is to  manually set the search using keywords.
Eg you do a keywords list with checkboxes "Orange","Lemon","Vodka" and each selected words get added to the search using javascript and use a hidden input.
You add all the keywords in the short description in the same order as the list and VM should then filter correctly your products.
Note that using the last trick only work if you have the word in the same order as your list eg.
Orange, Lemon, Vodka in short desc is found using "Orange","Lemon","Vodka" in the list but not Vodka, Orange, Lemon as short desc



Ventsi Genchev

#4
Using filtering categories is not the right solution in your case. The right solution is to use only custom fields.
You want to add an infinite number of categories, provided you can add only one text in a custom field.

For example, you can make a custom "Ingredients" field and choose options for each product: Orange, Lemon, Vodka. Or you can break down ingredients by type with more custom fields.
In any case, the "Custom Filters" is the right solution.

Issue:
The custom filter only adds the selected options. It does not exclude those who do not have such value.

Solution:
It is necessary to make hardcoded changes to the component.
The goal is to be able to choose one or more custom fields that work on reverse logic. Because some fields may have to work with normal logic. This gives more filtering capabilities.

Disadvantages:
Such a complex component change is not free of charge.
After updating the component, it is necessary to re-add the changes.

I can help you, but in your long conversation with the component developer I saw that you do not want a hardcoded change. Although I do not see what scary there is in changing 2 files after every update.
Unfortunately, I do not think there is a better solution to your case.
Audio Store:
https://vsystem.bg - Bulgarian language
https://vsystem.bg/en - English

roby.ds

It is ok for me to add the modification evry time I update the component (but in de discussion it seems that after the modification the component couldn't be update again: maybe because the 2 new files couldn't be used with newer version of the component?)

Anyway I need the category solution (not the custom field one) because I need it for other website (ex. "offer" category to filter at the same time of other categories in a shop).
I cant change the way my customers want to use their management system (that create the import file):
so it is easyer for them to add a new category then make a change in their Systems

I know I need to pay (If is not too much).. but I will pay for a solution i want.. not for the best solution the programmer think is the best for me
Furdermore I'm not an english native speaker so I have my understanding problems

Ventsi Genchev

In your first post you ask: "Can somebody suggest me a solution or a different approch?".
That is why I offer you a different solution. Not through categories.

I have not read your entire discussion with the component developer because it is very long. Still, I guess he will only make some changes to 2 files. I myself would do just that, but that's just a guess.
It is best to comment on it.

And no. I'm not part of the team that develops the component (in response to a personal message). I just know the component very well because I had to make some changes.
I also use it and have a paid account. And since I have access and your ticket is public, I saw what you wrote.

Anyway. I have no more time to read and write on this topic. You asked for a different approach, and I suggested. You now explain that you want a specific thing, not a different approach.

I saw you had a deadline until the end of the day to make a decision. The choice is yours.

I wish you success!
BR
Audio Store:
https://vsystem.bg - Bulgarian language
https://vsystem.bg/en - English

roby.ds

OK.. THX
You are right .. I asked for a different approch! but unfortunatly I need something that doesn't change to much the work of my customer.
sorry if I sound aggressive (not my intention)

H.A.N.D.!
THX

Studio 42

You can perhaps only use categories as filter ?
I think that a lightweight component (or module) can be coded, because you dont have multiple filters to check.
And perhaps(an idea) is to use unpublished categories, but modify the module to display only this.
In this case you use for eg. a main category "ingredient'
The filter are all ingredients sub categories eg.
-Orange
-Lemon
-Vodka
....
This need no change for your current category structure and using VM be pro for eg. YOu can easy mass add ingredients(cateogires) to products.
Contact me if you need this solution, but in any case, this need some dev.
Regards,
Patrick