Closed jamiewhitemccann closed 3 years ago
Fixed in https://github.com/nystudio107/craft-similar/commit/0d81f2f27cb698c469aefce68ad76379153ced0d
You can try it now by setting your semver in your composer.json
to look like this:
"nystudio107/craft-similar": "dev-develop as 1.1.1”,
Then do a composer update
Thank you very much Andrew!
Regards, Jamie
[signature_1389440161]
Jamie White Technical Lead McCann, Tower Wharf, Cheese Lane, Bristol, BS2 0JJ 0117 921 8102 www.mccannbristol.co.ukhttp://www.mccannbristol.co.uk/
From: Andrew Welch notifications@github.com Reply to: nystudio107/craft-similar reply@reply.github.com Date: Wednesday, 10 March 2021 at 04:08 To: nystudio107/craft-similar craft-similar@noreply.github.com Cc: Jamie White Jamie.White@mccann.com, Author author@noreply.github.com Subject: [EXTERNAL] Re: [nystudio107/craft-similar] $similarCounts not sanity checked on line 162 of src/services/Similar.php (#29)
You can try it now by setting your semver in your composer.json to look like this:
"nystudio107/craft-similar": "dev-develop as 1.1.1”,
Then do a composer update
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/nystudio107/craft-similar/issues/29*issuecomment-794840694__;Iw!!N96JrnIq8IfO5w!ynyHQa5FUriURbaC9hHCIw7WCgPfOwkMOhzyOoXzHCZMwushDLQkSDdB8Hxe2M0ZzA$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AEKX6EA75RDFFTD7MPJCL2TTC3PCBANCNFSM4Y4AE7KQ__;!!N96JrnIq8IfO5w!ynyHQa5FUriURbaC9hHCIw7WCgPfOwkMOhzyOoXzHCZMwushDLQkSDdB8HyDDPHOhQ$.
This message contains information which may be confidential and privileged. Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail, and delete the message. Thank you very much.
Hi,
I was receiving the same error and set my semver and updated with fix. It works as expected when I've assigned tags to a product, but when there are no tags assigned it now show products that aren't tagged similarly. It used to show nothing, but now with the update it shows the most recently added products.
Here's how I'm calling them:
{% set limitCriteria = craft.products.limit(20) %}
{% set similarEntriesByTags = craft.similar.find({ element: product, context: product.recommendationTags, criteria: limitCriteria }) %}
...
{% for similarEntry in similarEntriesByTags %}
...
{% endfor %}
I'm wondering if I'm doing something wrong here? Thanks!
My college has opened this ticket, which I think is actually the root cause of the error firing in the first place:
This issue is fixed in 1.1.1, which is released. https://github.com/nystudio107/craft-similar/releases/tag/1.1.1
@solutiondrop If you have a separate issue, please file a new issue. Might be related to: https://github.com/nystudio107/craft-similar/issues/31
Describe the bug
2021-03-09 10:58:03 [-][3][de99c010b4cfe6c82fedeef4c2b2ddb0][error][yii\base\ErrorException:8] yii\base\ErrorException: Undefined index: 1-175221 in /app/vendor/nystudio107/craft-similar/src/services/Similar.php:162
To reproduce
We are seeing fatal errors when using this plugin, although we are not 100% on the exact scenario to recreate.
Expected behaviour
The plugin should not throw error exceptions in this manner
Versions
Suggested patch to sanity check the $similarCounts array using a simple isset on the index: