Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix "ambiguous column" errors when filtering by original columns.

  • Loading branch information...
commit fba1ce295d21645775e55dff5c46d27513b65538 1 parent f5580b9
@colinmollenhour authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 code/Block/Adminhtml/Sales/Order/Grid.php
View
14 code/Block/Adminhtml/Sales/Order/Grid.php
@@ -10,7 +10,12 @@ class Cm_OrderProducts_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_B
const XML_PATH_RENDER_COLUMN = 'sales/cmorderproducts/render';
const XML_PATH_FILTER_COLUMN = 'sales/cmorderproducts/filter';
- // MUST override setCollection rather than _prepareCollection to get filtering and paging both working
+ /**
+ * MUST override setCollection rather than _prepareCollection to get filtering and paging both working
+ *
+ * @param Mage_Sales_Model_Mysql4_Order_Grid_Collection $collection
+ * @return
+ */
public function setCollection($collection)
{
parent::setCollection($collection);
@@ -34,6 +39,13 @@ protected function _prepareColumns()
parent::_prepareColumns();
if( ! Mage::getStoreConfig(self::XML_PATH_RENDER_COLUMN) || $this->_isExport) return;
+ // Specify table to fix ambiguous column errors
+ foreach($this->getColumns() as $column) {
+ if($column->getIndex()) {
+ $column->setFilterIndex('`main_table`.'.$column->getIndex());
+ }
+ }
+
$this->addColumnAfter('skus', array(
'header' => Mage::helper('sales')->__('Products Ordered (%s)', Mage::getStoreConfig(self::XML_PATH_RENDER_COLUMN)),
'index' => 'skus',
Please sign in to comment.
Something went wrong with that request. Please try again.