这是我的代码,在这种形式下不起作用:
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/order_grid_collection')
->addFieldToSelect('entity_id')
->addFieldToSelect('increment_id')
->addFieldToSelect('customer_id')
->addFieldToSelect('customer_email')
->addFieldToSelect('created_at')
->addFieldToSelect('grand_total')
->addFieldToSelect('base_grand_total')
->addFieldToSelect('status')
->addFieldToSelect('order_currency_code')
->addFieldToSelect('store_id')
->addFieldToSelect('billing_name')
->addFieldToSelect('shipping_name')
->addFieldToFilter('customer_id', Mage::registry('current_customer')->getId())
->setIsCustomerMode(true);
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _avansFilter($collection, $column)
{
if (!$value = $column->getFilter()->getValue()) {
return $this;
}
$orderId = $collection->getData();
$CustomerEmail = $orderId[0]['customer_email'];
$this->getCollection()->getSelect()->where(
"order.increment_id like ?"
, "%$value%");
return $this;
}
当我删除$orderId = $collection->getData();
时,函数_avansFilter
开始返回结果,但我必须到达$ collection中的数据,这样我才能得到正确的结果。
不知怎的$collection
和$this
不兼容,但我不知道原因。
也许这是一个非常愚蠢的问题,但我不知道如何解决它。
我需要从$collection
中获取要在function _avansFilter
内使用的数据,但是当我在函数中使用此数据时,它会停止使用return $this;
期待您的建议和答案。
亲切的问候