Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid:

Mage_Adminhtml_Block_Widget_Grid Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 __construct ()
 getStore ()
 getQuote ()
 getGridUrl ()

Protected Member Functions

 _addColumnFilterToCollection ($column)
 _prepareCollection ()
 _prepareColumns ()
 _getSelectedProducts ()
 _getGiftmessageSaveModel ()


Detailed Description

Definition at line 34 of file Grid.php.


Constructor & Destructor Documentation

__construct (  ) 

Constructor

By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes

Reimplemented from Varien_Object.

Definition at line 37 of file Grid.php.

00038     {
00039         parent::__construct();
00040         $this->setId('sales_order_create_search_grid');
00041         $this->setRowClickCallback('order.productGridRowClick.bind(order)');
00042         $this->setCheckboxCheckCallback('order.productGridCheckboxCheck.bind(order)');
00043         $this->setRowInitCallback('order.productGridRowInit.bind(order)');
00044         $this->setDefaultSort('entity_id');
00045         $this->setUseAjax(true);
00046         if ($this->getRequest()->getParam('collapse')) {
00047             $this->setIsCollapsed(true);
00048         }
00049     }


Member Function Documentation

_addColumnFilterToCollection ( column  )  [protected]

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 69 of file Grid.php.

00070     {
00071         // Set custom filter for in product flag
00072         if ($column->getId() == 'in_products') {
00073             $productIds = $this->_getSelectedProducts();
00074             if (empty($productIds)) {
00075                 $productIds = 0;
00076             }
00077             if ($column->getFilter()->getValue()) {
00078                 $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
00079             } else {
00080                 if($productIds) {
00081                     $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
00082                 }
00083             }
00084         } else {
00085             parent::_addColumnFilterToCollection($column);
00086         }
00087         return $this;
00088     }

_getGiftmessageSaveModel (  )  [protected]

Retrieve gift message save model

Returns:
Mage_Adminhtml_Model_Giftmessage_Save

Definition at line 204 of file Grid.php.

00205     {
00206         return Mage::getSingleton('adminhtml/giftmessage_save');
00207     }

_getSelectedProducts (  )  [protected]

Definition at line 192 of file Grid.php.

00193     {
00194         $products = $this->getRequest()->getPost('products', array());
00195 
00196         return $products;
00197     }

_prepareCollection (  )  [protected]

Prepare grid collection object

Returns:
this

need display all simple products

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 90 of file Grid.php.

00091     {
00092         $collection = Mage::getModel('catalog/product')->getCollection()
00093             ->setStore($this->getStore())
00094             ->addAttributeToSelect('name')
00095             ->addAttributeToSelect('sku')
00096             ->addAttributeToSelect('price')
00097             ->addAttributeToFilter('type_id', array_keys(
00098                 Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray()
00099             ))
00100             ->addStoreFilter();
00101 
00102         if($this->helper('giftmessage/message')->getIsMessagesAvailable(
00103             'main', $this->getQuote(), $this->getStore()
00104         )) {
00105             $collection->addAttributeToSelect('gift_message_available');
00106         }
00107 
00108         Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
00109         /**
00110          * need display all simple products
00111          */
00112         //Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
00113 
00114         $this->setCollection($collection);
00115 
00116         return parent::_prepareCollection();
00117     }

_prepareColumns (  )  [protected]

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 119 of file Grid.php.

00120     {
00121         $this->addColumn('entity_id', array(
00122             'header'    => Mage::helper('sales')->__('ID'),
00123             'sortable'  => true,
00124             'width'     => '60',
00125             'index'     => 'entity_id'
00126         ));
00127         $this->addColumn('name', array(
00128             'header'    => Mage::helper('sales')->__('Product Name'),
00129             'index'     => 'name'
00130         ));
00131         $this->addColumn('sku', array(
00132             'header'    => Mage::helper('sales')->__('SKU'),
00133             'width'     => '80',
00134             'index'     => 'sku'
00135         ));
00136         $this->addColumn('price', array(
00137             'header'    => Mage::helper('sales')->__('Price'),
00138             'align'     => 'center',
00139             'type'      => 'currency',
00140             'currency_code' => $this->getStore()->getCurrentCurrencyCode(),
00141             'rate'      => $this->getStore()->getBaseCurrency()->getRate($this->getStore()->getCurrentCurrencyCode()),
00142             'index'     => 'price'
00143         ));
00144 
00145         $this->addColumn('in_products', array(
00146             'header_css_class' => 'a-center',
00147             'type'      => 'checkbox',
00148             'name'      => 'in_products',
00149             'values'    => $this->_getSelectedProducts(),
00150             'align'     => 'center',
00151             'index'     => 'entity_id',
00152         ));
00153 
00154         if($this->helper('giftmessage/message')->getIsMessagesAvailable(
00155             'items', $this->getQuote(), $this->getStore()
00156         )) {
00157             $this->addColumn('giftmessage', array(
00158                 'filter'    => false,
00159                 'sortable'  => false,
00160                 'header'    => Mage::helper('sales')->__('Gift'),
00161                 'renderer'  => 'adminhtml/sales_order_create_search_grid_renderer_giftmessage',
00162                 'field_name'=> 'giftmessage',
00163                 'inline_css'=> 'checkbox input-text',
00164                 'align'     => 'center',
00165                 'index'     => 'entity_id',
00166                 'values'    => $this->_getGiftmessageSaveModel()->getAllowQuoteItemsProducts(),
00167                 'width'     => '1',
00168             ));
00169         }
00170 
00171         $this->addColumn('qty', array(
00172             'filter'    => false,
00173             'sortable'  => false,
00174             'header'    => Mage::helper('sales')->__('Qty To Add'),
00175             'name'      => 'qty',
00176             'inline_css'=> 'qty',
00177             'align'     => 'right',
00178             'type'      => 'input',
00179             'validate_class' => 'validate-number',
00180             'index'     => 'qty',
00181             'width'     => '1',
00182         ));
00183 
00184         return parent::_prepareColumns();
00185     }

getGridUrl (  ) 

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 187 of file Grid.php.

00188     {
00189         return $this->getUrl('*/*/loadBlock', array('block'=>'search_grid', '_current' => true, 'collapse' => null));
00190     }

getQuote (  ) 

Retrieve quote object

Returns:
Mage_Sales_Model_Quote

Definition at line 64 of file Grid.php.

00065     {
00066         return Mage::getSingleton('adminhtml/session_quote')->getQuote();
00067     }

getStore (  ) 

Retrieve quote store object

Returns:
Mage_Core_Model_Store

Definition at line 55 of file Grid.php.

00056     {
00057         return Mage::getSingleton('adminhtml/session_quote')->getStore();
00058     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:22:59 2009 for Magento by  doxygen 1.5.8