News:

AbanteCart v1.4.2 is released.

Main Menu
support

Displaying in stock options on product listing

Started by otterslide, October 20, 2014, 01:13:31 PM

Previous topic - Next topic

otterslide

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!

abantecart

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.
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

otterslide

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?


Quote from: abantecart on October 20, 2014, 01:27:36 PM
Check the model for product


getProductOptions method will give you all details for options including the stock.

Look at 'quantity' for each option.

otterslide

Never mind, It looks like it does cache,

$this->cache->set( 'product.options.'.$product_id, $product_option_data, $language_id );

thanks again.

theriot3

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

Forum Rules Code of conduct
AbanteCart.com 2010 -