Magento:SQLSTATE [42S22]:未找到列:1054 'where clause' 中的未知列 'billing_name'
Magento: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'billing_name' in 'where clause'
尝试过滤管理网格以查看特定产品的销售历史记录,但在尝试按帐单名称过滤时出现以下错误:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'billing_name' in 'where clause'
这是我正在使用的:
protected function _prepareCollection() {
$productId = $this->getProduct()->getId();
$ordersId = $this->getOrderIds($productId);
$collection = mage::getModel('sales/order')
->getCollection()
->addFieldToFilter('main_table.entity_id', array('in' => $ordersId))
->join('sales/order_address', '`sales/order_address`.entity_id=billing_address_id', array('billing_name' => "concat(firstname, ' ', lastname)"));
$this->setCollection($collection);
return parent::_prepareCollection();
}
然后为帐单名称添加网格列:
protected function _prepareColumns() {
$this->addColumn('billing_name', array(
'header' => Mage::helper('AdvancedStock')->__('Bill to Name'),
'index' => 'billing_name',
'sortable' => true
));
return parent::_prepareColumns();
}
列 returns 包含正确包含产品的订单中的所有帐单名称,我只是无法按名称过滤该列。有什么想法吗?
magento sales_flat_order 和 sales_flat_order_address tables 不会有列 billing_name.
您可以使用 sales_flat_order_grid table 而不是 sales_flat_order_address 来获取 billing_name 这样的
$collection = Mage::getModel('sales/order')
->getCollection()
->addFieldToFilter('main_table.entity_id', array('in' => $ordersId))
->join('sales/order_grid', '`sales/order_grid`.entity_id=main_table.entity_id', array('billing_name' => 'billing_name'));
否则,您可以左加入 sales_flat_order_grid table 与当前集合。
尝试过滤管理网格以查看特定产品的销售历史记录,但在尝试按帐单名称过滤时出现以下错误:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'billing_name' in 'where clause'
这是我正在使用的:
protected function _prepareCollection() {
$productId = $this->getProduct()->getId();
$ordersId = $this->getOrderIds($productId);
$collection = mage::getModel('sales/order')
->getCollection()
->addFieldToFilter('main_table.entity_id', array('in' => $ordersId))
->join('sales/order_address', '`sales/order_address`.entity_id=billing_address_id', array('billing_name' => "concat(firstname, ' ', lastname)"));
$this->setCollection($collection);
return parent::_prepareCollection();
}
然后为帐单名称添加网格列:
protected function _prepareColumns() {
$this->addColumn('billing_name', array(
'header' => Mage::helper('AdvancedStock')->__('Bill to Name'),
'index' => 'billing_name',
'sortable' => true
));
return parent::_prepareColumns();
}
列 returns 包含正确包含产品的订单中的所有帐单名称,我只是无法按名称过滤该列。有什么想法吗?
magento sales_flat_order 和 sales_flat_order_address tables 不会有列 billing_name.
您可以使用 sales_flat_order_grid table 而不是 sales_flat_order_address 来获取 billing_name 这样的
$collection = Mage::getModel('sales/order')
->getCollection()
->addFieldToFilter('main_table.entity_id', array('in' => $ordersId))
->join('sales/order_grid', '`sales/order_grid`.entity_id=main_table.entity_id', array('billing_name' => 'billing_name'));
否则,您可以左加入 sales_flat_order_grid table 与当前集合。