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_Collections_Filter_Magento 1.7 - Fatal编程技术网

Magento销售订单视图过滤器集合

Magento销售订单视图过滤器集合,magento,collections,filter,magento-1.7,Magento,Collections,Filter,Magento 1.7,我有个小问题。 我要筛选管理销售订单视图集合。 我尝试了,但找不到集合文件。 请帮忙。试试这些,它对我有用 <?php require_once('app/Mage.php'); //Path to Magento umask(0); Mage::app(); //echo $name = Mage::app()->getStore()->getId(); $orders = Mage::getModel('sales/order')->getCollection()

我有个小问题。
我要筛选
管理销售订单视图
集合。
我尝试了,但找不到集合文件。

请帮忙。

试试这些,它对我有用

<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
//echo $name = Mage::app()->getStore()->getId();

$orders = Mage::getModel('sales/order')->getCollection()
    ->addFieldToFilter('status', 'pending')
    ->addAttributeToSelect('customer_email', 'mail@domain.com')
    ;
foreach ($orders as $order) {
    $email = $order->getCustomerEmail();
    echo $email . "\n";
}

您应该能够使用observer完成此操作

在config.xml中

<adminhtml>
    <events>
    <sales_order_grid_collection_load_before>
        <observers>
            <magepal>
                <type>singleton</type>
                <class>magepal/observer</class>
                <method>handleOrderCollectionLoadBefore</method>
            </magepal>
        </observers>
    </sales_order_grid_collection_load_before>

感谢R.S的提示。

R.S感谢您的提示。如果我想用observer来计算下面以黄色显示的总计。。。能做到吗?
public function handleOrderCollectionLoadBefore($observer) 
{
     $collection = $observer->getOrderGridCollection();
     // $collection->addFieldToFilter('status', 'pending');
     // you may need to do additional check to make sure that the filter is only apply to specific section
<sales_order_item_collection_load_before>
    <observers>
        <set_discount_new_customer>
            <type>singleton</type>
            <class>modulename_customattribute/observer</class>
            <method>filterCollection</method>
        </set_discount_new_customer>
    </observers>
</sales_order_item_collection_load_before>
public function filterCollection($observer)
{
   $rawnew = $observer->getOrderItemCollection();
   $rawnew->addFieldToFilter('mycustom_attribute',6);
   return $rawnew;
}