1

I am trying to filter products by brands, which have been inputed into a text field in Drupal Commerce and indexed.

If I try for instance "Breitling" in the contextual filter it works perfectly and I can see the correct products shown in the Views preview. I am using PHP code for the contextual filter. So as a test I just used the following in the contextual field and it does not work (I have tried both options for using the contextual field)

    return "Breitling";

What I do get is no results.

1

I think it's because the value that you put into the Views preview will just be a value to pass to the PHP code. So if you enter return "Breitling", your code is going to try and find a brand named 'return "Breitling"'.

If you just need to return all results from the brand Breitling for testing purposes, in your PHP code in the contextual filter, set the value to look for as "Breitling".

Let me know how you get on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.