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

SQL error: Unknown column 'structureelements.lft' in 'group statement' #12

Closed dowadidi closed 5 years ago

dowadidi commented 6 years ago

After upgrading to 1.0.4 from 1.0.3 I get a db error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'structureelements.lft' in 'group statement'

In the template:

{% set ids = product.tags.ids | merge(product.category.ids) %}
{% set limitCriteria = craft.products.limit(3).with(['heroImage']) %}
{% set similarProductsByTagsAndCategories = craft.similar.find({ element: product, context: ids, criteria: limitCriteria }) %}
svale commented 6 years ago

Sorry @DiederikVanHoorebeke, this is my bad: I submitted a PR without testing with Commerce Products... Please see #13 for a possible quick fix.

dowadidi commented 6 years ago

@svale The quick fix works. :-)

JayBox325 commented 5 years ago

I'm getting this exact same issue when getting products, @DiederikVanHoorebeke.

I am on the latest version of the plugin though so I'd have thought this merge back in October would have resolved it. (@svale)

svale commented 5 years ago

The PR that resolves the issue for products is still open, but see see approx line 141 for the actual (very simple) patch.

As I understand it, Craft 3 itself has dropped GROUP BY (the sinner in this case) in its data queries, so maybe @khalwat have plans for a some more re-factoring than this fix - but I wouldn't know :)

khalwat commented 5 years ago

Yeah I just haven't had the time to fully vette the PR, and ensure it isn't creating other unexpected issues.

Still I'll give the PR a go and see if we can't get it out there.

khalwat commented 5 years ago

Merged the PR and published the release as 1.0.5: https://github.com/nystudio107/craft-similar/releases/tag/1.0.5

Thanks again @svale !