You are here

function _uc_reports_product_get_skus in Ubercart 6.2

Get the SKUs on a product, first from the product itself, then from the adjustments table, finally pulling any SKUs out of previous orders.

Parameters

$nid: The product's node ID.

Return value

A unique sorted array of all skus.

2 calls to _uc_reports_product_get_skus()
uc_reports_products in uc_reports/uc_reports.admin.inc
Display the product reports
uc_reports_products_custom in uc_reports/uc_reports.admin.inc
Display the custom product report.

File

uc_reports/uc_reports.admin.inc, line 281
Reports administration menu items.

Code

function _uc_reports_product_get_skus($nid) {

  // Product SKU.
  $models = array(
    db_result(db_query("SELECT model FROM {uc_products} WHERE nid = %d", $nid)),
  );

  // Adjustment SKUs.
  $product_models = db_query("SELECT model FROM {uc_product_adjustments} WHERE nid = %d", $nid);
  while ($product_model = db_fetch_object($product_models)) {
    $models[] = $product_model->model;
  }

  // SKUs from orders.
  $order_product_models = db_query("SELECT DISTINCT model FROM {uc_order_products} WHERE nid = %d", $nid);
  while ($order_product_model = db_fetch_object($order_product_models)) {
    $models[] = $order_product_model->model;
  }

  // Unique, sorted.
  $models = array_unique($models);
  asort($models);
  return $models;
}