Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#735 Do not include product in search results if site has none #13638

Merged
merged 1 commit into from
Feb 26, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Feb 19, 2019

Overview

Suppress products from contribution queries where no products exist on the site.

This is mostly for performance but it does get rid of the 'Premium' column for sites that don't use it. Many people WOULD like to replace it but they have varied alternatives so hooks / future funded leap into configurability are the best place fotr that.

Before

screenshot 2019-02-19 17 27 30

After

No change if someone has purchase a product off the site & there is a db record of it - otherwise

screenshot 2019-02-19 17 28 17

Technical Details

@colemanw this turned out to be surprisingly easy due to earlier cleanup by @monishdeb & myself. Am expecting some test fails but I'll update the tests at that point

Comments

https://lab.civicrm.org/dev/core/issues/735

@civibot
Copy link

civibot bot commented Feb 19, 2019

(Standard links)

@civibot civibot bot added the master label Feb 19, 2019
@eileenmcnaughton eileenmcnaughton force-pushed the squash_products branch 5 times, most recently from c3613e8 to 761f381 Compare February 20, 2019 01:22
@eileenmcnaughton
Copy link
Contributor Author

@colemanw wanna check this? passing now

\Civi::$statics[__CLASS__]['has_products'] = (bool) CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_contribution_product LIMIT 1');
}
return \Civi::$statics[__CLASS__]['has_products'];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc for this function should contain this:

hasproduct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

Copy link
Member

@colemanw colemanw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this out on the demo site by going to Search -> Find Contributions and found a couple issues:

  • After clicking "Search" (with no criteria) I found no Premium column in the results even though a premium exists in the system (Coffee Mug).
  • I tried the search again selecting 1 search criteria: Premium = Coffee Mug. This caused an error:

Notice: Undefined index: contribution_product_id in CRM_Contribute_BAO_Query::whereClauseSingle() (line 464 of /home/jenkins/bknix-dfl/build/core-13638-6jcaq/sites/all/modules/civicrm/CRM/Contribute/BAO/Query.php).

@eileenmcnaughton
Copy link
Contributor Author

@colemanw I agree the enotice needs fixing but note that I used SELECT id FROM civicrm_contribution_product LIMIT 1 to determine if products exist - mostly because it seems lots of sites have created a product at some point & then abandoned the concept so having actually sold one seemed to show intent to me

@eileenmcnaughton
Copy link
Contributor Author

so I updated it so not show the premium field if the kitty is sad - I can update the criteria to a different table if you think it would be better - I figured it will never return results unless contribution_product has rows regardless

@eileenmcnaughton
Copy link
Contributor Author

test this please

@colemanw
Copy link
Member

That makes sense.
@civicrm-builder test this please.

@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

@colemanw does 'approved' == merge on pass?

@colemanw
Copy link
Member

Approval + cat pic = merge on pass

@colemanw colemanw merged commit be47dee into civicrm:master Feb 26, 2019
@eileenmcnaughton eileenmcnaughton deleted the squash_products branch February 26, 2019 20:27
@eileenmcnaughton
Copy link
Contributor Author

@colemanw ah now I know :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants