Skip to main content
changed format of code blocks
Source Link
Vladimir Kerkhoff
  • 8.2k
  • 1
  • 36
  • 41

I am trying to add "sku" and "product name" to sales order grid with filtering.

I have created my joins but the columns are empty and I'm not sure what I have done incorrectly here...

Trying to get collection from sales/flat_order_item

protected function _prepareCollection() { $collection = Mage::getResourceModel($this->_getCollectionClass());

protected function _prepareCollection() { $collection = Mage::getResourceModel($this->_getCollectionClass()); $collection->getSelect()->joinLeft(array('sfoi' => 'sales_flat_order_item'),   'sfoi.parent_id=main_table.entity_id', array('sfoi.sku',   'sfoi.name'));  $this->setCollection($collection);  return parent::_prepareCollection(); } 

}

And add to the grid

protected function _prepareColumns() { $this->addColumn('sku', array( 'header'=> Mage::helper('sales')->__('Sku'), 'width' => '80px', 'type' => 'text', 'filter_index' => 'sfoi.sku', ));

protected function _prepareColumns() { $this->addColumn('sku', array( 'header'=> Mage::helper('sales')->__('Sku'), 'width' => '80px', 'type' => 'text', 'filter_index' => 'sfoi.sku', )); $this->addColumn('name', array(   'header'=> Mage::helper('sales')->__('Product Name'),   'width' => '80px',   'type' => 'text',   'filter_index' => 'sfoi.name',  )); } 

}

Can anyone see what I have done wrong here please..?

I am trying to add "sku" and "product name" to sales order grid with filtering.

I have created my joins but the columns are empty and I'm not sure what I have done incorrectly here...

Trying to get collection from sales/flat_order_item

protected function _prepareCollection() { $collection = Mage::getResourceModel($this->_getCollectionClass());

$collection->getSelect()->joinLeft(array('sfoi' => 'sales_flat_order_item'), 'sfoi.parent_id=main_table.entity_id', array('sfoi.sku', 'sfoi.name')); $this->setCollection($collection); return parent::_prepareCollection(); 

}

And add to the grid

protected function _prepareColumns() { $this->addColumn('sku', array( 'header'=> Mage::helper('sales')->__('Sku'), 'width' => '80px', 'type' => 'text', 'filter_index' => 'sfoi.sku', ));

$this->addColumn('name', array( 'header'=> Mage::helper('sales')->__('Product Name'), 'width' => '80px', 'type' => 'text', 'filter_index' => 'sfoi.name', )); 

}

Can anyone see what I have done wrong here please..?

I am trying to add "sku" and "product name" to sales order grid with filtering.

I have created my joins but the columns are empty and I'm not sure what I have done incorrectly here...

Trying to get collection from sales/flat_order_item

protected function _prepareCollection() { $collection = Mage::getResourceModel($this->_getCollectionClass()); $collection->getSelect()->joinLeft(array('sfoi' => 'sales_flat_order_item'),   'sfoi.parent_id=main_table.entity_id', array('sfoi.sku',   'sfoi.name'));  $this->setCollection($collection);  return parent::_prepareCollection(); } 

And add to the grid

protected function _prepareColumns() { $this->addColumn('sku', array( 'header'=> Mage::helper('sales')->__('Sku'), 'width' => '80px', 'type' => 'text', 'filter_index' => 'sfoi.sku', )); $this->addColumn('name', array(   'header'=> Mage::helper('sales')->__('Product Name'),   'width' => '80px',   'type' => 'text',   'filter_index' => 'sfoi.name',  )); } 

Can anyone see what I have done wrong here please..?

Source Link
user1704524
  • 2.5k
  • 13
  • 62
  • 106

How to add "SKU" and "Product Name" to sales order grid?

I am trying to add "sku" and "product name" to sales order grid with filtering.

I have created my joins but the columns are empty and I'm not sure what I have done incorrectly here...

Trying to get collection from sales/flat_order_item

protected function _prepareCollection() { $collection = Mage::getResourceModel($this->_getCollectionClass());

$collection->getSelect()->joinLeft(array('sfoi' => 'sales_flat_order_item'), 'sfoi.parent_id=main_table.entity_id', array('sfoi.sku', 'sfoi.name')); $this->setCollection($collection); return parent::_prepareCollection(); 

}

And add to the grid

protected function _prepareColumns() { $this->addColumn('sku', array( 'header'=> Mage::helper('sales')->__('Sku'), 'width' => '80px', 'type' => 'text', 'filter_index' => 'sfoi.sku', ));

$this->addColumn('name', array( 'header'=> Mage::helper('sales')->__('Product Name'), 'width' => '80px', 'type' => 'text', 'filter_index' => 'sfoi.name', )); 

}

Can anyone see what I have done wrong here please..?