magentoaddattribute

Magento - how to get more values from addAttributeToFilter?


Hello I hope someone can help me figure out what to do!

I need to get several results from magento. The following code works:

private $_orderstatusToFilter = array("processing", "done");

->addAttributeToFilter('status',array('eq' => $this->_orderstatusToFilter[0]))

this line above shows all the values from one var which is:_orderstatusToFilter = processing. Now I would like to also get all the values where 'status' = (_orderstatusToFilter =) done.

    ->addAttributeToFilter('status',array('eq' => $this->_orderstatusToFilter[0], 'eq' => $this->_orderstatusToFilter[1]))

There are no results if I run the code.

What to do?


Solution

  • You can try to take out condition like in sample below

    $statusCondition = array(
        array(
            'eq' => $this->_orderstatusToFilter[0]
        ),
        array(
            'eq' => $this->_orderstatusToFilter[1]
        )
    );
    
    ->addAttributeToFilter('status', $statusCondition);
    

    Or use IN condition instead

    ->addAttributeToFilter('id', array('in' => $_orderstatusToFilter));