Im trying to figure out how to make a views block that gives me the top 5 products sales visible to anonymous users. This views need a filter 'orders status completed' (at least as i see the way it should work) and unless I give anonymous users the 'View any Order order' permission (which has security implications) they dont get the expected results. So if anyone knows a way via Views UI or programatically to get this one working i'll be gratefull for your thoughts.

Comments

liupascal’s picture

Try the following,
There is an option in views to not take into account permissions when running the query (dunno if it is on the query level or display level though)

Edit your view > Right column "Advanced" > Query settings : check "Disable Query Rewritting"
--> Disabling SQL rewriting will disable node_access checks as well as other modules that implement hook_query_alter().

It worked for me.

EndEd’s picture

thanks for the tip liupascal :)

liupascal’s picture

Status:Active» Closed (fixed)

Anytime :-)

Zorin 007’s picture

Category:support» bug
Status:Closed (fixed)» Needs review

Disabling Query Rewriting worked for me too but I don't think we should close the case, maybe moving it to a different category? Reason is everything worked ok with query rewriting enabled before update.

rszrama’s picture

Category:bug» support
Status:Needs review» Closed (fixed)

There are other open issues dealing with this stuff in relation to Views, so I don't think we need to reopen / recategorize this one. Another issue pointed out that something has changed inside Views itself, so it will most likely be a documentation issue for Commerce.

leroyg’s picture

Good point rszrama I'll keep you posted

3rdLOF’s picture

subscribing

quantos’s picture

Hi rszrama. Can I enquire why this one is closed? So far as I know the sql rewrite/related products type issue is ongoing?

But if the issue has been resolved or the discussion still going on is there a link you could place in here for us? This ticket is referenced from lots of other tickets, for example, but I can't see any that have a better fix than disabling sql rewriting (with that security issue - whatever that exactly is too).

It would be great to know where this issue is being followed through and where/when a proper fix might materialise.

Thanks.

Colin

batigol’s picture

Status:Closed (fixed)» Closed (duplicate)
quantos’s picture

Many thanks.

faclab’s picture

I banged my head on the keyboard about this one for a bit. Your instructions worked.

Thanks, liupascal.

GaneshKumar’s picture

Thanks liupascal,
Your idea works for me when i use Drupal Commerce + quicktabs + Views altogether.

aryaalvenkar’s picture

thanks a lot..u made my day... :)

jamuy’s picture

Buenas, en mi caso, despues de varias pruebas. Agregue que el usuario anonimo puede ver cualquier producto de cualquier tipo y así funcionó.

Si solo pongo el tipo de producto involucrado en la consulta, no funciona. Idem para los demás roles que tengo creados.

Saludos.

anodenymous’s picture

thanks liupascal perfecto #1

ttwhyz’s picture

Thanks!!! This worked for me as well. Is anyone worried about the warning message.

WARNING: Disabling SQL rewriting means that node access security is disabled. This may allow users to see data they should not be able to see if your view is misconfigured. Please use this option only if you understand and accept this security risk.

ttwhyz’s picture

Issue summary:View changes

my english is baaad

Avi.Kumar’s picture

Issue summary:View changes

Giving Permissions to Anonymous User to:
View any product of any type
Warning: Give to trusted roles only; this permission has security implications.
Seems to fix this problem problem more cleanly, without explicitly searching through all Views and changing setting there.