Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Amount of products sold - and goal to reach
 
pouldc
Jr. Member
 
Total Posts:  1
Joined:  2013-05-18
 

Hi,
For our shop we need a certain amount of preorders before a product is produced.
So I need to show how many items are ordered, how many need to be ordered for the product to go into production and maybe even show a progress bar or percentage. Not unlike this page, anyone that can help?
http://beatdelete.com/

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Moderator
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 

Try to play with the following code:

<?php
$thresholdQty         
25//target qty
$productId             123//product id
$_productCollection  Mage::getResourceModel('reports/product_collection')
    ->
addOrderedQty()
    ->
addAttributeToFilter('id'$productId
    ->
setOrder('ordered_qty''desc')
    ->
getFirstItem();

$soldQty    = (int)$_productCollection->getOrderedQty();
$pendingQty $thresholdQty $soldQty;
var_dump($pendingQty);
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top