algolia / algoliasearch-client-php

⚡️ A fully-featured and blazing-fast PHP API client to interact with Algolia.
https://www.algolia.com/doc/api-client/php/getting-started/
MIT License
671 stars 116 forks source link

TypeError: Cannot access offset of type string on string #690

Closed ImJustToNy closed 2 years ago

ImJustToNy commented 2 years ago

Description

When you try to use RecommendedClilent()->getRelatedProducts() it throws an error. image

Steps To Reproduce

RecommendClient::create('foo', 'bar', 'baz')->getRelatedProducts([ 'indexName' => 'example', 'objectID' => '5' ])

DevinCodes commented 2 years ago

Hi @ImJustToNy , Thank you for reporting this.

The parameter to getRelatedProducts should be an array of arrays, can you check with the following code, please?

RecommendClient::create('foo', 'bar', 'baz')->getRelatedProducts([[ 'indexName' => 'example', 'objectID' => '5' ]]);

Thank you in advance!

ImJustToNy commented 2 years ago

Oh! My bad. Thank you for your help, it works just fine now.