manage inventory issue?
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
manage inventory issue?
I can update and save on the first page but if I go to the second, third, etc I get a error when I hit save. Anyone else having this issue?
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
I tried it on my test site, but I'm not sure what you mean by the second and third.
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
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
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
manage>inventory
brings up inventory list with stock level below whatever you select. On the first page of it (i have more than one page because of number of products) I can edit the amounts and click save. If I go to any other page and try to edit and save it gives me a error. A index was out of range error.
brings up inventory list with stock level below whatever you select. On the first page of it (i have more than one page because of number of products) I can edit the amounts and click save. If I go to any other page and try to edit and save it gives me a error. A index was out of range error.
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
I don't have that many products to try, but that could be a bug. I got the same error on editing kits- if I went to edit an existing kit , I had to re-select the kit product (in this case size of bedspread) option (twin) before I could save the other changes. I did post that as a bug. It sounds like something similar here- it's not preserving a parameter or something when you go to the next page.
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
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
- voir
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Mon Jun 09, 2008 4:25 pm
- Location: Belingham, WA US
Re:
Was there any resolution to this? I'm having this problem when using the Copy button on the second page of Product Templates. Perhaps my problem is different enough to be a different bug, but the code error has to be very similar.compunerdy wrote:I will bug report it
Re: manage inventory issue??
I am unable to reproduce it, what is your application version?Was there any resolution to this? I'm having this problem when using the Copy button on the second page of Product Templates. Perhaps my problem is different enough to be a different bug, but the code error has to be very similar.
- voir
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Mon Jun 09, 2008 4:25 pm
- Location: Belingham, WA US
Re: manage inventory issue??
PLATFORM: ASP.NET
VERSION: 7.0
BUILD: 10125
VERSION: 7.0
BUILD: 10125
-
- Lieutenant, Jr. Grade (LT JG)
- Posts: 44
- Joined: Thu Feb 28, 2008 6:21 am
- Location: Pittsburgh, PA (Go Steelers!)
Re: manage inventory issue?
I too have received this error message with ASP.NET 7.0
If you have more than 1 page of inventory, you cannot save a change on the 2nd, 3rd, etc pages.
If you have more than 1 page of inventory, you cannot save a change on the 2nd, 3rd, etc pages.
Re: manage inventory issue?
What is your build number? Probably you are using some old build. I have checked the latest final version and its fine.
-
- Lieutenant, Jr. Grade (LT JG)
- Posts: 44
- Joined: Thu Feb 28, 2008 6:21 am
- Location: Pittsburgh, PA (Go Steelers!)
Re: manage inventory issue?
BUILD: 8272
Are there some specific lines of code that I can implement? We are going live soon and I don't want to upgrade, due to customizations.
Are there some specific lines of code that I can implement? We are going live soon and I don't want to upgrade, due to customizations.
Re: manage inventory issue?
Better PM me your Admin/Catalog/Inventory.aspx file, May be i can sum up with something after having a look at it.
Re: manage inventory issue?
Please backup your existing Admin/Catalog/Inventory.aspx file and then Replace its contents with the following code. Hopefully it will workout
Code: Select all
<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" Title="Manage Inventory"
Inherits="CommerceBuilder.Web.UI.AbleCommerceAdminPage" %>
<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<%@ Register Assembly="CommerceBuilder.Web" Namespace="CommerceBuilder.Web.UI.WebControls"
TagPrefix="cb" %>
<script runat="server">
protected string GetName(object dataItem)
{
ProductInventoryDetail detail = (ProductInventoryDetail)dataItem;
if (string.IsNullOrEmpty(detail.VariantName)) return detail.Name;
return string.Format("{0} ({1})", detail.Name, detail.VariantName);
}
protected void InventoryGrid_DataBound(object sender, EventArgs e)
{
SaveButton.Visible = (InventoryGrid.Rows.Count > 0);
InventoryGrid.GridLines = (SaveButton.Visible) ? GridLines.Both : GridLines.None;
}
private int GetControlValue(GridViewRow row, string controlId)
{
TextBox tb = row.FindControl(controlId) as TextBox;
if (tb != null)
{
return AlwaysConvert.ToInt(tb.Text);
}
return 0;
}
protected void SaveButton_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in InventoryGrid.Rows)
{
int dataItemIndex = row.DataItemIndex;
dataItemIndex = (dataItemIndex - (InventoryGrid.PageSize * InventoryGrid.PageIndex));
int productId = (int)InventoryGrid.DataKeys[dataItemIndex].Values[0];
int productVariantId = AlwaysConvert.ToInt(InventoryGrid.DataKeys[dataItemIndex].Values[1].ToString());
int inStock = GetControlValue(row, "InStock");
int lowStock = GetControlValue(row, "LowStock");
if (productVariantId.Equals(0))
{
Product product = ProductDataSource.Load(productId);
product.InStock = inStock;
product.InStockWarningLevel = lowStock;
product.Save();
}
else
{
ProductVariant variant = new ProductVariant();
variant.Load(productVariantId);
variant.InStock = inStock;
variant.InStockWarningLevel = lowStock;
variant.Save();
}
}
SavedMessage.Text = string.Format(SavedMessage.Text, DateTime.Now);
SavedMessage.Visible = true;
InventoryGrid.DataBind();
}
protected void GoButton_Click(object sender, EventArgs e)
{
InventoryGrid.DataBind();
}
</script>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="Server">
<ajax:UpdatePanel ID="ReportAjax" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="pageHeader">
<div class="caption">
<h1>
<asp:Localize ID="Localize1" runat="server" Text="Manage Product Inventory"></asp:Localize></h1>
</div>
</div>
<table cellpadding="2" cellspacing="0" class="innerLayout">
<tr class="noPrint">
<td style="padding: 10px 20px 0px 20px;">
<asp:Label ID="MaxInStockLabel" runat="server" Text="Show stock levels at or below:"
SkinID="FieldHeader"></asp:Label>
<asp:TextBox ID="MaxInStock" runat="server" Text="0" Columns="4"></asp:TextBox>
<asp:Button ID="GoButton" runat="server" Text="Go" OnClick="GoButton_Click" /><br />
<br />
<asp:Label ID="SavedMessage" runat="server" Text="Data saved at {0:g}" EnableViewState="false"
Visible="false" SkinID="GoodCondition"></asp:Label>
</td>
</tr>
<tr>
<td class="itemList">
<cb:SortedGridView ID="InventoryGrid" runat="server" AutoGenerateColumns="False"
DataSourceID="InventoryDs" DataKeyNames="ProductId,ProductVariantId" DefaultSortExpression="Name"
AllowPaging="True" AllowSorting="true" PageSize="20" CellPadding="4" RowStyle-CssClass="odd"
AlternatingRowStyle-CssClass="even" OnDataBound="InventoryGrid_DataBound" SkinID="Summary"
Width="100%">
<Columns>
<asp:TemplateField HeaderText="Name" SortExpression="Name">
<itemtemplate>
<asp:HyperLink ID="ProductLink" runat="server" Text='<%# GetName(Container.DataItem) %>' NavigateUrl='<%#Eval("ProductId", "../Products/EditProduct.aspx?ProductId={0}")%>'></asp:HyperLink>
</itemtemplate>
<headerstyle horizontalalign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="In Stock" SortExpression="InStock">
<itemstyle horizontalalign="Center" />
<itemtemplate>
<asp:TextBox ID="InStock" runat="server" Text='<%# Eval("InStock") %>' Columns="4"></asp:TextBox>
</itemtemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Low Stock">
<itemstyle horizontalalign="Center" />
<itemtemplate>
<asp:TextBox ID="LowStock" runat="server" Text='<%# Eval("InStockWarningLevel") %>' Columns="4"></asp:TextBox>
</itemtemplate>
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="paging" HorizontalAlign="right" />
<PagerSettings NextPageText="»" PreviousPageText="«" />
<EmptyDataTemplate>
<div class="emptyResult_FromCustomFile">
<asp:Label ID="EmptyResultsMessage" runat="server" Text="There are no items currently at or below the indicated stock level."></asp:Label>
</div>
</EmptyDataTemplate>
</cb:SortedGridView>
<br />
<asp:Button ID="SaveButton" runat="server" Text="Save" OnClick="SaveButton_Click" />
</td>
</tr>
</table>
</ContentTemplate>
</ajax:UpdatePanel>
<asp:ObjectDataSource ID="InventoryDs" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetProductInventory" TypeName="CommerceBuilder.Reporting.ProductInventoryDataSource"
SortParameterName="sortExpression" EnablePaging="true" SelectCountMethod="GetProductInventoryCount">
<SelectParameters>
<asp:ControlParameter ControlID="MaxInStock" Name="maxInStock" PropertyName="Text"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</asp:Content>
-
- Lieutenant, Jr. Grade (LT JG)
- Posts: 44
- Joined: Thu Feb 28, 2008 6:21 am
- Location: Pittsburgh, PA (Go Steelers!)
Re: manage inventory issue?
Thanks. This worked.
Sheldon
Sheldon
- voir
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Mon Jun 09, 2008 4:25 pm
- Location: Belingham, WA US
Re: manage inventory issue??
For me the resolution was modifying /admin/products/productemplates/default.aspx so that the copy button passes the ProductTemplateID directly instead of the Container.DataItemIndex thingmazhar wrote:I am unable to reproduce it, what is your application version?Was there any resolution to this? I'm having this problem when using the Copy button on the second page of Product Templates. Perhaps my problem is different enough to be a different bug, but the code error has to be very similar.
Code: Select all
<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" Title="Product Templates" Inherits="CommerceBuilder.Web.UI.AbleCommerceAdminPage" %>
<script runat="server">
protected void AddButton_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
ProductTemplate pt = new ProductTemplate();
pt.Name = AddName.Text;
pt.Save();
Response.Redirect("EditProductTemplate.aspx?ProductTemplateId=" + pt.ProductTemplateId.ToString());
}
}
protected void Page_Load(object sender, EventArgs e)
{
PageHelper.SetDefaultButton(AddName, AddButton.ClientID);
}
protected int CountMerchantFields(object dataItem)
{
ProductTemplate template = (ProductTemplate)dataItem;
int count = 0;
foreach(InputField field in template.InputFields)
{
if (field.IsMerchantField) count++;
}
return count;
}
protected int CountCustomerFields(object dataItem)
{
ProductTemplate template = (ProductTemplate)dataItem;
int count = 0;
foreach (InputField field in template.InputFields)
{
if (!field.IsMerchantField) count++;
}
return count;
}
protected int CountProducts(object dataItem)
{
return ProductDataSource.CountForProductTemplate(((ProductTemplate)dataItem).ProductTemplateId);
}
protected void ProductTemplateGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Copy")
{
//VAH int productTemplateId = (int)ProductTemplateGrid.DataKeys[Int32.Parse(e.CommandArgument.ToString())].Value;
int productTemplateId = Int32.Parse(e.CommandArgument.ToString());//VAH
ProductTemplate copy = ProductTemplate.Copy(productTemplateId, true);
if (copy != null)
{
copy.Name = "Copy of " + copy.Name;
copy.Save();
ProductTemplateGrid.DataBind();
}
}
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<div class="pageHeader">
<div class="caption">
<h1><asp:Localize ID="Caption" runat="server" Text="Product Templates"></asp:Localize></h1>
</div>
</div>
<table cellpadding="2" cellspacing="0" class="innerLayout">
<tr>
<td colspan="2" style="padding:10px 0px 10px 0px; text-indent:20px;">
<asp:Label ID="InstructionText" runat="server" Text="Use templates to define additional custom fields for your products."></asp:Label>
</td>
</tr>
<tr>
<td class="itemList">
<ajax:UpdatePanel ID="ProductTemplateAjax" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="ProductTemplateGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ProductTemplateDs"
DataKeyNames="ProductTemplateId" AllowPaging="True" OnRowCommand="ProductTemplateGrid_RowCommand"
SkinID="PagedList" width="100%">
<Columns>
<asp:TemplateField HeaderText="Template Name">
<ItemTemplate>
<asp:Label ID="Name" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Merchant Fields">
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label ID="MerchantFields" runat="server" Text='<%# CountMerchantFields(Container.DataItem) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Customer Fields">
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label ID="CustomerFields" runat="server" Text='<%# CountCustomerFields(Container.DataItem) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Products">
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:HyperLink ID="Products" runat="server" Text='<%# CountProducts(Container.DataItem) %>' NavigateUrl='<%#Eval("ProductTemplateId", "ViewProducts.aspx?ProductTemplateId={0}")%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Wrap="false">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:HyperLink ID="EditLink" runat="server" NavigateUrl='<%#Eval("ProductTemplateId", "EditProductTemplate.aspx?ProductTemplateId={0}")%>'><asp:Image ID="EditIcon" runat="server" SkinID="EditIcon" /></asp:HyperLink>
<asp:ImageButton ID="CopyButton" runat="server" AlternateText="Copy" SkinID="CopyIcon" CommandName="Copy" CommandArgument='<%#Eval("ProductTemplateId")%>' /> <!-- % # Container.DataItemIndex % VAH-->
<asp:ImageButton ID="DeleteButton" runat="server" AlternateText="Delete" SkinID="DeleteIcon" CommandName="Delete" OnClientClick='<%#Eval("Name", "return confirm(\"Are you sure you want to delete {0}?\")") %>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<div style="text-align:center;margin-top:10px;margin-bottom:10px;padding-left:10px;padding-right:10px">
<asp:Label ID="NoProductTemplatesText" runat="server" Text="<i>There are no product templates defined.</i>"></asp:Label>
</div>
</EmptyDataTemplate>
</asp:GridView>
</ContentTemplate>
</ajax:UpdatePanel>
</td>
<td class="detailPanel">
<div class="section">
<div class="header">
<h2 class="addtemplate"><asp:Localize ID="AddCaption" runat="server" Text="Add Template" /></h2>
</div>
<div class="content">
<ajax:UpdatePanel ID="AddAjax" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="Add" />
<asp:Label ID="AddNameLabel" runat="server" Text="Name:" SkinID="FieldHeader"></asp:Label>
<asp:TextBox ID="AddName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="AddNameRequired" runat="server" ControlToValidate="AddName" ValidationGroup="Add" Text="*" ErrorMessage="Name is required."></asp:RequiredFieldValidator>
<asp:Button ID="AddButton" runat="server" Text="Add" OnClick="AddButton_Click" ValidationGroup="Add" />
</ContentTemplate>
</ajax:UpdatePanel>
</div>
</div>
</td>
</tr>
</table>
<asp:ObjectDataSource ID="ProductTemplateDs" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="LoadForStore" TypeName="CommerceBuilder.Products.ProductTemplateDataSource" DataObjectTypeName="CommerceBuilder.Products.ProductTemplate" DeleteMethod="Delete"></asp:ObjectDataSource>
</asp:Content>