以下代码允许向订单/销售页面添加一列,其中显示送货方式为包含所有送货承运人的送货说明。Magento - 完整性约束违规:1052 - 运输方法
_prepareCollection
$collection->getSelect()->join('sales_flat_order', 'main_table.entity_id = sales_flat_order.entity_id',array('shipping_description'));
_prepareColumn
$this->addColumn('shipping_method', array(
'header' => Mage::helper('sales')->__('Shipping Method'),
'index' => 'shipping_description',
'filter_index' => 'main_table.status',
));
的送货方式似乎完美后,我编译的一切。现在,当我尝试将订单由prcessing排序,并砸在搜索谈到这个错误:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous, query was: SELECT COUNT(*) FROM `sales_flat_order_grid` AS `main_table` INNER JOIN `sales_flat_order` ON main_table.entity_id = sales_flat_order.entity_id WHERE (status = 'processing')
一些研究,这意味着有当表进行接合的双重身份之后,现在怎么创建一个alians从这个以及如何应用它。此外,如果有人知道过滤/按此列排序的方式会很棒。
PS。该文件位于: 应用程序/代码/本地/法师/ Adminhtml /座/销售/订单
编辑:现在想弄清楚如何选择下拉列表基于数据库中的值来创建。这里是我试图去上班代码:您需要使用自定义渲染
protected function _getAttributeOptions($attribute_code)
{
$attribute = Mage::getModel('sales/order')->getAttribute('shipping_description', $attribute_code);
$options = array();
foreach($attribute->getSource()->getAllOptions(true, true) as $option) {
$options[$option['value']] = $option['label'];
}
return $options;
}
你能否详细说明如何创建这个定制的渲染,我不知道有关文件的管理在这方面,如果我可以在grid.php或外部类中创建此 - 在那里将它放置。我真的不想创建一个模块。 – damek132
已更新。我不建议你重写或编辑核心文件。更好地创建新模块。 – zhartaunik
不知道你是否注意到,但我复制了核心文件并使用本地文件夹中的相同文件: app/code/local/Mage/Adminhtml/Block/Sales/Order – damek132