Edit Product - Button

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
igavemybest
Captain (CAPT)
Captain (CAPT)
Posts: 388
Joined: Sun Apr 06, 2008 5:47 pm

Edit Product - Button

Post by igavemybest » Tue Aug 10, 2010 10:31 pm

I want to add an "Edit Product" button that would appear on a store front-end products page while browsing the store's products as an admin. This would save tons of time going back into the catalog and looking up the item and I think it would be a great feature to also include in the next update. How would I go about this, or does anyone already have code for this?

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Edit Product - Button

Post by AbleMods » Wed Aug 11, 2010 4:23 am

You can do this fairly easily by changing the BuyProductDialog user control as follows:

Edit /ConLib/BuyProductDialog.ascx and find (near the bottom):

Code: Select all

            <tr>
                <td colspan="2">
                    <asp:ValidationSummary ID="ValidationSummary" runat="server" ValidationGroup="AddToBasket" />					
                    <asp:Button ID="AddToWishlistButton" runat="server" Visible="true" OnClick="AddToWishlistButton_Click" Text="Add to Wishlist" EnableViewState="false" ValidationGroup="AddToBasket"></asp:Button>
                    <asp:Button ID="AddToBasketButton" runat="server" Visible="true" OnClick="AddToBasketButton_Click" Text="Add to Cart" EnableViewState="false" ValidationGroup="AddToBasket"></asp:Button>
                </td>
            </tr>
And change it to look like this:

Code: Select all

            <tr>
                <td colspan="2">
                    <asp:ValidationSummary ID="ValidationSummary" runat="server" ValidationGroup="AddToBasket" />					
                    <asp:Button ID="AddToWishlistButton" runat="server" Visible="true" OnClick="AddToWishlistButton_Click" Text="Add to Wishlist" EnableViewState="false" ValidationGroup="AddToBasket"></asp:Button>
                    <asp:Button ID="AddToBasketButton" runat="server" Visible="true" OnClick="AddToBasketButton_Click" Text="Add to Cart" EnableViewState="false" ValidationGroup="AddToBasket"></asp:Button>
                    <asp:Button ID="EditProductButton" runat="server" Visible="false" Text="Edit Product" EnableViewState="false"></asp:Button>
                </td>
            </tr>
Now edit the code-behind file /ConLib/BuyProductDialog.ascx.cs and find (near the top):

Code: Select all

    protected void Page_Init(object sender, System.EventArgs e)
    {
        _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
        _Product = ProductDataSource.Load(_ProductId);
        if (_Product != null)
        {
            //DISABLE PURCHASE CONTROLS BY DEFAULT
            AddToBasketButton.Visible = false;
            rowQuantity.Visible = false;
and make it look like this:

Code: Select all

    protected void Page_Init(object sender, System.EventArgs e)
    {
        _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
        _Product = ProductDataSource.Load(_ProductId);
        if (_Product != null)
        {
            //BEGIN MOD: AbleMods.com
            //8/10/2010
            // Show Edit-Product button if user is admin
            if (Token.Instance.User.IsAdmin && Token.Instance.User.IsApproved)
            {
                EditProductButton.Visible = true;
                EditProductButton.PostBackUrl = string.Format("~/Admin/Products/EditProduct.aspx?ProductId={0}", _Product.ProductId);
            }
            //END MOD:  AbleMods.com

            //DISABLE PURCHASE CONTROLS BY DEFAULT
            AddToBasketButton.Visible = false;
            rowQuantity.Visible = false;
Now every product page will have a 3rd button "Edit Product". The button will only be visible if the authenticated user is both an Admin User and the user account has been approved.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
igavemybest
Captain (CAPT)
Captain (CAPT)
Posts: 388
Joined: Sun Apr 06, 2008 5:47 pm

Re: Edit Product - Button

Post by igavemybest » Wed Aug 11, 2010 5:05 am

Simple enough! Thanks Joe!

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Edit Product - Button

Post by jmestep » Wed Aug 11, 2010 6:40 am

Down at the bottom of the page, underneath the Mode for View Page or Edit, there is a link that you can click to edit the product. There is also one for edit category, but I don't remember if that was originally there or if it came in a newer build.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
igavemybest
Captain (CAPT)
Captain (CAPT)
Posts: 388
Joined: Sun Apr 06, 2008 5:47 pm

Re: Edit Product - Button

Post by igavemybest » Wed Aug 11, 2010 2:01 pm

Judy, you are correct. I have never seen that before. I have 7.0.4, guess I must have missed it! I like Joe's approach though, more my style =)

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Edit Product - Button

Post by AbleMods » Wed Aug 11, 2010 3:14 pm

SCORE ! :P

sadly, I didn't know it was down there until Judy pointed it out in this thread :oops:
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Post Reply