Mage_Adminhtml_Block_Catalog_Category_Tab_Product Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Catalog_Category_Tab_Product:

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 ()
 getCategory ()
 getGridUrl ()

Protected Member Functions

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


Detailed Description

Definition at line 34 of file Product.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 Product.php.

00038     {
00039         parent::__construct();
00040         $this->setId('catalog_category_products');
00041         $this->setDefaultSort('entity_id');
00042         $this->setUseAjax(true);
00043     }


Member Function Documentation

_addColumnFilterToCollection ( column  )  [protected]

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 50 of file Product.php.

00051     {
00052         // Set custom filter for in category flag
00053         if ($column->getId() == 'in_category') {
00054             $productIds = $this->_getSelectedProducts();
00055             if (empty($productIds)) {
00056                 $productIds = 0;
00057             }
00058             if ($column->getFilter()->getValue()) {
00059                 $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
00060             }
00061             elseif(!empty($productIds)) {
00062                 $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
00063             }
00064         }
00065         else {
00066             parent::_addColumnFilterToCollection($column);
00067         }
00068         return $this;
00069     }

_getSelectedProducts (  )  [protected]

Definition at line 151 of file Product.php.

00152     {
00153         $products = $this->getRequest()->getPost('selected_products');
00154         if (is_null($products)) {
00155             $products = $this->getCategory()->getProductsPosition();
00156             return array_keys($products);
00157         }
00158         return $products;
00159     }

_prepareCollection (  )  [protected]

Prepare grid collection object

Returns:
this

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 71 of file Product.php.

00072     {
00073         if ($this->getCategory()->getId()) {
00074             $this->setDefaultFilter(array('in_category'=>1));
00075         }
00076         $collection = Mage::getModel('catalog/product')->getCollection()
00077             ->addAttributeToSelect('name')
00078             ->addAttributeToSelect('sku')
00079             ->addAttributeToSelect('price')
00080             ->addStoreFilter($this->getRequest()->getParam('store'))
00081             ->joinField('position',
00082                 'catalog/category_product',
00083                 'position',
00084                 'product_id=entity_id',
00085                 'category_id='.(int) $this->getRequest()->getParam('id', 0),
00086                 'left');
00087         $this->setCollection($collection);
00088 
00089         if ($this->getCategory()->getProductsReadonly()) {
00090             $productIds = $this->_getSelectedProducts();
00091             if (empty($productIds)) {
00092                 $productIds = 0;
00093             }
00094             $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
00095         }
00096 
00097         return parent::_prepareCollection();
00098     }

_prepareColumns (  )  [protected]

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 100 of file Product.php.

00101     {
00102         if (!$this->getCategory()->getProductsReadonly()) {
00103             $this->addColumn('in_category', array(
00104                 'header_css_class' => 'a-center',
00105                 'type'      => 'checkbox',
00106                 'name'      => 'in_category',
00107                 'values'    => $this->_getSelectedProducts(),
00108                 'align'     => 'center',
00109                 'index'     => 'entity_id'
00110             ));
00111         }
00112         $this->addColumn('entity_id', array(
00113             'header'    => Mage::helper('catalog')->__('ID'),
00114             'sortable'  => true,
00115             'width'     => '60',
00116             'index'     => 'entity_id'
00117         ));
00118         $this->addColumn('name', array(
00119             'header'    => Mage::helper('catalog')->__('Name'),
00120             'index'     => 'name'
00121         ));
00122         $this->addColumn('sku', array(
00123             'header'    => Mage::helper('catalog')->__('SKU'),
00124             'width'     => '80',
00125             'index'     => 'sku'
00126         ));
00127         $this->addColumn('price', array(
00128             'header'    => Mage::helper('catalog')->__('Price'),
00129             'type'  => 'currency',
00130             'width'     => '1',
00131             'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
00132             'index'     => 'price'
00133         ));
00134         $this->addColumn('position', array(
00135             'header'    => Mage::helper('catalog')->__('Position'),
00136             'width'     => '1',
00137             'type'      => 'number',
00138             'index'     => 'position',
00139             'editable'  => !$this->getCategory()->getProductsReadonly()
00140             //'renderer'  => 'adminhtml/widget_grid_column_renderer_input'
00141         ));
00142 
00143         return parent::_prepareColumns();
00144     }

getCategory (  ) 

Definition at line 45 of file Product.php.

00046     {
00047         return Mage::registry('category');
00048     }

getGridUrl (  ) 

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 146 of file Product.php.

00147     {
00148         return $this->getUrl('*/*/grid', array('_current'=>true));
00149     }


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

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