Product ID search in Admin area?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 лет назад
Hey Guys,

I am loading a great deal of products into my site, and I need people to be able to search for these products in the admin area..

At the moment you can search by product name, manufacturer or category...

Is there a simple way for me to add a product ID search field??

THANKS :)
13 лет назад
The easiest way to access products by their ID, for editing, is to alter the product ID in the URL after loading a product from the gridview (Administration > Catalog > Products > Manage Products). You can add a field to edit the product by product ID (works similar to "Go directly to product SKU").

1. Add the following to Administration\Modules\Products.ascx (after the </tr> for GoDirectlyToSKU, line 77 in 1.80):
<tr>
    <td class="adminTitle">
        <nopCommerce:ToolTipLabel runat="server" ID="lblGoDirectlyToID" Text="<% $NopResources:Admin.Products.GoDirectlyID %>"
            ToolTip="<% $NopResources:Admin.Products.GoDirectlyID.Tooltip %>" ToolTipImage="~/Administration/Common/ico-help.gif" />
    </td>
    <td class="adminData">
        <nopCommerce:SimpleTextBox runat="server" CssClass="adminInput" ID="txtID" Width="150px"
            ValidationGroup="GoDirectlyID" ErrorMessage="<% $NopResources:Admin.Products.GoDirectlyID.ErrorMessage %>">
        </nopCommerce:SimpleTextBox>
        <asp:Button runat="server" Text="<% $NopResources:Admin.Products.GoIDButton.Text %>"
            CssClass="adminButtonBlue" ID="btnGoDirectlyToID" OnClick="btnGoDirectlyToID_Click"
            ValidationGroup="GoDirectlyID" />
    </td>
</tr>
    
2. Add the following to Administration\Modules\Products.ascx.cs:
protected void btnGoDirectlyToID_Click(object sender, EventArgs e)
{
    if (Page.IsValid)
    {
        try
        {
            int productId = 0;

            if (Int32.TryParse(txtID.Text.Trim(), out productId))
            {
                var product = ProductManager.GetProductById(productId);
                if (product != null)
                {
                    string url = string.Format("{0}ProductDetails.aspx?ProductId={1}",
                        CommonHelper.GetStoreAdminLocation(),
                        product.ProductId.ToString());
                    Response.Redirect(url);
                }
            }
        }
        catch (Exception exc)
        {
            ProcessException(exc);
        }
    }
}

3. Add the following four string resources (Administration > Content Management > Localization > "Select Language"):
    
Name: Admin.Products.GoDirectlyID
Value: Go directly to product ID

Name: Admin.Products.GoDirectlyID.Tooltip
Value: Enter product ID and click Go

Name: Admin.Products.GoDirectlyID.ErrorMessage
Value: Product ID is required

Name: Admin.Products.GoIDButton.Text
Value: Go

You will need to recompile the project.

.
13 лет назад
elegant and simple solution :)

Thanks!  Will try it out
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.