Page 1 of 1
Edit Product - Button
Posted: Tue Aug 10, 2010 10:31 pm
by igavemybest
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?
Re: Edit Product - Button
Posted: Wed Aug 11, 2010 4:23 am
by AbleMods
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.
Re: Edit Product - Button
Posted: Wed Aug 11, 2010 5:05 am
by igavemybest
Simple enough! Thanks Joe!
Re: Edit Product - Button
Posted: Wed Aug 11, 2010 6:40 am
by jmestep
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.
Re: Edit Product - Button
Posted: Wed Aug 11, 2010 2:01 pm
by igavemybest
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 =)
Re: Edit Product - Button
Posted: Wed Aug 11, 2010 3:14 pm
by AbleMods
SCORE !
sadly, I didn't know it was down there until Judy pointed it out in this thread
