Adding SKU to the Search in Admin
Adding SKU to the Search in Admin
Hi guys
The product listing on admin page shows only names, is it possible to show for
example SKU & Name in that page, say when product is selected?
Thanks
The product listing on admin page shows only names, is it possible to show for
example SKU & Name in that page, say when product is selected?
Thanks
Re: Adding SKU to the Search in Admin
Yes its possible. Edit your Website/Admin/Catalog/Search.aspx file and locate following lines
and then update them as below
Finally edit your Website/Admin/Catalog/Search.aspx.cs file and add following code lines just above the very last closing curly brace "}" like
Save the files and now try the admin search again.
Code: Select all
<asp:TemplateField HeaderText="Sort">
<HeaderStyle HorizontalAlign="center" Width="27px" />
<ItemStyle Width="27px" HorizontalAlign="Center" />
<ItemTemplate>
<img src="<%# GetCatalogIconUrl(Container.DataItem) %>" border="0" alt="<%#Eval("CatalogNodeType")%>" />
</ItemTemplate>
</asp:TemplateField>
Code: Select all
<asp:TemplateField HeaderText="Sort">
<HeaderStyle HorizontalAlign="center" Width="27px" />
<ItemStyle Width="27px" HorizontalAlign="Center" />
<ItemTemplate>
<img src="<%# GetCatalogIconUrl(Container.DataItem) %>" border="0" alt="<%#Eval("CatalogNodeType")%>" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SKU">
<HeaderStyle HorizontalAlign="center" Width="27px" />
<ItemStyle Width="27px" HorizontalAlign="Center" />
<ItemTemplate>
<%# GetSku(Container.DataItem) %>
</ItemTemplate>
</asp:TemplateField>
Code: Select all
protected string GetSku(Object dataItem)
{
CatalogNode catalogNode = (CatalogNode)dataItem;
if (catalogNode.CatalogNodeType == CatalogNodeType.Product)
return ((Product)catalogNode.ChildObject).Sku;
return string.Empty;
}
Re: Adding SKU to the Search in Admin
Thanks Mazhar , it works exactly the way it is suppose to. Appriciate your help.
- rhuffman
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Thu May 19, 2005 6:36 pm
- Location: Dublin, OH
- Contact:
Re: Adding SKU to the Search in Admin
This solution worked find. However, it would also be nice to be able to search by SKU.
It would also be nice to have the product browse http://website/Admin/Catalog/Browse.aspx display the SKU by default.
Any suggestions on coding to accomplish both of these.
It would also be nice to have the product browse http://website/Admin/Catalog/Browse.aspx display the SKU by default.
Any suggestions on coding to accomplish both of these.
Re: Adding SKU to the Search in Admin
In order show sku on browse page simply locate following code block in Admin/Catalog/Browse.aspx file
and update it as below
then edit Admin/catalog/browse.aspx.cs file and add following code just above last closing curly brace
This change should list the sku next to product name on browse page.
Code: Select all
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:LinkButton ID="N" runat="server" Text='<%# Eval("Name") %>' CommandName="Do_Open" CommandArgument='<%#string.Format("{0}|{1}", Eval("CatalogNodeTypeId"), Eval("CatalogNodeId"))%>'></asp:LinkButton>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
Code: Select all
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:LinkButton ID="N" runat="server" Text='<%# Eval("Name") %>' CommandName="Do_Open" CommandArgument='<%#string.Format("{0}|{1}", Eval("CatalogNodeTypeId"), Eval("CatalogNodeId"))%>'></asp:LinkButton>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Sku">
<ItemTemplate>
<%#GetSku(Container.DataItem) %>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
Code: Select all
protected string GetSku(Object dataItem)
{
CatalogNode catalogNode = (CatalogNode)dataItem;
if (catalogNode.CatalogNodeType == CatalogNodeType.Product)
return ((Product)catalogNode.ChildObject).Sku;
return string.Empty;
}
- rhuffman
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Thu May 19, 2005 6:36 pm
- Location: Dublin, OH
- Contact:
Re: Adding SKU to the Search in Admin
Mazhar:
Following the directions and got the following error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'ItemTemplate' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.
Source Error:
Line 168:
Line 169:
Line 170: <ItemTemplate>
Line 171: <a href="<%# GetPreviewUrl(Eval("CatalogNodeType"), Eval("CatalogNodeId"), Eval("Name")) %>" Title="Preview" Target="_blank"><img src="<%# GetIconUrl("Preview.gif") %>" border="0" alt="Preview" /></a>
Line 172:
Source File: /Admin/Catalog/Browse.aspx Line: 170
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
Following the directions and got the following error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'ItemTemplate' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.
Source Error:
Line 168:
Line 169:
Line 170: <ItemTemplate>
Line 171: <a href="<%# GetPreviewUrl(Eval("CatalogNodeType"), Eval("CatalogNodeId"), Eval("Name")) %>" Title="Preview" Target="_blank"><img src="<%# GetIconUrl("Preview.gif") %>" border="0" alt="Preview" /></a>
Line 172:
Source File: /Admin/Catalog/Browse.aspx Line: 170
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
Re: Adding SKU to the Search in Admin
Make sure you modified the file accordingly. Seems like may you have replaced some unnecessary part in the file. It would be better simply locate the TemplateField for name and then after its closing tag </asp:TemplateField> try adding
save the file and in code file add method as described above
save the file and test it.
Code: Select all
<asp:TemplateField HeaderText="Sku">
<ItemTemplate>
<%#GetSku(Container.DataItem) %>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
Code: Select all
protected string GetSku(Object dataItem)
{
CatalogNode catalogNode = (CatalogNode)dataItem;
if (catalogNode.CatalogNodeType == CatalogNodeType.Product)
return ((Product)catalogNode.ChildObject).Sku;
return string.Empty;
}
- rhuffman
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Thu May 19, 2005 6:36 pm
- Location: Dublin, OH
- Contact:
Re: Adding SKU to the Search in Admin
Mazhar:
Thanks you! It works exactly the way I needed. This will save us a lot of time.
One more request that's related.
In Able 5.x we were able to search by SKU. Can we add a check box in the search (browse.aspx or is it search.aspx?) that will allow us to search by sku?
Thank you.
Thanks you! It works exactly the way I needed. This will save us a lot of time.
One more request that's related.
In Able 5.x we were able to search by SKU. Can we add a check box in the search (browse.aspx or is it search.aspx?) that will allow us to search by sku?
Thank you.
Re: Adding SKU to the Search in Admin
I think in catalog search this option is not available and there is no easy workaround to put it there. But SKU is considered when you search from admin search page. Simply trigger the search for SKU through search box available in admin header and it will list the product.
- rhuffman
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Thu May 19, 2005 6:36 pm
- Location: Dublin, OH
- Contact:
Re: Adding SKU to the Search in Admin
Mashar:
Duuh! Way too obvious. Didn't even try in the general search.
Thanks again for your help. It is greatly appreciated.
Ray Huffman
www.DarbyCreekTrading.com
Duuh! Way too obvious. Didn't even try in the general search.
Thanks again for your help. It is greatly appreciated.
Ray Huffman
www.DarbyCreekTrading.com