Display SKU

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 лет назад
How can we display the SKU on the product detail page as well as in the order details?
14 лет назад
Anyone???  It looks like no one really moderates these forums since there are so many unanswered posts. If anyone knows how I can display the product SKU on the order details page that would be great
14 лет назад
I've been wanting to display the SKU on the Product Info page too.  I'm sure there's many ways but here's one for products that don't have multiple variants.  

In the file ProductInfo.ascx add a literal to display the SKU (i.e. the new literal being the bold part of the following code:

        <h3 class="productname">
            <asp:Literal ID="lProductName" runat="server" />
        </h3>
        <br />
        <asp:Literal ID="lSKU" runat="server" /><br />
        <div class="shortdescription">



Now the the code behind file, ProductInfo.ascx.cs, add the following code after the line lFullDescription.Text = product.FullDescription; (line 62 approx):

               
if (product.HasMultipleVariants == false)
{
           ProductVariant thisVariant = ProductManager.GetProductVariantByID(product.ProductVariants[0].ProductVariantID);
                    lSKU.Text = string.Concat("[Part No: ", product.ProductVariants[0].SKU , "]");
                    lSKU.Visible = true;
                }
                else
                {
                    lSKU.Visible = false;
}


Recomplie, upload the new files and dlls from the bin and this will display the SKU on the product info page for products with only a single variant.  You can mess with css to change the style and I'm going to tweak it to include multiple variants but this does me for now.

Hope it helps.
14 лет назад
sorry, should have said, this is v1.30
14 лет назад
and you can see the result on http://www.waterware.co.uk shortly
14 лет назад
sorry again - this line of code is unnecessary and should be removed

ProductVariant thisVariant = ProductManager.GetProductVariantByID(product.ProductVariants[0].ProductVariantID);
14 лет назад
v1.30

And to display the SKU for products with multiple variants, in the file Modules/ProductVariantsInGrid.ascx

Find the line of code:
<asp:Label runat="server" ID="ProductVariantID" Text='<%#Eval("ProductVariantID")%>'
                        Visible="false" />


Insert after it this line of code:

<asp:Label runat="server" ID="ProductVariantSKU" Text='<%# String.Concat("[SKU: ", Eval("SKU"), "]")%>' 
                        Visible="true" />



Save the page, recomplie, upload the new page and the NopCommerceStore.dll (in the bin).
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.