Closed (fixed)
Project:
Ubercart
Version:
7.x-3.x-dev
Component:
Other
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 Nov 2011 at 18:19 UTC
Updated:
18 Nov 2011 at 19:40 UTC
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
Comment #1
Woggers commentedThis 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();