Look up Ubercart 3 product attribute by SKU function


function lookup_option_name($sku) {
$query = "SELECT nid, combination FROM {uc_product_adjustments} WHERE model = '$sku'";
$result = db_query($query);
foreach ($result as $row) {
$nid = $row->nid;
$combo = $row->combination;
list($stuff, $oid, $junk) = split('"', $combo);
$query2 = "SELECT aid,name FROM {uc_attribute_options} WHERE oid = '$oid'";
$result2 = db_query($query2);
foreach ($result2 as $row2) {
$name = $row2->name;
}
}
return $name;
}