以下代码在Magento 1.6下正常运行但在1.5.0.1下运行时引发了Mage_Core_Exception(消息:'无法检索实体配置:sales / Array')。要在Magento 1.5.0.1下运行此代码,我需要做什么?
$results = Mage::getResourceModel('sales/order_collection');
$results->join(
array('status_key_table' => 'order_status'),
'main_table.status = status_key_table.status',
array('status_key_table.label')
);
谢谢你,
本
答案 0 :(得分:3)
如果比较1.5.0.1和1.6.2.0之间的join()方法:
1.5.0.1: Mage_Core_Model_Mysql4_Collection_Abstract::join()
public function join($table, $cond, $cols='*')
{
if (!isset($this->_joinedTables[$table])) {
$this->getSelect()->join(array($table=>$this->getTable($table)), $cond, $cols);
$this->_joinedTables[$table] = true;
}
return $this;
}
1.6.2.0: Mage_Core_Model_Resource_Db_Collection_Abstract::join()
public function join($table, $cond, $cols = '*')
{
if (is_array($table)) {
foreach ($table as $k => $v) {
$alias = $k;
$table = $v;
break;
...
您可以看到1.5.0.1不支持别名。相反,它会在您传入的第一个参数上调用$ this-> getTable() - 这应该是一个字符串。因此,在您的情况下,您需要传递'sales / order_status'作为第一个参数。