0

I've created a grid to list the invoices in my store and make decisions from it, but there are some invoices that the order that generated it is with status canceled or delivered. I need to list only the invoices that the base order is with the status processing.

My collection:

$collection = Mage::getResourceModel($this->_getCollectionClass())
            ->addFieldToSelect('entity_id')
            ->addFieldToSelect('created_at')
            ->addFieldToSelect('order_id')
            ->addFieldToSelect('increment_id')
            ->addFieldToSelect('order_increment_id')
            ->addFieldToSelect('order_created_at')
            ->addFieldToSelect('state')
            ->addFieldToSelect('grand_total')
            ->addFieldToSelect('base_grand_total')
            ->addFieldToSelect('store_currency_code')
            ->addFieldToSelect('base_currency_code')
            ->addFieldToSelect('order_currency_code')
            ->addFieldToSelect('billing_name')
        ;
        $this->setCollection($collection);
        return parent::_prepareCollection();

How to add filter by order status?

0

I solve it like this:

$order_status = "processing";
    $collection = Mage::getResourceModel($this->_getCollectionClass())
        ->addFieldToSelect('entity_id')
        ->addFieldToSelect('created_at')
        ->addFieldToSelect('order_id')
        ->addFieldToSelect('increment_id')
        ->addFieldToSelect('order_increment_id')
        ->addFieldToSelect('order_created_at')
        ->addFieldToSelect('state')
        ->addFieldToSelect('grand_total')
        ->addFieldToSelect('base_grand_total')
        ->addFieldToSelect('store_currency_code')
        ->addFieldToSelect('base_currency_code')
        ->addFieldToSelect('order_currency_code')
        ->addFieldToSelect('billing_name');

    $collection->getSelect()->join( array('order'=> 'sales_flat_order'), 'order.entity_id = main_table.order_id', array('order.status'))
        ->where("order.status = ?", $order_status);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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