Active
Project:
UberPOS
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 Jul 2011 at 10:11 UTC
Updated:
15 Aug 2011 at 07:10 UTC
Would it be possible to add stock data to product nodes?
--- up_multi.module (revision 1492)
+++ up_multi.module (working copy)
@@ -374,7 +374,18 @@
case 'delete':
db_query('DELETE FROM {up_store_products} WHERE nid=%d', $node->nid);
db_query('DELETE FROM {up_store_stock} WHERE model=%d', $node->model);
+ case 'load':
+ // add stock data to the node
+ $stores = array();
+ $stores_result = db_query("SELECT * FROM {up_stores} ORDER BY LOWER(store_name)");
+ while($store_record = db_fetch_object($stores_result)) {
+ $stock = db_result(db_query("SELECT stock_level FROM {up_store_stock} WHERE model='%s' AND store_id=%d", $node->model, $store_record->store_id));
+ $store_record->stock = $stock;
+ $stores[] = $store_record;
+ };
+ $node->up_multi_stock = $stores;
}
+
}
}
Comments
Comment #1
slip commentedWell, this is interesting... uc_product loads sell price into the node object, but uc_stock doesn't load stock info in there... We should probably override the price or have a similar patch to this one for price (eg, up_multi_price)..
But yeah, I'm not opposed to adding this, but I'm curious if it would be a common need, seeing as ubercart itself doesn't load this information into the node.
Comment #2
rhmtts commentedPersonally I prefer erring on the side of providing all the data that's available :-)