1
Answers
Vote up!
0
Vote down!

How to I get the Product SKU from a Commerce Line Item?

Hi,
How do I retrieve a Product SKU from a commerce_line_item? I have managed to loop through the commerce_line_items to retrieve order id's but I am not sure how to use those id's to retrieve the Product SKU's for each corresponding line item.

If anyone knows or has a snippet of code they could post or even point me in the right direction I would be grateful.

Thanks.

Asked by: CommerceDev77
on August 16, 2012

1 Answer

Vote up!
1
Vote down!

Assuming your in a commerce_line_items loop, for each line item, you can get the wrapper and access the corresponding product sku.

Here is a little snippet.

$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$product_sku = $line_item_wrapper->commerce_product->sku->value();
Answer by: Anonymous (not verified)
Posted: Aug 24, 2012