SQLSTATE [42S22]:找不到列:1054未知列'全名'在' where子句'在Magento

时间:2017-05-25 11:21:07

标签: magento

$collection = Mage::getModel('marketplace/sellertransaction')->getCollection();

$prefix = Mage::getConfig()->getTablePrefix();
$eavAttribute = new Mage_Eav_Model_Mysql4_Entity_Attribute();
$fn = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'firstname');
$ln = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'lastname');
$collection->getSelect()
    ->join(array('ce1' => 'customer_entity_varchar'), 'ce1.entity_id=main_table.sellerid', array('firstname' => 'value'))
    ->where('ce1.attribute_id='.$fn->getAttributeId()) 
    ->join(array('ce2' => 'customer_entity_varchar'), 'ce2.entity_id=main_table.sellerid', array('lastname' => 'value'))
    ->where('ce2.attribute_id='.$ln->getAttributeId()) 
    ->columns(new Zend_Db_Expr("CONCAT(`ce1`.`value`, ' ',`ce2`.`value`) AS fullname"));

$collection->getSelect()
       ->join(array("ce3" => $prefix."customer_entity"),"ce3.entity_id = main_table.sellerid",array("email" => "email"))
       ->columns(new Zend_Db_Expr("`main_table`.`created_at` AS createddate"));
$collection->addFilterToMap("createddate","`main_table`.`created_at`");
$this->setCollection($collection);
parent::_prepareCollection();  

fullname列中过滤时出现以下错误:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'fullname' in 'where clause', query was: SELECT COUNT(*) FROM `marketplace_sellertransaction` AS `main_table`
 INNER JOIN `customer_entity_varchar` AS `ce1` ON ce1.entity_id=main_table.sellerid
 INNER JOIN `customer_entity_varchar` AS `ce2` ON ce2.entity_id=main_table.sellerid
 INNER JOIN `customer_entity` AS `ce3` ON ce3.entity_id = main_table.sellerid WHERE (ce1.attribute_id=1) AND (ce2.attribute_id=2) AND (fullname LIKE '%hemel%')

0 个答案:

没有答案