Code for Alert when there are reviews to approve

This forum is where we'll mirror posts that are of value to the community so they may be more easily found.
Post Reply
User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1274
Joined: Sun Nov 18, 2007 3:55 pm

Code for Alert when there are reviews to approve

Post by compunerdy » Thu Jan 31, 2008 4:14 pm

I would like to get a alert for when there are reviews to approve.

User avatar
troutlet
Lieutenant (LT)
Lieutenant (LT)
Posts: 77
Joined: Mon Sep 24, 2007 3:01 am
Location: USA
Contact:

definately

Post by troutlet » Fri Feb 01, 2008 4:28 am

I agree, this really should be there. An email would be great. A notice or alert on the Dashboard might work fine too.

User avatar
m_plugables
Commander (CMDR)
Commander (CMDR)
Posts: 149
Joined: Tue Mar 11, 2008 12:44 am
Contact:

Post by m_plugables » Wed Mar 19, 2008 1:27 am

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

User avatar
troutlet
Lieutenant (LT)
Lieutenant (LT)
Posts: 77
Joined: Mon Sep 24, 2007 3:01 am
Location: USA
Contact:

very nice

Post by troutlet » Wed Mar 19, 2008 2:39 am

Sweet! That worked like a charm. Thank you for that.

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1274
Joined: Sun Nov 18, 2007 3:55 pm

Post by compunerdy » Wed Mar 19, 2008 8:12 am

Edit AdminAlerts.ascx.cs not AdminAlerts.ascx

Thanks for the code!!

Robbie@FireFold
Commodore (COMO)
Commodore (COMO)
Posts: 433
Joined: Wed May 28, 2008 9:42 am
Location: Concord, NC
Contact:

Re:

Post by Robbie@FireFold » Mon Jul 21, 2008 3:59 pm

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?
Robbie Hodge
General Manager
Robbie@FireFold.com
http://www.FireFold.com

Robbie@FireFold
Commodore (COMO)
Commodore (COMO)
Posts: 433
Joined: Wed May 28, 2008 9:42 am
Location: Concord, NC
Contact:

Re: Code for Alert when there are reviews to approve

Post by Robbie@FireFold » Tue Jul 22, 2008 11:20 am

I must have been doing something wrong. I retried this today.

Flawless.
Robbie Hodge
General Manager
Robbie@FireFold.com
http://www.FireFold.com

User avatar
efficiondave
Commander (CMDR)
Commander (CMDR)
Posts: 151
Joined: Tue Dec 02, 2008 10:20 am
Location: St. Louis Missouri
Contact:

Re: Code for Alert when there are reviews to approve

Post by efficiondave » Mon Jan 07, 2013 3:52 pm

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.

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1274
Joined: Sun Nov 18, 2007 3:55 pm

Re: Code for Alert when there are reviews to approve

Post by compunerdy » Fri Oct 16, 2015 9:35 am

Anyone know how to make this work for GOLD?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5079
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Code for Alert when there are reviews to approve

Post by mazhar » Wed Oct 21, 2015 12:23 am

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.

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1274
Joined: Sun Nov 18, 2007 3:55 pm

Re: Code for Alert when there are reviews to approve

Post by compunerdy » Wed Oct 21, 2015 5:19 am

Works great thanks

Post Reply