Page 1 of 1

Code for Alert when there are reviews to approve

Posted: Thu Jan 31, 2008 4:14 pm
by compunerdy
I would like to get a alert for when there are reviews to approve.

definately

Posted: Fri Feb 01, 2008 4:28 am
by troutlet
I agree, this really should be there. An email would be great. A notice or alert on the Dashboard might work fine too.

Posted: Wed Mar 19, 2008 1:27 am
by m_plugables

Code: Select all

if (store.Settings.ProductReviewEnabled != CommerceBuilder.Users.UserAuthFilter.None) 
            {
                ProductReviewCollection unaprovedReviews = ProductReviewDataSource.LoadUnApprovedReviews();
                if (unaprovedReviews.Count > 0)
                {
                    string alertText = "You have ({0}) unaproved review{1}.";
                    string tempValue = (unaprovedReviews.Count > 1) ? "s" : string.Empty; 
                    alertList.Add(string.Format(alertText, unaprovedReviews.Count,tempValue));    
                }
            }
place the above code in Admin/Dashboard/AdminAlerts.ascx file just above the following comment
//UPDATE CACHE

for example the code will be placed at location like

// customized code provided in this post will be here just before the update cache code
//UPDATE CACHE

very nice

Posted: Wed Mar 19, 2008 2:39 am
by troutlet
Sweet! That worked like a charm. Thank you for that.

Posted: Wed Mar 19, 2008 8:12 am
by compunerdy
Edit AdminAlerts.ascx.cs not AdminAlerts.ascx

Thanks for the code!!

Re:

Posted: Mon Jul 21, 2008 3:59 pm
by Robbie@FireFold
mazhar_plugables wrote:

Code: Select all

if (store.Settings.ProductReviewEnabled != CommerceBuilder.Users.UserAuthFilter.None) 
            {
                ProductReviewCollection unaprovedReviews = ProductReviewDataSource.LoadUnApprovedReviews();
                if (unaprovedReviews.Count > 0)
                {
                    string alertText = "You have ({0}) unaproved review{1}.";
                    string tempValue = (unaprovedReviews.Count > 1) ? "s" : string.Empty; 
                    alertList.Add(string.Format(alertText, unaprovedReviews.Count,tempValue));    
                }
            }
place the above code in Admin/Dashboard/AdminAlerts.ascx file just above the following comment
//UPDATE CACHE

for example the code will be placed at location like

// customized code provided in this post will be here just before the update cache code
//UPDATE CACHE
I put this code in correctly - only to get the front page to error.

I'm on the final release. This would be a good feature for me. Any code need to change?

Re: Code for Alert when there are reviews to approve

Posted: Tue Jul 22, 2008 11:20 am
by Robbie@FireFold
I must have been doing something wrong. I retried this today.

Flawless.

Re: Code for Alert when there are reviews to approve

Posted: Mon Jan 07, 2013 3:52 pm
by efficiondave
Huge help. Thanks! A couple minor tweaks in the code below:
1. Fixed typo "unaproved"
2. Made "Unapproved Review" a link to the Reviews page
3. Added a Comment

Code: Select all

			// LOOK FOR UNAPPROVED REVIEWS
			if (store.Settings.ProductReviewEnabled != CommerceBuilder.Users.UserAuthFilter.None)
            {
                ProductReviewCollection unaprovedReviews = ProductReviewDataSource.LoadUnApprovedReviews();
                if (unaprovedReviews.Count > 0)
                {
                    string alertText = "You have ({0}) <a href='/Admin/Products/Reviews/Default.aspx'>unapproved review{1}</a>.";
                    string tempValue = (unaprovedReviews.Count > 1) ? "s" : string.Empty;
                    alertList.Add(string.Format(alertText, unaprovedReviews.Count,tempValue));   
                }
            }
I also put the code higher up in the alert list so it's seen more easily. I put it above the "//CHECK FOR LOW INVENTORY PRODUCTS" section but it's easy to move it to wherever you like in the list.

Re: Code for Alert when there are reviews to approve

Posted: Fri Oct 16, 2015 9:35 am
by compunerdy
Anyone know how to make this work for GOLD?

Re: Code for Alert when there are reviews to approve

Posted: Wed Oct 21, 2015 12:23 am
by mazhar
Just two small changes and it should work great on Gold. The updated version of Daveid's code should be like this

Code: Select all

// LOOK FOR UNAPPROVED REVIEWS
            if (AbleContext.Current.Store.Settings.ProductReviewEnabled != CommerceBuilder.Users.UserAuthFilter.None)
            {
                IList<ProductReview> unaprovedReviews = ProductReviewDataSource.Search(0, BitFieldState.False);
                if (unaprovedReviews.Count > 0)
                {
                    string alertText = "You have ({0}) <a href='/Admin/Products/Reviews/Default.aspx'>unapproved review{1}</a>.";
                    string tempValue = (unaprovedReviews.Count > 1) ? "s" : string.Empty;
                    alertList.Add(string.Format(alertText, unaprovedReviews.Count, tempValue));
                }
            }
We have tried to keep it easy to upgrade AC7 codes to gold and I have posted some tips here viewtopic.php?f=47&t=17108 You can read the common things you may need to update in any AC7 script.

Re: Code for Alert when there are reviews to approve

Posted: Wed Oct 21, 2015 5:19 am
by compunerdy
Works great thanks