2

I have a very strange problem with the Views and Drupal Commerce. I would like a list of products and their prices, but in the view - and ONLY in the view, the price is hidden for anonymous users. I can see it when I am logged in, and if I go to the actual product page it is showing for all users, just not on the view! STRANGE! I've made sure that anonymous users can access the checkout, which they can.

enter image description here

enter image description here

I'm using

  • Drupal 7.54
  • Drupal Commerce 7x 1.13
  • Views 7x 3.14

The view is pulling in the price through fields

  • Content: Product
  • formatter: Rendered Product
  • View Mode: Content: Teaser (also tried Commerce Product: Content: Teaser)

If I add a relationship it looks fine when logged in but the whole view completely disappears when not logged in.

I've never run into this issue with views before and I've done quite a few e-commerce sites. I assume that this is a permission problem somewhere, but I can't seem to find it and I'm feeling completely stupid for not being able to trouble shoot this. Can anyone give me any hints?

5
  • Do you have the field permissions module installed?
    – Clive
    Commented Feb 17, 2017 at 20:30
  • No, I don't have any other permission modules other then what came with core. Commented Feb 17, 2017 at 20:31
  • 1
    Do anonymous users have the "view any product" or something else appropriate permission enabled?
    – Clive
    Commented Feb 17, 2017 at 20:35
  • Ooooooh so I just added "View any product of any type" to Anonymous users and it worked but it says "Warning: Give to trusted roles only; this permission has security implications." That's why I've left it off so far... Commented Feb 17, 2017 at 20:38
  • i don't have a commerce site to hand to check, but I'm pretty sure this is the monumental issue covering the problem you have
    – Clive
    Commented Feb 17, 2017 at 20:56

1 Answer 1

3

A first possible solution is to give the "View any product of any type" permissions to anonymous. Here is a relevant screenprint about it:

enter image description here

Another solution is to disable SQL rewriting within the Advanced > SQL Settings section of the view. This can have security implications if your using contextual or exposed filters. So make sure that your filters or contextual filters (i.e. relationships) are properly limiting access.

For more info, refer to comment nr 5 or comment nr 6 of the issue about "Views results empty for unprivileged user when using Relationship: Content: Referenced Product"

2
  • 1
    Indeed, disabling SQL rewriting is almost always the solution. Just ensure that your filters or contextual filters (i.e. relationships) are properly limiting access and you'll be fine. In most product cases, it's the nodes that you need to concern yourself with re: access while product access will then be mediated through those nodes' product reference field values. Commented Feb 18, 2017 at 21:51
  • Hm, a confirmation from somebody who must know for sure ... merci @RyanSzrama ! Commented Feb 18, 2017 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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