0

I want to show Revenue from product under Reports> Products> Products Ordered Grid.

I know for the Grid I have to override app\code\core\Mage\Adminhtml\Block\Report\Product\Sold\Grid.php but how do I get revenue for the product.

Scrrenshot

1 Answer 1

0

See the answer posted here for the basis of my code suggestion

Magento: How to display how many times a product has been sold?

since you are wanting to display this value in the frontend, i'm assuming phtml, so I'll code it that way, and just attempt to multiply final price by qty sold.

<?php
        // Enter your product ID here 
        $id = 123; 

        // Load the product collection and do some filters   
        $_productCollection = Mage::getResourceModel('reports/product_collection')
            ->addOrderedQty()
            ->addAttributeToFilter('id', $id)
            ->setOrder('ordered_qty', 'desc')
            ->getFirstItem();

        // Since the filter selects one product, we can use it here as the single result
        $product = $_productCollection;

        // Load the tax helper
        $_taxHelper  = Mage::helper('tax');

        // Get the final price of the product
        $finalprice = $_taxHelper->getPrice($product, $product->getFinalPrice(), true);


        // Print the results
        echo $product->getName() . " total revenue: " . (int)$product->ordered_qty * $finalprice;
?>

This is untested, coded on the fly, but the concepts are pretty basic so you should have no trouble adapting what I've shown to do what you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.