Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku:

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 ($arguments=array())
 getStore ()
 getGridUrl ()

Protected Member Functions

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


Detailed Description

Definition at line 34 of file Sku.php.


Constructor & Destructor Documentation

__construct ( arguments = array()  ) 

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 37 of file Sku.php.

00038     {
00039         parent::__construct($arguments);
00040 
00041         if ($this->getRequest()->getParam('current_grid_id')) {
00042             $this->setId($this->getRequest()->getParam('current_grid_id'));
00043         } else {
00044             $this->setId('skuChooserGrid_'.$this->getId());
00045         }
00046 
00047         $form = $this->getJsFormObject();
00048         $this->setRowClickCallback("$form.chooserGridRowClick.bind($form)");
00049         $this->setCheckboxCheckCallback("$form.chooserGridCheckboxCheck.bind($form)");
00050         $this->setRowInitCallback("$form.chooserGridRowInit.bind($form)");
00051         $this->setDefaultSort('sku');
00052         $this->setUseAjax(true);
00053         if ($this->getRequest()->getParam('collapse')) {
00054             $this->setIsCollapsed(true);
00055         }
00056     }


Member Function Documentation

_addColumnFilterToCollection ( column  )  [protected]

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 67 of file Sku.php.

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

_getSelectedProducts (  )  [protected]

Definition at line 145 of file Sku.php.

00146     {
00147         $products = $this->getRequest()->getPost('selected', array());
00148 
00149         return $products;
00150     }

_prepareCollection (  )  [protected]

Prepare grid collection object

Returns:
this

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 86 of file Sku.php.

00087     {
00088         $collection = Mage::getResourceModel('catalog/product_collection')
00089             ->setStoreId(0)
00090             ->addAttributeToSelect('name')
00091             ->addAttributeToFilter('type_id', array('in'=>array(
00092                 Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
00093                 Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
00094                 Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE
00095             )));
00096 
00097         $this->setCollection($collection);
00098 
00099         return parent::_prepareCollection();
00100     }

_prepareColumns (  )  [protected]

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 102 of file Sku.php.

00103     {
00104         $this->addColumn('in_products', array(
00105             'header_css_class' => 'a-center',
00106             'type'      => 'checkbox',
00107             'name'      => 'in_products',
00108             'values'    => $this->_getSelectedProducts(),
00109             'align'     => 'center',
00110             'index'     => 'sku',
00111             'use_index' => true,
00112         ));
00113 
00114         $this->addColumn('entity_id', array(
00115             'header'    => Mage::helper('sales')->__('ID'),
00116             'sortable'  => true,
00117             'width'     => '60px',
00118             'index'     => 'entity_id'
00119         ));
00120 
00121         $this->addColumn('chooser_sku', array(
00122             'header'    => Mage::helper('sales')->__('SKU'),
00123             'name'      => 'chooser_sku',
00124             'width'     => '80px',
00125             'index'     => 'sku'
00126         ));
00127         $this->addColumn('chooser_name', array(
00128             'header'    => Mage::helper('sales')->__('Product Name'),
00129             'name'      => 'chooser_name',
00130             'index'     => 'name'
00131         ));
00132 
00133         return parent::_prepareColumns();
00134     }

getGridUrl (  ) 

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 136 of file Sku.php.

00137     {
00138         return $this->getUrl('*/*/chooser', array(
00139             '_current'          => true,
00140             'current_grid_id'   => $this->getId(),
00141             'collapse'          => null
00142         ));
00143     }

getStore (  ) 

Retrieve quote store object

Returns:
Mage_Core_Model_Store

Definition at line 62 of file Sku.php.

00063     {
00064         return Mage::app()->getStore();
00065     }


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

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