Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Nauman 98 posts 118 karma points
    Nov 24, 2010 @ 13:10
    Nauman
    0

    get properties of item in .NET

    Hi Soren

    I want to get few properties of the products residing within a purchase order. I am able to get the product sku of the items in purchase order. How can I get the properties using this sku?

    var orderLine = request.PurchaseOrder.OrderLines.ToList();

     for (int p = 0; p < orderLine.Count; p++)
    {
    string pSku = orderLine[p].Sku;
    }

    I have created a product defination "internalCode" in Settings >> Catalog >> Product definations, I want to get "internalCode" through "pSku" in above loop. How can i do that?

    Nauman

  • Søren Spelling Lund 1797 posts 2786 karma points
    Nov 24, 2010 @ 13:40
    Søren Spelling Lund
    0

    Hi Nauman,

    You can accomplish that using something like this:

    foreach (OrderLine orderline in request.PurchaseOrder.OrderLine)
    {
    string pSku = orderLine.Sku;
    // Look up the product
    Product product = Product.All().Where(x => x.Sku == pSku && x.ParentProductId == null).Single();
    string internalCode = product["internalCode"];
    }

    One caveat with this code is that the query I use to look up the product doesn't take into account variants. If your variants store the property you can expand on the query and check on the variantSku as well like so:

    string variantSku = orderLine.VariantSku;
    Product product = Product.All().Where(x => x.Sku == pSku x.VariantSku == pVariantSku).Single();

    I hope this helps.

Please Sign in or register to post replies

Write your reply to:

Draft