tags:

views:

24

answers:

1

I display a best-sell list in front-end,Now I also want to show the QTY that how many already sell for this product,How do I get the QTY ? And if the product is a "Configurable Product",How do I get the QTY ?

A: 

Your question is a little unclear. This is how to get the quantity available for a product, which actually means the STOCK.

// get the quantity for a Mage_Catalog_Model_Product $product
$productStockItem = $product->getStockItem();
$productStockItem->getQty();

If you want the number of sold items you'll have to select all your orders and search for products in there, and is a little more complicated. I dont think that the type of product and the display frontend or backend makes it different in any way.

Elzo Valugi