Public Member Functions | |
__construct () | |
getGridUrl () | |
getRowUrl ($row) | |
Protected Member Functions | |
_getStore () | |
_prepareCollection () | |
_addColumnFilterToCollection ($column) | |
_prepareColumns () | |
_prepareMassaction () |
Definition at line 34 of file Grid.php.
__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.
Reimplemented in Mage_Adminhtml_Block_Review_Product_Grid.
Definition at line 37 of file Grid.php.
00038 { 00039 parent::__construct(); 00040 $this->setId('productGrid'); 00041 $this->setDefaultSort('entity_id'); 00042 $this->setDefaultDir('desc'); 00043 $this->setSaveParametersInSession(true); 00044 $this->setUseAjax(true); 00045 $this->setVarNameFilter('product_filter'); 00046 00047 }
_addColumnFilterToCollection | ( | $ | column | ) | [protected] |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 91 of file Grid.php.
00092 { 00093 if ($this->getCollection()) { 00094 if ($column->getId() == 'websites') { 00095 $this->getCollection()->joinField('websites', 00096 'catalog/product_website', 00097 'website_id', 00098 'product_id=entity_id', 00099 null, 00100 'left'); 00101 } 00102 } 00103 return parent::_addColumnFilterToCollection($column); 00104 }
_getStore | ( | ) | [protected] |
Definition at line 49 of file Grid.php.
00050 { 00051 $storeId = (int) $this->getRequest()->getParam('store', 0); 00052 return Mage::app()->getStore($storeId); 00053 }
_prepareCollection | ( | ) | [protected] |
Prepare grid collection object
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 55 of file Grid.php.
00056 { 00057 $store = $this->_getStore(); 00058 $collection = Mage::getModel('catalog/product')->getCollection() 00059 ->addAttributeToSelect('sku') 00060 ->addAttributeToSelect('name') 00061 ->addAttributeToSelect('attribute_set_id') 00062 ->addAttributeToSelect('type_id') 00063 ->joinField('qty', 00064 'cataloginventory/stock_item', 00065 'qty', 00066 'product_id=entity_id', 00067 '{{table}}.stock_id=1', 00068 'left'); 00069 00070 if ($store->getId()) { 00071 //$collection->setStoreId($store->getId()); 00072 $collection->addStoreFilter($store); 00073 $collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId()); 00074 $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId()); 00075 $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId()); 00076 $collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId()); 00077 } 00078 else { 00079 $collection->addAttributeToSelect('price'); 00080 $collection->addAttributeToSelect('status'); 00081 $collection->addAttributeToSelect('visibility'); 00082 } 00083 00084 $this->setCollection($collection); 00085 00086 parent::_prepareCollection(); 00087 $this->getCollection()->addWebsiteNamesToResult(); 00088 return $this; 00089 }
_prepareColumns | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Reimplemented in Mage_Adminhtml_Block_Review_Product_Grid, and Mage_Adminhtml_Block_Urlrewrite_Product_Grid.
Definition at line 106 of file Grid.php.
00107 { 00108 $this->addColumn('entity_id', 00109 array( 00110 'header'=> Mage::helper('catalog')->__('ID'), 00111 'width' => '50px', 00112 'type' => 'number', 00113 'index' => 'entity_id', 00114 )); 00115 $this->addColumn('name', 00116 array( 00117 'header'=> Mage::helper('catalog')->__('Name'), 00118 'index' => 'name', 00119 )); 00120 00121 $store = $this->_getStore(); 00122 if ($store->getId()) { 00123 $this->addColumn('custom_name', 00124 array( 00125 'header'=> Mage::helper('catalog')->__('Name In %s', $store->getName()), 00126 'index' => 'custom_name', 00127 )); 00128 } 00129 00130 $this->addColumn('type', 00131 array( 00132 'header'=> Mage::helper('catalog')->__('Type'), 00133 'width' => '60px', 00134 'index' => 'type_id', 00135 'type' => 'options', 00136 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(), 00137 )); 00138 00139 $sets = Mage::getResourceModel('eav/entity_attribute_set_collection') 00140 ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId()) 00141 ->load() 00142 ->toOptionHash(); 00143 00144 $this->addColumn('set_name', 00145 array( 00146 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'), 00147 'width' => '100px', 00148 'index' => 'attribute_set_id', 00149 'type' => 'options', 00150 'options' => $sets, 00151 )); 00152 00153 $this->addColumn('sku', 00154 array( 00155 'header'=> Mage::helper('catalog')->__('SKU'), 00156 'width' => '80px', 00157 'index' => 'sku', 00158 )); 00159 00160 $store = $this->_getStore(); 00161 $this->addColumn('price', 00162 array( 00163 'header'=> Mage::helper('catalog')->__('Price'), 00164 'type' => 'price', 00165 'currency_code' => $store->getBaseCurrency()->getCode(), 00166 'index' => 'price', 00167 )); 00168 00169 $this->addColumn('qty', 00170 array( 00171 'header'=> Mage::helper('catalog')->__('Qty'), 00172 'width' => '100px', 00173 'type' => 'number', 00174 'index' => 'qty', 00175 )); 00176 00177 $this->addColumn('visibility', 00178 array( 00179 'header'=> Mage::helper('catalog')->__('Visibility'), 00180 'width' => '70px', 00181 'index' => 'visibility', 00182 'type' => 'options', 00183 'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(), 00184 )); 00185 00186 $this->addColumn('status', 00187 array( 00188 'header'=> Mage::helper('catalog')->__('Status'), 00189 'width' => '70px', 00190 'index' => 'status', 00191 'type' => 'options', 00192 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(), 00193 )); 00194 00195 if (!Mage::app()->isSingleStoreMode()) { 00196 $this->addColumn('websites', 00197 array( 00198 'header'=> Mage::helper('catalog')->__('Websites'), 00199 'width' => '100px', 00200 'sortable' => false, 00201 'index' => 'websites', 00202 'type' => 'options', 00203 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(), 00204 )); 00205 } 00206 00207 $this->addColumn('action', 00208 array( 00209 'header' => Mage::helper('catalog')->__('Action'), 00210 'width' => '50px', 00211 'type' => 'action', 00212 'getter' => 'getId', 00213 'actions' => array( 00214 array( 00215 'caption' => Mage::helper('catalog')->__('Edit'), 00216 'url' => array( 00217 'base'=>'*/*/edit', 00218 'params'=>array('store'=>$this->getRequest()->getParam('store')) 00219 ), 00220 'field' => 'id' 00221 ) 00222 ), 00223 'filter' => false, 00224 'sortable' => false, 00225 'index' => 'stores', 00226 )); 00227 00228 $this->addRssList('rss/catalog/notifystock', Mage::helper('catalog')->__('Notify Low Stock RSS')); 00229 00230 return parent::_prepareColumns(); 00231 }
_prepareMassaction | ( | ) | [protected] |
Prepare grid massaction actions
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Reimplemented in Mage_Adminhtml_Block_Review_Product_Grid, and Mage_Adminhtml_Block_Urlrewrite_Product_Grid.
Definition at line 233 of file Grid.php.
00234 { 00235 $this->setMassactionIdField('entity_id'); 00236 $this->getMassactionBlock()->setFormFieldName('product'); 00237 00238 $this->getMassactionBlock()->addItem('delete', array( 00239 'label'=> Mage::helper('catalog')->__('Delete'), 00240 'url' => $this->getUrl('*/*/massDelete'), 00241 'confirm' => Mage::helper('catalog')->__('Are you sure?') 00242 )); 00243 00244 $statuses = Mage::getSingleton('catalog/product_status')->getOptionArray(); 00245 00246 array_unshift($statuses, array('label'=>'', 'value'=>'')); 00247 $this->getMassactionBlock()->addItem('status', array( 00248 'label'=> Mage::helper('catalog')->__('Change status'), 00249 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)), 00250 'additional' => array( 00251 'visibility' => array( 00252 'name' => 'status', 00253 'type' => 'select', 00254 'class' => 'required-entry', 00255 'label' => Mage::helper('catalog')->__('Status'), 00256 'values' => $statuses 00257 ) 00258 ) 00259 )); 00260 00261 $this->getMassactionBlock()->addItem('attributes', array( 00262 'label' => Mage::helper('catalog')->__('Update attributes'), 00263 'url' => $this->getUrl('*/catalog_product_action_attribute/edit', array('_current'=>true)) 00264 )); 00265 00266 return $this; 00267 }
getGridUrl | ( | ) |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Reimplemented in Mage_Adminhtml_Block_Review_Product_Grid, and Mage_Adminhtml_Block_Urlrewrite_Product_Grid.
Definition at line 269 of file Grid.php.
getRowUrl | ( | $ | row | ) |
Reimplemented in Mage_Adminhtml_Block_Review_Product_Grid, and Mage_Adminhtml_Block_Urlrewrite_Product_Grid.
Definition at line 274 of file Grid.php.
00275 { 00276 return $this->getUrl('*/*/edit', array( 00277 'store'=>$this->getRequest()->getParam('store'), 00278 'id'=>$row->getId()) 00279 ); 00280 }