Drupal 7, commerce kickstart2.

Need to create a view with ContentType ProductDisplay. ProductDisplay has field Product. A Product has multiple field of a Country type.

User object has a property Country filed by IP2Country Module. The view need to show only products with user’s country.

View: type=page, link= /products (no other arguments in url expected), added releation Product

Here what I tried

  1. Created Contextual filter: "Product: Country List (indexed)". Had to add index to this field so it can be select in contextual filter
  2. Configured default argument for the "When the filter value is NOT in the URL". By using "hook_views_plugins" created "Current user's Country name" argument type. It is working and providing correct argument value - user’s country

Didn’t manage to make it work. Also, tried some other things and spent few hours browsing web for a possible solution. Didn't find any similar problems or solution. There’re many examples with taxonomy terms and url args.

As a plan B, think to create view for every country and override main view, but don't like it

Is a better solution to the task possible?


| improve this question | | | | |

Found the problem!

All I did was correct, except one thing; I choose wrong View type during creation.

wrong: selected Show "Product display"

working: choose Show "Content" of type "Product display"

Don't know the difference, but it's working

| improve this answer | | | | |

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.