Public Member Functions | |
__construct () | |
getTabUrl () | |
getTabClass () | |
getGridUrl () | |
getTabLabel () | |
getTabTitle () | |
canShowTab () | |
isHidden () | |
Protected Member Functions | |
_getProduct () | |
_addColumnFilterToCollection ($column) | |
_prepareCollection () | |
_prepareColumns () | |
_getSelectedProducts () |
Definition at line 34 of file Group.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.
Definition at line 36 of file Group.php.
00037 { 00038 parent::__construct(); 00039 $this->setId('super_product_grid'); 00040 $this->setDefaultSort('entity_id'); 00041 $this->setSkipGenerateContent(true); 00042 $this->setUseAjax(true); 00043 if ($this->_getProduct()->getId()) { 00044 $this->setDefaultFilter(array('in_products'=>1)); 00045 } 00046 }
_addColumnFilterToCollection | ( | $ | column | ) | [protected] |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 68 of file Group.php.
00069 { 00070 // Set custom filter for in product flag 00071 if ($column->getId() == 'in_products') { 00072 $productIds = $this->_getSelectedProducts(); 00073 if (empty($productIds)) { 00074 $productIds = 0; 00075 } 00076 if ($column->getFilter()->getValue()) { 00077 $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds)); 00078 } 00079 else { 00080 $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds)); 00081 } 00082 } 00083 else { 00084 parent::_addColumnFilterToCollection($column); 00085 } 00086 00087 return $this; 00088 }
_getProduct | ( | ) | [protected] |
Retirve currently edited product model
Definition at line 63 of file Group.php.
00064 { 00065 return Mage::registry('current_product'); 00066 }
_getSelectedProducts | ( | ) | [protected] |
Definition at line 170 of file Group.php.
00171 { 00172 $products = $this->getRequest()->getPost('products', null); 00173 if (!is_array($products)) { 00174 $products = $this->_getProduct()->getTypeInstance(true)->getAssociatedProductIds($this->_getProduct()); 00175 } 00176 return $products; 00177 }
_prepareCollection | ( | ) | [protected] |
Prepare grid collection object
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 90 of file Group.php.
00091 { 00092 $allowProductTypes = array(); 00093 foreach (Mage::getConfig()->getNode('global/catalog/product/type/grouped/allow_product_types')->children() as $type) { 00094 $allowProductTypes[] = $type->getName(); 00095 } 00096 00097 $collection = Mage::getModel('catalog/product_link')->useGroupedLinks() 00098 ->getProductCollection() 00099 ->setProduct($this->_getProduct()) 00100 ->addAttributeToSelect('*') 00101 ->addFilterByRequiredOptions() 00102 ->addAttributeToFilter('type_id', $allowProductTypes); 00103 00104 $this->setCollection($collection); 00105 return parent::_prepareCollection(); 00106 }
_prepareColumns | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 108 of file Group.php.
00109 { 00110 $this->addColumn('in_products', array( 00111 'header_css_class' => 'a-center', 00112 'type' => 'checkbox', 00113 'name' => 'in_products', 00114 'values' => $this->_getSelectedProducts(), 00115 'align' => 'center', 00116 'index' => 'entity_id' 00117 )); 00118 00119 $this->addColumn('entity_id', array( 00120 'header' => Mage::helper('catalog')->__('ID'), 00121 'sortable' => true, 00122 'width' => '60px', 00123 'index' => 'entity_id' 00124 )); 00125 $this->addColumn('name', array( 00126 'header' => Mage::helper('catalog')->__('Name'), 00127 'index' => 'name' 00128 )); 00129 $this->addColumn('sku', array( 00130 'header' => Mage::helper('catalog')->__('SKU'), 00131 'width' => '80px', 00132 'index' => 'sku' 00133 )); 00134 $this->addColumn('price', array( 00135 'header' => Mage::helper('catalog')->__('Price'), 00136 'type' => 'currency', 00137 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE), 00138 'index' => 'price' 00139 )); 00140 00141 $this->addColumn('qty', array( 00142 'header' => Mage::helper('catalog')->__('Default Qty'), 00143 'name' => 'qty', 00144 'type' => 'number', 00145 'validate_class' => 'validate-number', 00146 'index' => 'qty', 00147 'width' => '1', 00148 'editable' => true 00149 )); 00150 00151 $this->addColumn('position', array( 00152 'header' => Mage::helper('catalog')->__('Position'), 00153 'name' => 'position', 00154 'type' => 'number', 00155 'validate_class' => 'validate-number', 00156 'index' => 'position', 00157 'width' => '1', 00158 'editable' => true, 00159 'edit_only' => !$this->_getProduct()->getId() 00160 )); 00161 00162 return parent::_prepareColumns(); 00163 }
canShowTab | ( | ) |
getGridUrl | ( | ) |
getTabLabel | ( | ) |
Implements Mage_Adminhtml_Block_Widget_Tab_Interface.
Definition at line 179 of file Group.php.
00180 { 00181 return Mage::helper('catalog')->__('Associated Products'); 00182 }
getTabTitle | ( | ) |
Implements Mage_Adminhtml_Block_Widget_Tab_Interface.
Definition at line 183 of file Group.php.
00184 { 00185 return Mage::helper('catalog')->__('Associated Products'); 00186 }
getTabUrl | ( | ) |
isHidden | ( | ) |