00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist extends Mage_Adminhtml_Block_Widget_Grid
00036 {
00037
00038
00039
00040
00041
00042 protected $_parentTemplate;
00043
00044
00045
00046
00047
00048 public function __construct()
00049 {
00050 parent::__construct();
00051 $this->setId('wishlistGrid');
00052 $this->setUseAjax(true);
00053 $this->_parentTemplate = $this->getTemplate();
00054 $this->setTemplate('customer/tab/wishlist.phtml');
00055 $this->setEmptyText(Mage::helper('customer')->__('No Items Found'));
00056 }
00057
00058
00059
00060
00061
00062
00063 protected function _getCustomer()
00064 {
00065 return Mage::registry('current_customer');
00066 }
00067
00068
00069
00070
00071
00072
00073 protected function _prepareCollection()
00074 {
00075 $collection = Mage::getModel('wishlist/wishlist')
00076 ->loadByCustomer($this->_getCustomer())
00077 ->setSharedStoreIds($this->_getCustomer()->getSharedStoreIds())
00078 ->getProductCollection()
00079 ->addAttributeToSelect('name')
00080 ->addAttributeToSelect('price')
00081 ->addAttributeToSelect('small_image')
00082 ->addStoreData();
00083
00084 $this->setCollection($collection);
00085
00086 return parent::_prepareCollection();
00087 }
00088
00089
00090
00091
00092
00093
00094 protected function _prepareColumns()
00095 {
00096
00097
00098
00099
00100
00101
00102
00103
00104 $this->addColumn('product_name', array(
00105 'header' => Mage::helper('customer')->__('Product name'),
00106 'index' => 'name'
00107 ));
00108
00109 $this->addColumn('description', array(
00110 'header' => Mage::helper('customer')->__('User description'),
00111 'index' => 'description',
00112 'renderer' => 'adminhtml/customer_edit_tab_wishlist_grid_renderer_description'
00113 ));
00114
00115 if (!Mage::app()->isSingleStoreMode()) {
00116 $this->addColumn('store', array(
00117 'header' => Mage::helper('customer')->__('Added From'),
00118 'index' => 'store_name',
00119 'type' => 'store'
00120 ));
00121 }
00122
00123 $this->addColumn('visible_in', array(
00124 'header' => Mage::helper('customer')->__('Visible In'),
00125 'index' => 'store_id',
00126 'type' => 'store'
00127 ));
00128
00129 $this->addColumn('added_at', array(
00130 'header' => Mage::helper('customer')->__('Date Added'),
00131 'index' => 'added_at',
00132 'gmtoffset' => true,
00133 'type' => 'date'
00134 ));
00135
00136 $this->addColumn('days', array(
00137 'header' => Mage::helper('customer')->__('Days in Wishlist'),
00138 'index' => 'days_in_wishlist',
00139 'type' => 'number'
00140 ));
00141
00142 $this->addColumn('action', array(
00143 'header' => Mage::helper('customer')->__('Action'),
00144 'index' => 'wishlist_item_id',
00145 'type' => 'action',
00146 'filter' => false,
00147 'sortable' => false,
00148 'actions' => array(
00149 array(
00150 'caption' => Mage::helper('customer')->__('Delete'),
00151 'url' => '#',
00152 'onclick' => 'return wishlistControl.removeItem($wishlist_item_id);'
00153 )
00154 )
00155 ));
00156
00157 return parent::_prepareColumns();
00158 }
00159
00160
00161
00162
00163
00164
00165 public function getGridUrl()
00166 {
00167 return $this->getUrl('*/*/wishlist', array('_current'=>true));
00168 }
00169
00170
00171
00172
00173
00174
00175
00176 protected function _addColumnFilterToCollection($column)
00177 {
00178 if($column->getId()=='store') {
00179 $this->getCollection()->addFieldToFilter('store_id', $column->getFilter()->getCondition());
00180 return $this;
00181 }
00182
00183 if ($this->getCollection() && $column->getFilter()->getValue()) {
00184 $this->getCollection()->addFieldToFilter($column->getIndex(), $column->getFilter()->getCondition());
00185 }
00186
00187 return $this;
00188 }
00189
00190
00191
00192
00193
00194
00195 public function getGridParentHtml()
00196 {
00197 $templateName = Mage::getDesign()->getTemplateFilename($this->_parentTemplate, array('_relative'=>true));
00198 return $this->fetchView($templateName);
00199 }
00200
00201
00202
00203
00204
00205
00206 public function getRowUrl($row)
00207 {
00208 return $this->getUrl('*/catalog_product/edit', array('id' => $row->getProductId()));
00209 }
00210 }