
Originally Posted by
panservolvo
Or maybe I could make a db-trigger to update the attribute when stock is <=0 thoughts?
I have not touched the core code of this mod in a while so I would have to relook at what routes can be done. But I would say that would be a good place to start. This is a bit of code from the core that I used to do a custom dropdown for a friend which basically disables the products from the dropdown when stock reaches a predetermined level he targets.
Code:
function zen_get_product_quantity_form($product_id) {
global $db;
$sql = "select products_quantity from " . TABLE_PRODUCTS . (zen_not_null($product_id) ? " where products_id=" . (int)$product_id : "");
$check_quantity = $db->Execute($sql);
return $check_quantity->fields['products_quantity'];
}
So you could use this logic in your code to trigger the change of the attribute. Bascially just make sure to loop through the products and then the function will assign "instock" and "outofstock" automatically.
But another approach is to just go in the tpl file for dynamic filter and basically make a custom filter selection to loop through all products and either give the 2 choices of "instock" and outofstock" based on the function above results on the quantity. This would be the easier way as you won't have to touch the core code of messing with the attributes but instead just have the filter give selections based on the quantity value. This would be the way I would approach it.
Bookmarks