Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取magento中产品产生的总收入_Magento - Fatal编程技术网

获取magento中产品产生的总收入

获取magento中产品产生的总收入,magento,Magento,如何以编程方式获取Magento中产品产生的总收入 假设有一款产品id为1的产品,售价为10美元,5倍,5美元(折扣率),8倍,所以我想从Magento那里总共得到90美元。这可能吗???请参阅此处发布的答案,以了解我的代码建议的基础 由于您希望在前端显示此值,因此我假设为phtml,因此我将以这种方式对其进行编码,并尝试将最终价格乘以售出数量 <?php // Enter your product ID here $id = 123;

如何以编程方式获取Magento中产品产生的总收入


假设有一款产品id为
1
的产品,售价为10美元,5倍,5美元(折扣率),8倍,所以我想从Magento那里总共得到90美元。这可能吗???

请参阅此处发布的答案,以了解我的代码建议的基础

由于您希望在前端显示此值,因此我假设为phtml,因此我将以这种方式对其进行编码,并尝试将最终价格乘以售出数量

<?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;
?>


这是未经测试的,是动态编码的,但概念非常基本,因此您应该可以毫无困难地调整我所展示的内容,以满足您的需要。

您好,这是离题的。堆栈溢出用于编程问题。Magento的社区支持资源可能是更好的地方。你看过数据库模式吗?Pekka这是一个编程问题,实际上我想在前端显示值。是的,这是一个涉及Magento域逻辑的编程问题。这是一个很好的例子,说明了为什么存在一个关于分层价格的问题?