1

我有一个小问题。
我想过滤admin sales order view收藏。
我试过了,但找不到收藏文件。
请帮忙 。

4

3 回答 3

1

试试这些,它对我有用,

<?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";
}
于 2013-11-13T11:21:35.770 回答
1

您应该能够使用观察者来做到这一点

在 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>

在你的观察者中

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
于 2013-11-13T14:10:25.470 回答
1
<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;
}

感谢 RS 提供提示。

于 2013-11-14T12:24:39.893 回答