Magento model listing/get function

1.8k Views Asked by At

I'm trying to learn how to use Magento models, but I'm getting very impatient and keep getting interrupted by client phone calls....Can someone just tell me how to achieve the following:

SELECT * FROM usertable WHERE emaillike '%gmail%' and taxnumber = 300
//Then print the results in php

I'm looking for code that might look something like

$model = new UserTable();
$results = $model->getWhere(array('email'=>'%gmail%', tax=>300));
print_r($results);

or something to that effect;

1

There are 1 best solutions below

3
On BEST ANSWER
$customer = Mage::getModel('customer/customer');
$collection = $customer->getCollection()
            ->addAttributeToFilter('taxvat', 300)
            ->addAttributeToFilter('email', array('like'=>'%gmail%'))
            ->load();
print_r($collection->toArray());

P.S. When you have time the knowledge base makes a good primer.