开发者

How to get ordered qty of product in front-end?

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 Q开发者_如何学编程TY ? And if the product is a "Configurable Product",How do I get the QTY ?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜