2

I am wondering if there is a way to do the following.

I need to alter view return data and either remove entries or keep entires based upon running some PHP.

Is there any easy way to do that? I was looking at the theme stuff, but that would mean I would nuke my pagination, is there anyway I could remove results but regenerate my pagination.

Sorry if this is confusing...

Edit: It's a little difficult to explain, but I am using Commerce. And I need to get a list of discounted products. But commerce only discounts products before they are displayed (ie there is no database I can join/where on to get discounted products). So I need to get all the products, then remove those that are not discounts.

  • If you're using a pager you'll need to do the alter at the query level (hook_views_query_alter()) otherwise things will go lopsided. If not, you can probably get away with hook_views_pre_render(), but it kind of depends exactly what you need to change and when – Clive Mar 27 '14 at 18:40
  • It's a little difficult to explain, but I am using Commerce. And I need to get a list of discounted products. But commerce only discounts products before they are displayed (ie there is no database I can join/where on to get discounted products). So I need to get all the products, then remove those that are not discounts. – Steven Mar 27 '14 at 18:42
  • Totally clear; that an interesting problem. I guess the discounts are applied by a rule? – Clive Mar 27 '14 at 18:43
  • Yes they are applied via Rules. – Steven Mar 27 '14 at 18:44
  • Looks like others are working on it: drupal.org/node/1020050. There are a couple of patches to try there, or perhaps get a starting point from – Clive Mar 27 '14 at 18:52
0

You can use hook_views_data to alter view data like Commerce discounted products. As suggested by Clive, here is the patch which is implementing related feature:

Other hooks to consider which can allow to alter the views data are:

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.