Tagger icon indicating copy to clipboard operation
Tagger copied to clipboard

matchAllGroups option

Open pyrographics opened this issue 9 years ago • 9 comments

I suggest an additional TaggerGetResourcesWhere option that would match all groups. This would allow it to be better used for catalog sorting options when sorting separately by types, manufacturers or whatever product options. The where clause would be something like:

WHERE (Type = A OR Type = B) AND (Manufacturer = C OR Manufacturer = D) AND (Color = Red OR Color = White)

pyrographics avatar Apr 17 '15 20:04 pyrographics

Not sure why is better to match all? For the WHERE you mentioned you can construct URL /type/A/B/manufacturer/C/D/color/Red/White

theboxer avatar Apr 20 '15 08:04 theboxer

What we want it to do is to narrow the results when selecting different groups but expand the results when selecting multiple tags within a single group. We are trying to use Tagger's TaggergetResourcesWhere to provide no-refresh product filtering using pdoResources, Tagger and Ajax. Say a user wants to find red and green items only from Acme, there is no way I can find to do it with the current methods.

With matchAll on: WHERE Type = A AND Type = B AND Manufacturer = C AND Manufacturer = D AND Color = Red AND Color = White

With matchAll off: WHERE Type = A OR Type = B OR Manufacturer = C OR Manufacturer = D OR Color = Red OR Color = White

pyrographics avatar Apr 20 '15 17:04 pyrographics

Here is our site that may better demonstrate. http://www.prevailingarms.com/rifles/ Checking a checkbox inside each box should add to the list but not add any items disqualified by what is checked in another box.

pyrographics avatar Apr 20 '15 17:04 pyrographics

Are you talking about this param https://github.com/modxcms/Tagger/blob/master/core/components/tagger/elements/snippets/taggergetrelatedwhere.snippet.php#L26 ?

theboxer avatar Apr 20 '15 17:04 theboxer

Same parameter name but in this snippet: https://github.com/modxcms/Tagger/blob/master/core/components/tagger/elements/snippets/taggergetresourceswhere.snippet.php#L16

pyrographics avatar Apr 20 '15 17:04 pyrographics

here you go: https://github.com/modxcms/Tagger/blob/master/core/components/tagger/elements/snippets/taggergetresourceswhere.snippet.php#L16

theboxer avatar Apr 20 '15 17:04 theboxer

To achieve the results we seek, we need OR within each group of tags and AND between the groups. The current matchAll doesn't take groups into account.

pyrographics avatar Apr 20 '15 18:04 pyrographics

Yes, i think this would be good as well.

In my example, i have a catalogue where i put all products. Then they are able to add the following groups: States, Colors, Product Category, Collection

Their product could exist in one or many states. In one or many colors. In one or many Categories. In one or many collections.

  1. We would like the end user to first select a state they are interested in. So they chose California.

  2. Then the user would like to see products in California within the summer collection.

  3. The user would then like to see t-shirts within the summer collection in California.

  4. They also wanna see pants. So they select pants.

But this is where I can't seem to get tagger to work out of the box since to be able to show both pants and t-shirts within the summer collection in California the pants and t-shirt products must both be tagged as t-shirts and pants.

This is by using matchAll. If we don't use matchAll, then it would show all pants and t-shirts within all collections and all states. Which is not what we want.

So we currently sorted it by our own xpdo queries. But if it could be solved with some improvements to the TaggerGetResourcesWhere snippet it would be great.

If this can be achieved then i am sorry, because i must have missed it.

ghost avatar Mar 05 '16 15:03 ghost

I'm going to add a request for this myself. I have exactly this same problem right now. Are there any solutions since.... 2016?

robcarey avatar Jun 06 '20 18:06 robcarey