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?
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:
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
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:
I hope this helps.
is working on a reply...