AbanteCart Community
Shopping Cart Operations => Support => Topic started by: otterslide on October 20, 2014, 01:13:31 PM
-
Hello,
I have some items that have multiple sizes and I need to display the sizes on the main product listing before people click the listing.
I managed to display options out of the $Product object and looping them, however it is getting even the options which have 0 quantity left in stock.
Does anyone know how to check if an Option is in stock for a particular product?.. or how to get the list of in-stock options in a better way?..
Or even what code I can take a look at that is doing this already.. it must be doing it on the product listing page somehow to get the dropdown list.
this is what I came up with:
/template/pages/product/product_listing.tpl
$options = $product['options'];
if($options != null) {
foreach ($options as $option) {
if($option['option_value'] != null) {
foreach ($option['option_value'] as $option_value) {
$option_text .= $option_value['name'];
$option_text .= "<br/>";
}
}
}
}
Thanks!
-
Check the model for product
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/model/catalog/product.php
getProductOptions method will give you all details for options including the stock.
Look at 'quantity' for each option.
-
Thanks, That seems to work, and already filters out 0 quantity,
$this->model_catalog_product->getProductOptions($product['product_id']);
Would be nice if this was cached in the product, I think this will query for each product, correct?
Check the model for product
getProductOptions method will give you all details for options including the stock.
Look at 'quantity' for each option.
-
Never mind, It looks like it does cache,
$this->cache->set( 'product.options.'.$product_id, $product_option_data, $language_id );
thanks again.
-
My site has somehow lost its handshake with product_list.tpl entirely—can't get to any of my products!
Completely blown.
Any Ideas?
Marc