×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: bejoy balan
Added: Nov 27, 2014 9:58 AM
Views: 24
http://magentotutorialbeginners.blogspot.in/2014/03/magento-interview-questions-and-answers_25.html
  1.  
  2. $coll = Mage::getModel('sales/order')->getCollection();
  3.  
  4. $fn = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'firstname');
  5. $ln = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'lastname');
  6.  
  7. $coll->getSelect()
  8.     ->join(array('ce1' => 'customer_entity_varchar'), 'ce1.entity_id=main_table.customer_id', array('firstname' => 'value'))
  9.     ->where('ce1.attribute_id='.$fn->getAttributeId())
  10.     ->join(array('ce2' => 'customer_entity_varchar'), 'ce2.entity_id=main_table.customer_id', array('lastname' => 'value'))
  11.     ->where('ce2.attribute_id='.$ln->getAttributeId())
  12.     ->columns(new Zend_Db_Expr("CONCAT(`ce1`.`value`, ' ',`ce2`.`value`) AS fullname"));
  13.  
  14. print_r($coll->getData());