Public Member Functions | |
__construct () | |
isReadonly () | |
getGridUrl () | |
Protected Member Functions | |
_getProduct () | |
_addColumnFilterToCollection ($column) | |
_prepareCollection () | |
_prepareColumns () | |
_getSelectedProducts () |
Definition at line 34 of file Upsell.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 37 of file Upsell.php.
00038 { 00039 parent::__construct(); 00040 $this->setId('up_sell_product_grid'); 00041 $this->setDefaultSort('entity_id'); 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 58 of file Upsell.php.
00059 { 00060 // Set custom filter for in product flag 00061 if ($column->getId() == 'in_products') { 00062 $productIds = $this->_getSelectedProducts(); 00063 if (empty($productIds)) { 00064 $productIds = 0; 00065 } 00066 if ($column->getFilter()->getValue()) { 00067 $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds)); 00068 } 00069 else { 00070 if($productIds) { 00071 $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds)); 00072 } 00073 } 00074 } 00075 else { 00076 parent::_addColumnFilterToCollection($column); 00077 } 00078 return $this; 00079 }
_getProduct | ( | ) | [protected] |
Retirve currently edited product model
Definition at line 53 of file Upsell.php.
00054 { 00055 return Mage::registry('current_product'); 00056 }
_getSelectedProducts | ( | ) | [protected] |
Definition at line 206 of file Upsell.php.
00207 { 00208 $products = $this->getRequest()->getPost('products', null); 00209 if (!is_array($products)) { 00210 $products = $this->_getProduct()->getUpSellProductIds(); 00211 } 00212 return $products; 00213 }
_prepareCollection | ( | ) | [protected] |
Prepare grid collection object
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 91 of file Upsell.php.
00092 { 00093 $collection = Mage::getModel('catalog/product_link')->useUpSellLinks() 00094 ->getProductCollection() 00095 ->setProduct($this->_getProduct()) 00096 ->addAttributeToSelect('*'); 00097 00098 if ($this->isReadonly()) { 00099 $productIds = $this->_getSelectedProducts(); 00100 if (empty($productIds)) { 00101 $productIds = array(0); 00102 } 00103 $collection->addFieldToFilter('entity_id', array('in'=>$productIds)); 00104 } 00105 00106 $this->setCollection($collection); 00107 return parent::_prepareCollection(); 00108 }
_prepareColumns | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 110 of file Upsell.php.
00111 { 00112 if (!$this->_getProduct()->getUpsellReadonly()) { 00113 $this->addColumn('in_products', array( 00114 'header_css_class' => 'a-center', 00115 'type' => 'checkbox', 00116 'name' => 'in_products', 00117 'values' => $this->_getSelectedProducts(), 00118 'align' => 'center', 00119 'index' => 'entity_id' 00120 )); 00121 } 00122 00123 $this->addColumn('entity_id', array( 00124 'header' => Mage::helper('catalog')->__('ID'), 00125 'sortable' => true, 00126 'width' => '60px', 00127 'index' => 'entity_id' 00128 )); 00129 $this->addColumn('name', array( 00130 'header' => Mage::helper('catalog')->__('Name'), 00131 'index' => 'name' 00132 )); 00133 00134 $this->addColumn('type', 00135 array( 00136 'header'=> Mage::helper('catalog')->__('Type'), 00137 'width' => '100px', 00138 'index' => 'type_id', 00139 'type' => 'options', 00140 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(), 00141 )); 00142 00143 $sets = Mage::getResourceModel('eav/entity_attribute_set_collection') 00144 ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId()) 00145 ->load() 00146 ->toOptionHash(); 00147 00148 $this->addColumn('set_name', 00149 array( 00150 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'), 00151 'width' => '130px', 00152 'index' => 'attribute_set_id', 00153 'type' => 'options', 00154 'options' => $sets, 00155 )); 00156 00157 $this->addColumn('status', 00158 array( 00159 'header'=> Mage::helper('catalog')->__('Status'), 00160 'width' => '90px', 00161 'index' => 'status', 00162 'type' => 'options', 00163 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(), 00164 )); 00165 00166 $this->addColumn('visibility', 00167 array( 00168 'header'=> Mage::helper('catalog')->__('Visibility'), 00169 'width' => '90px', 00170 'index' => 'visibility', 00171 'type' => 'options', 00172 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(), 00173 )); 00174 00175 $this->addColumn('sku', array( 00176 'header' => Mage::helper('catalog')->__('SKU'), 00177 'width' => '80px', 00178 'index' => 'sku' 00179 )); 00180 $this->addColumn('price', array( 00181 'header' => Mage::helper('catalog')->__('Price'), 00182 'type' => 'currency', 00183 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE), 00184 'index' => 'price' 00185 )); 00186 00187 $this->addColumn('position', array( 00188 'header' => Mage::helper('catalog')->__('Position'), 00189 'name' => 'position', 00190 'type' => 'number', 00191 'width' => '60px', 00192 'validate_class' => 'validate-number', 00193 'index' => 'position', 00194 'editable' => !$this->_getProduct()->getUpsellReadonly(), 00195 'edit_only' => !$this->_getProduct()->getId() 00196 )); 00197 00198 return parent::_prepareColumns(); 00199 }
getGridUrl | ( | ) |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 201 of file Upsell.php.
00202 { 00203 return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/upsell', array('_current'=>true)); 00204 }
isReadonly | ( | ) |
Checks when this block is readonly
Definition at line 86 of file Upsell.php.
00087 { 00088 return $this->_getProduct()->getUpsellReadonly(); 00089 }