You are hereBlogs / mehow's blog / Look up Ubercart 3 product attribute by SKU function

Look up Ubercart 3 product attribute by SKU function


By mehow - Posted on 03 July 2014


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;
}

Tags