Hi, when I dsm $node I can see stock and SKU (model) but only for the main product, there is nothing in the Attributes->Options. Is there any way to print the attribute option stock level and SKU?

CommentFileSizeAuthor
#2 devel.jpg196.72 KBkevin_91
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TR’s picture

You generally need to do a node_load() to get all the data attached to a node (product, in this case).

kevin_91’s picture

FileSize
196.72 KB

Hey, thanks for the tip, but still couldn't get the SKU or stock level.

This is what I get in the devel:
devel

TR’s picture

Status: Active » Fixed

Attributes don't have SKUs. Products have SKUs, and the SKU depends on the *combination* of attributes that the the customer has selected. If Size and Color are attributes, then a Large Green T-Shirt would have a SKU, and a Medium Green T-Shirt could have a different SKU, but Color=Green would not have its own SKU.

You can take a look at uc_attribute_uc_product_alter() to see how internally we decide what SKU to associate with a particular ordered product with a particular set of attributes and options chosen. Or if you are looking at an already-placed order, the correct SKU for the ordered product is stored in the uc_order_products table.

Given a SKU, the stock level may be obtained via uc_stock_level($sku).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.