I want search shipping address by customer name, company, city or postcode. Please help me
This my code, but it get double, it gte shipping and billing address, i want get only shipping address.
$addressCollection = Mage::getModel('sales/order_address')->getCollection(); $addressCollection->getSelect()->where("lastname like '%$customerName%' and company like '%$customerCompany%' and city like '%$customerCity%' and postcode like '%$customerCode%'"); var_dump($addressCollection->getData());exit;
I follow answer and it show error
Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lastname like '%Nhân%' and company like '%%' and city like '%%' and postcode li' at line 1, query was: SELECT `main_table`.* FROM `sales_flat_order_address` AS `main_table` WHERE (address_type = 'shipping' lastname like '%Nhân%' and company like '%%' and city like '%%' and postcode like '%%')";