Public Member Functions | |
__construct () | |
getGridUrl () | |
Protected Member Functions | |
_beforeToHtml () | |
_prepareCollection () | |
_prepareColumns () | |
_prepareMassaction () | |
_getGoogleBaseProductIds () | |
_getStore () |
Definition at line 34 of file Product.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 Product.php.
00038 { 00039 parent::__construct(); 00040 $this->setId('googlebase_selection_search_grid'); 00041 $this->setDefaultSort('id'); 00042 $this->setUseAjax(true); 00043 }
_beforeToHtml | ( | ) | [protected] |
Before rendering html, but after trying to load cache
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 45 of file Product.php.
00046 { 00047 $this->setId($this->getId().'_'.$this->getIndex()); 00048 $this->getChild('reset_filter_button')->setData('onclick', $this->getJsObjectName().'.resetFilter()'); 00049 $this->getChild('search_button')->setData('onclick', $this->getJsObjectName().'.doFilter()'); 00050 return parent::_beforeToHtml(); 00051 }
_getGoogleBaseProductIds | ( | ) | [protected] |
Definition at line 142 of file Product.php.
00143 { 00144 $collection = Mage::getResourceModel('googlebase/item_collection') 00145 ->addStoreFilterId($this->_getStore()->getId()) 00146 ->load(); 00147 $productIds = array(); 00148 foreach ($collection as $item) { 00149 $productIds[] = $item->getProductId(); 00150 } 00151 return $productIds; 00152 }
_getStore | ( | ) | [protected] |
Definition at line 154 of file Product.php.
00155 { 00156 return Mage::app()->getStore($this->getRequest()->getParam('store')); 00157 }
_prepareCollection | ( | ) | [protected] |
Prepare grid collection object
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 53 of file Product.php.
00054 { 00055 $collection = Mage::getModel('catalog/product')->getCollection() 00056 ->setStore($this->_getStore()) 00057 ->addAttributeToSelect('name') 00058 ->addAttributeToSelect('sku') 00059 ->addAttributeToSelect('price') 00060 ->addAttributeToSelect('attribute_set_id'); 00061 // ->addFilterByRequiredOptions(); 00062 00063 $store = $this->_getStore(); 00064 if ($store->getId()) { 00065 $collection->addStoreFilter($store); 00066 } 00067 00068 if ($excludeIds = $this->_getGoogleBaseProductIds()) { 00069 $collection->addIdFilter($excludeIds, true); 00070 } 00071 00072 Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection); 00073 00074 $this->setCollection($collection); 00075 00076 return parent::_prepareCollection(); 00077 }
_prepareColumns | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 79 of file Product.php.
00080 { 00081 $this->addColumn('id', array( 00082 'header' => Mage::helper('sales')->__('ID'), 00083 'sortable' => true, 00084 'width' => '60px', 00085 'index' => 'entity_id' 00086 )); 00087 $this->addColumn('name', array( 00088 'header' => Mage::helper('sales')->__('Product Name'), 00089 'index' => 'name', 00090 'column_css_class'=> 'name' 00091 )); 00092 00093 $sets = Mage::getResourceModel('eav/entity_attribute_set_collection') 00094 ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId()) 00095 ->load() 00096 ->toOptionHash(); 00097 00098 $this->addColumn('set_name', 00099 array( 00100 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'), 00101 'width' => '100px', 00102 'index' => 'attribute_set_id', 00103 'type' => 'options', 00104 'options' => $sets, 00105 )); 00106 00107 $this->addColumn('sku', array( 00108 'header' => Mage::helper('sales')->__('SKU'), 00109 'width' => '80px', 00110 'index' => 'sku', 00111 'column_css_class'=> 'sku' 00112 )); 00113 $this->addColumn('price', array( 00114 'header' => Mage::helper('sales')->__('Price'), 00115 'align' => 'center', 00116 'type' => 'currency', 00117 'currency_code' => $this->_getStore()->getCurrentCurrencyCode(), 00118 'rate' => $this->_getStore()->getBaseCurrency()->getRate($this->_getStore()->getCurrentCurrencyCode()), 00119 'index' => 'price' 00120 )); 00121 00122 return parent::_prepareColumns(); 00123 }
_prepareMassaction | ( | ) | [protected] |
Prepare grid massaction actions
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 125 of file Product.php.
00126 { 00127 $this->setMassactionIdField('product_id'); 00128 $this->getMassactionBlock()->setFormFieldName('product'); 00129 00130 $this->getMassactionBlock()->addItem('add', array( 00131 'label' => $this->__('Add to Google Base'), 00132 'url' => $this->getUrl('*/*/massAdd', array('_current'=>true)), 00133 )); 00134 return $this; 00135 }
getGridUrl | ( | ) |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 137 of file Product.php.
00138 { 00139 return $this->getUrl('googlebase/selection/grid', array('index' => $this->getIndex(),'_current'=>true)); 00140 }