I know this question may not be relevant to Ubercart development itself, but at least in this forum people would know which tables I'm specifically talking about.

What is wrong with this query?

$combos = db_select('uc_product_adjustments', 'adjustments');
	  $combos->fields('adjustments', array('model', 'combination'));
	  $combos->leftJoin('uc_product_stock', 'stock', 'adjustments.nid = stock.nid');
	  $combos->condition('adjustments.nid', $node->nid, '=');
	  $combos->condition('stock.stock', 0, '<>');
	  $result = $combos->execute;		

          print kpr($result);

Basically I'm trying to get all product ajdustments SKU's whose stock level is not 0?
I should be getting about 4-5 results on the node I'm testing but I'm getting none?

Could eventually turn this into a simple OUT OF STOCK attribute related for D7 since it seems nobody has ported to D7 yet from the D6 ones.

Thanks.

Comments

Woggers’s picture

Status: Active » Fixed

This does the job.

$skus = db_query("SELECT a.model, a.combination FROM {uc_product_adjustments} a, {uc_product_stock} s WHERE a.nid = :nid AND s.sku = a.model AND s.active = 1 AND s.stock > 0", array(':nid' => $node->nid))->fetchAll();

Status: Fixed » Closed (fixed)

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