Page 1 of 1

Products with Low Inventory back in stock page.

Posted: Fri Oct 14, 2016 10:53 am
by compunerdy
How can I add the sku to this page? When I put parts back in stock its based off sku not product descriptions..

Re: Products with Low Inventory back in stock page.

Posted: Tue Oct 18, 2016 2:33 am
by nadeem
You can add a new column for sku just after Name. To make this update open Admin/Reports/LowInventory.aspx

Locate the following

Code: Select all

<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>
and replace with

Code: Select all

<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="Sku">
   <ItemTemplate>
       <asp:Label runat="server" Text='<%# GetSku(Container.DataItem) %>'></asp:Label>
   </ItemTemplate>
   <HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
Now open Admin/Reports/LowInventory.aspx.cs and put the following code some where e.g. below GetName() function

Code: Select all

protected string GetSku(object dataItem)
{
    ProductInventoryDetail detail = (ProductInventoryDetail)dataItem;
    if (detail.Variant != null && !string.IsNullOrEmpty(detail.Variant.Sku)) return detail.Variant.Sku;
    Product product = ProductDataSource.Load(detail.ProductId);
    if (product != null && !string.IsNullOrEmpty(product.Sku)) return product.Sku;
    return string.Empty;
}

Re: Products with Low Inventory back in stock page.

Posted: Tue Oct 18, 2016 4:26 am
by compunerdy
That worked great thanks!!

Re: Products with Low Inventory back in stock page.

Posted: Wed Feb 22, 2017 12:04 pm
by compunerdy
How would I sort the manufacturer drop down? Right now it goes off the manufacturer ID number or something and I would prefer it to be alphabetical so I can find the one I am looking for faster.