Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Extend admin grid of orders
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

i want to extend the list of orders in backend by an symbol which displays the availability of ordered products (in my case its allowed to order products out of stock). So i want to realize following:

All Products available: green icon
Only one product isnt available: yellow icon
Two ore more products arent available: red icon

So i want to add static value with this code: (its an example out of order grid)

$this->addColumn('real_order_id', array(
            
'header'=> Mage::helper('sales')->__('Order #'),
            
'width' => '80px',
            
'index' => 'increment_id',
        ));

I need smth like that:

$this->addColumn('real_order_id', array(
            
'header'=> Mage::helper('sales')->__('Order #'),
            
'width' => '80px',
            
'value' => Mage::getModel('bla/bla')->getAvailability(),
        ));

So far as i can see its only possible to print datas out of the collection created with _prepareCollection() in grid-block. Is there a pos. to add a static value? Are there any hints to do this? Or can i add some additional code to realize a rollover function?

Hope my english is “understandable” smile!

Cheers and thanks in advance

Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

here is the solution:

class Mage_Ordercustomization_Block_Adminhtml_Ordercustomization_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{
  
  
protected function _prepareCollection()
  
{
        $collectionProducts 
Mage::getResourceModel('sales/order_collection')
            ->
addAttributeToSelect('*');        
        
        if(isset(
$collectionProducts)){
            
foreach($collectionProducts AS $_item){
                $order 
Mage::getModel('sales/order')->loadByIncrementId($_item->getIncrementId());
                
$order->setOrderProductStatus(Mage::getSingleton('ordercustomization/ordercustomization')->getStatusIcon($_item->getIncrementId()));
                
$order->save();            
            
}
        }        
        
        
return parent::_prepareCollection();
  
}

  
protected function _prepareColumns()
  
{
        $this
->addColumn('order_product_status', array(
            
'header' => Mage::helper('ordercustomization')->__('Status'),
            
'index' => 'order_product_status',
            
'width' => '20px',            
            
'type' => 'text',
        ));
        
        return 
parent::_prepareColumns();
  
}    

}

Cheers

Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top