nystudio107 / craft-similar

Similar for Craft lets you find elements, Entries, Categories, Commerce Products, etc, that are similar, based on... other related elements.
https://nystudio107.com/
MIT License
26 stars 5 forks source link

Error when using orderBy('RAND()') as criteria #32

Closed ryanfoote closed 3 years ago

ryanfoote commented 3 years ago

Describe the bug

When orderBy('RAND()') is used as a criteria, Craft produces the following error:

Array to string conversion

To reproduce

Apply orderBy('RAND()') to the criteria, like so:

{% set queryCriteria = craft.entries.limit(1).orderBy('RAND()') %}
{% set relatedContent = craft.similar.find({element: entry, context: entry.category, criteria: queryCriteria}) %}

Expected behaviour

That the plugin would return a randomized set of entries.

Screenshots

Screen Shot 2021-03-23 at 4 49 41 PM

Versions

khalwat commented 3 years ago

Fixed in https://github.com/nystudio107/craft-similar/releases/tag/1.1.3