Filtering PHP SDK



I’m using the php sdk and doing a filter on the product slug

$item = $moltin->products->filter(['eq' => ['slug' => $productslug]])->all()->data();

But I’m getting all products containing the slug eg
all slugs containing the word “vase” in for example but I want just the exact match of the slug
Is there a way to do an exact match only?



Hi @greenlightpete :wave:

As far as I can see it should work as expected according to the API reference and SDK docs.

One of our engineers @andrew should be able to identify if there would ever be a case this wouldn’t occur.

I don’t imagine you are but there is no change to the SDK once you’re importing, such as extending the products class and filter functions?



Hi @greenlightpete - can you give me an example of a slug you are matching against?

We suspect that you may have spaces in your slugs (when really they should have spaces replaced with -).

Can you confirm for us?




arrrrr yes found the issue
a variation product had some dashes and then spaces in instead of all dashes in it so must be that
I’ll make the relevant changes to my import script and make sure always dashes then should be all ok

Thanks @andrew


No problem, glad it’s behaving itself now :smile:

We’re going to add some validation to try and prevent this from happening by default.




This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.