-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support adjusted splitting behavior for arrays of length one #193
Comments
Thought I'd follow up on this issue and see if Greg's solution was still something you'd consider. We've been using a forked version of Scout... and that's been serving us well, but it would be really great to get back on the canonical plugin at some point. Cheers! |
Hey @joshuapease @gregkohn, thanks for putting in the work and sorry about the delay, still coming to grips with every nook and cranny of this plugin :). This is out in 2.7.0 so you should be good to switch back to the released version of the plugin now! |
Currently when splitting elements, if an element has an array of just one thing for the relevant key, that record isn't split and it gets the entire array.
https://github.com/riasvdv/craft-scout/blob/bf30a01602a4e5db45c09ce43233be7b512abba6/src/engines/Engine.php#L36-L40
This is in contrast to an element that does need to be split, where each record gets one of the array children without the wrapping array.
I'm not sure if this is a bug per se but it's giving me some grief because I can't count on the structure of the value for my split key. Any chance I'm missing something obvious? I'd be more than happy to open a PR for a setting that adjusts this behavior so there's no breaking change, but I figured I'd start a conversation first.
In my case, I'm splitting Craft Commerce products on their variants. So there is a record per variant, and variants of a product all share a
distinctID
. But products with one variant end up with it being wrapped in an array, while products with multiple variants don't, making it exceedingly difficult to manipulate and filter the data for our purposes.Minimal example:
Thanks for a great plugin!
The text was updated successfully, but these errors were encountered: