TBT_Enhancedgrid - Version 1.3.2.0

Version Notes

Improved some of the architecture to make the grid column handlers more expandable in the future, and resolved issue with Magento Community Edition 1.6+ and Magento Enterprise/Professional Editions 1.11+

Download this release

Release Info

Developer Magento Core Team
Extension TBT_Enhancedgrid
Version 1.3.2.0
Comparing to
See all releases


Code changes from version 1.3.1.3 to 1.3.2.0

app/code/community/TBT/Enhancedgrid/Block/Catalog/Product/Grid.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category WDCA
22
  * @package TBT_Enhancedgrid
23
- * @copyright Copyright (c) 2008-2010 WDCA (http://www.wdca.ca)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -31,590 +31,606 @@
31
  * @package TBT_Enhancedgrid
32
  * @author WDCA <contact@wdca.ca>
33
  */
34
- class TBT_Enhancedgrid_Block_Catalog_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
- {
36
  protected $isenhanced = true;
 
37
  private $columnSettings = array();
 
 
38
  private $columnOptions = array();
 
39
  private $isenabled = true;
40
 
41
- public function __construct()
42
- {
 
43
  parent::__construct();
44
- $this->isenabled = Mage::getStoreConfig('enhancedgrid/general/isenabled');
 
 
45
 
46
- $this->setId('productGrid');
47
-
48
  $this->prepareDefaults();
49
 
50
- $this->setSaveParametersInSession(true);
51
- $this->setUseAjax(true);
52
- $this->setVarNameFilter('product_filter');
53
 
54
  $this->prepareColumnSettings();
55
- $this->setTemplate('tbt/enhancedgrid/catalog/product/grid.phtml');
56
-
57
- }
58
 
59
- protected function prepareDefaults() {
60
- $this->setDefaultLimit(Mage::getStoreConfig('enhancedgrid/defaults/limit'));
61
- $this->setDefaultPage(Mage::getStoreConfig('enhancedgrid/defaults/page'));
62
- $this->setDefaultSort(Mage::getStoreConfig('enhancedgrid/defaults/sort'));
63
- $this->setDefaultDir(Mage::getStoreConfig('enhancedgrid/defaults/dir'));
64
-
65
  }
 
 
 
 
 
 
66
 
 
 
67
  protected function prepareColumnSettings() {
68
- $storeSettings = Mage::getStoreConfig('enhancedgrid/columns/showcolumns');
69
-
70
- $tempArr = explode(',', $storeSettings);
71
 
72
- foreach($tempArr as $showCol) {
73
- $this->columnSettings[trim($showCol)] = true;
74
- }
75
  }
76
 
 
 
 
 
 
 
 
77
  public function colIsVisible($code) {
78
- return isset($this->columnSettings[$code]);
79
  }
80
-
81
  protected function _isSpecialCol($col) {
82
- return ($col == 'qty' || $col == 'websites' || $col=='id' || $col == 'categories');
83
  }
84
-
85
- protected function _prepareLayout()
86
- {
87
- $this->setChild('export_button',
88
- $this->getLayout()->createBlock('adminhtml/widget_button')
89
- ->setData(array(
90
- 'label' => Mage::helper('adminhtml')->__('Export'),
91
- 'onclick' => $this->getJsObjectName().'.doExport()',
92
- 'class' => 'task'
93
- ))
94
- );
95
- $this->setChild('reset_filter_button',
96
- $this->getLayout()->createBlock('adminhtml/widget_button')
97
- ->setData(array(
98
- 'label' => Mage::helper('adminhtml')->__('Reset Filter'),
99
- 'onclick' => $this->getJsObjectName().'.resetFilter()',
100
- ))
101
- );
102
- $this->setChild('search_button',
103
- $this->getLayout()->createBlock('adminhtml/widget_button')
104
- ->setData(array(
105
- 'label' => Mage::helper('adminhtml')->__('Search'),
106
- 'onclick' => $this->getJsObjectName().'.doFilter()',
107
- 'class' => 'task'
108
- ))
109
- );
 
 
110
  return parent::_prepareLayout();
111
  }
 
112
  public function getQueryStr() {
113
- return urldecode($this->getParam('q'));
114
  }
 
115
  /**
116
  * get collection object
117
  * //@nelkaake -a 13/11/10: this is just here for the codeassist function
118
  *
119
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
120
  */
121
- public function getCollection()
122
- {
123
  return parent::getCollection();
124
  }
125
- protected function _prepareCollection()
126
- {
 
127
  $collection = $this->getCollection();
128
  //@nelkaake -m 13/11/10: Just made it a little nicer
129
  $queryString = $this->getQueryStr();
130
- if($queryString) {
131
- $collection = Mage::helper('enhancedgrid')
132
- ->getSearchCollection($queryString, $this->getRequest());
133
  }
134
- if(!$collection) {
135
- //@nelkaake -a 15/12/10: To fix categories column issue this is a tempoary way we are going to load the modified collection class.
 
136
  $collection = new TBT_Enhancedgrid_Model_Resource_Eav_Mysql4_Product_Collection();
137
  }
138
  $store = $this->_getStore();
139
- $collection
140
- ->joinField('qty',
141
- 'cataloginventory/stock_item',
142
- 'qty',
143
- 'product_id=entity_id',
144
- '{{table}}.stock_id=1',
145
- 'left');
146
- $collection->addAttributeToSelect('sku');
147
 
148
  //$collection->addAttributeToSelect('attribute_set_id');
149
  //$collection->addAttributeToSelect('type_id');
150
-
151
- if ($store->getId()) {
 
152
  //$collection->setStoreId($store->getId());
153
- $collection->addStoreFilter($store->getId());
154
- $collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
155
- $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
156
- $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId());
157
- $collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
158
- }
159
- else {
160
- $collection->addAttributeToSelect('price');
161
- $collection->addAttributeToSelect('status');
162
- $collection->addAttributeToSelect('visibility');
163
  }
164
  // EG: Select all needed columns.
165
  //id,name,type,attribute_set,sku,price,qty,visibility,status,websites,image
166
- foreach($this->columnSettings as $col => $true) {
167
- if($this->_isSpecialCol($col)) continue;
168
- $collection->addAttributeToSelect($col);
169
  }
170
 
171
- if($this->colIsVisible('categories')) {
172
- $this->setJoinCategories(true);
173
  }
174
 
175
- $this->setCollection($collection);
176
 
177
- $this->addExportType('*/*/exportCsv', Mage::helper('customer')->__('CSV'));
178
- $this->addExportType('*/*/exportXml', Mage::helper('customer')->__('XML'));
179
 
180
  parent::_prepareCollection();
181
  $collection->addWebsiteNamesToResult();
182
 
183
  return $this;
184
  }
185
-
186
  /**
187
  * if the attribute has options an options entry will be
188
  * added to $columnOptions
189
- */
190
  protected function loadColumnOptions($attr_code) {
191
- $attr = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', $attr_code);
192
- if(sizeof($attr->getData()) > 0) {
193
- if($attr->getFrontendInput() == 'select') {
194
- //@nelkaake -a 13/11/10:
195
- if($attr->getSourceModel() != null) {
196
- $sourcemodel = Mage::getModel($attr->getSourceModel());
197
- //@nelkaake -a 16/11/10:
198
- $sourcemodel->setAttribute($attr);
199
- if(method_exists($sourcemodel, 'getAllOptions')) {
200
- try {
201
- //die($attr->getSourceModel());
202
- $values = $sourcemodel->getAllOptions();
203
-
204
- $options = array();
205
-
206
- foreach($values as $value) {
207
-
208
- $options[$value['value']] = $value['label'];
209
- }
210
- //die($attr_code);
211
- $this->columnOptions[$attr_code] = $options;
212
- return;
213
- } catch (Exception $e) {
214
- Mage::log("Tried to get options for {$attr_code} using getAllOptions on {$attr->getSourceModel()}, but an exception occured: ". (String)$e);
215
- }
216
- }
 
 
217
  }
218
- //@nelkaake -a 13/11/10:
219
- $values = Mage::getResourceModel('eav/entity_attribute_option_collection')
220
- ->setAttributeFilter($attr->getId())
221
- ->setStoreFilter($this->_getStore()->getId(), false)
 
222
  ->load();
223
  $options = array();
224
- foreach($values as $value) {
225
  $options[$value->getOptionId()] = $value->getValue();
226
  }
227
  //die($attr_code);
228
  $this->columnOptions[$attr_code] = $options;
229
- //die(print_r($this->columnOptions, true));
 
230
  }
231
  }
232
-
233
- }
234
 
 
235
 
236
-
237
- protected function _getStore()
238
- {
239
- $storeId = (int) $this->getRequest()->getParam('store', 0);
240
- $store = Mage::app()->getStore($storeId);
241
- if($store->getId() != $storeId) $store = Mage::app()->getStore(0);
242
  return $store;
243
  }
244
 
245
-
246
- protected function _addColumnFilterToCollection($column)
247
- {
248
- if ($this->getCollection()) {
249
- if ($column->getId() == 'websites') {
250
- $this->getCollection()->joinField('websites',
251
- 'catalog/product_website',
252
- 'website_id',
253
- 'product_id=entity_id',
254
- null,
255
- 'left');
256
  }
257
  }
258
- return parent::_addColumnFilterToCollection($column);
259
  }
260
 
261
- protected function _prepareColumns()
262
- {
263
  // Loads all the column options for each applicable column.
264
- foreach($this->columnSettings as $col => $true) {
265
- $this->loadColumnOptions($col);
266
  }
267
 
268
  $store = $this->_getStore();
269
- if($this->colIsVisible('id')) {
270
- $this->addColumn('id',
271
  array(
272
- 'header'=> Mage::helper('catalog')->__('ID'),
273
- 'width' => '50px',
274
- 'type' => 'number',
275
- 'index' => 'entity_id',
276
- ));
277
  }
278
 
279
- $imgWidth = Mage::getStoreConfig('enhancedgrid/images/width') + "px";
280
 
281
- if($this->colIsVisible('thumbnail')) {
282
- $this->addColumn('thumbnail',
283
  array(
284
- 'header'=> Mage::helper('catalog')->__('Thumbnail'),
285
- 'type' => 'image',
286
- 'width' => $imgWidth,
287
- 'index' => 'thumbnail',
288
- ));
289
  }
290
- if($this->colIsVisible('small_image')) {
291
- $this->addColumn('small_image',
292
  array(
293
- 'header'=> Mage::helper('catalog')->__('Small Img'),
294
- 'type' => 'image',
295
- 'width' => $imgWidth,
296
- 'index' => 'small_image',
297
- ));
298
  }
299
- if($this->colIsVisible('image')) {
300
- $this->addColumn('image',
301
  array(
302
- 'header'=> Mage::helper('catalog')->__('Image'),
303
- 'type' => 'image',
304
- 'width' => $imgWidth,
305
- 'index' => 'image',
306
- ));
307
  }
308
 
309
- if($this->colIsVisible('name')) {
310
- $this->addColumn('name',
311
  array(
312
- 'header'=> Mage::helper('catalog')->__('Name'),
313
- 'index' => 'name',
314
- // 'width' => '150px'
315
- ));
316
  }
317
- if($this->colIsVisible('name')) {
318
- if ($store->getId()) {
319
- $this->addColumn('custom_name',
320
  array(
321
- 'header'=> Mage::helper('catalog')->__('Name In %s', $store->getName()),
322
- 'index' => 'custom_name',
323
  'width' => '150px'
324
- ));
325
  }
326
  }
327
-
328
- if($this->colIsVisible('type_id')) {
329
- $this->addColumn('type',
330
  array(
331
- 'header'=> Mage::helper('catalog')->__('Type'),
332
- 'width' => '60px',
333
- 'index' => 'type_id',
334
- 'type' => 'options',
335
- 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
336
- ));
337
  }
338
-
339
 
340
- if($this->colIsVisible('attribute_set_id')) {
341
- $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
342
- ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
 
343
  ->load()
344
  ->toOptionHash();
345
-
346
- $this->addColumn('set_name',
347
  array(
348
- 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
349
- 'width' => '100px',
350
- 'index' => 'attribute_set_id',
351
- 'type' => 'options',
352
- 'options' => $sets,
353
- ));
354
  }
355
 
356
- if($this->colIsVisible('sku')) {
357
- $this->addColumn('sku',
358
  array(
359
- 'header'=> Mage::helper('catalog')->__('SKU'),
360
- 'width' => '80px',
361
- 'index' => 'sku',
362
- ));
363
  }
364
-
365
-
366
- if($this->colIsVisible('price')) {
367
- $this->addColumn('price',
368
  array(
369
- 'header'=> Mage::helper('catalog')->__('Price'),
370
- 'type' => 'price',
371
- 'currency_code' => $store->getBaseCurrency()->getCode(),
372
- 'index' => 'price',
373
- ));
 
374
  }
375
-
376
-
377
- if($this->colIsVisible('qty')) {
378
- $this->addColumn('qty',
379
  array(
380
- 'header'=> Mage::helper('catalog')->__('Qty'),
381
- 'width' => '100px',
382
- 'type' => 'number',
383
- 'index' => 'qty',
384
- ));
385
  }
386
-
387
-
388
- if($this->colIsVisible('visibility')) {
389
- $this->addColumn('visibility',
390
  array(
391
- 'header'=> Mage::helper('catalog')->__('Visibility'),
392
- 'width' => '70px',
393
- 'index' => 'visibility',
394
- 'type' => 'options',
395
- 'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(),
396
- ));
397
  }
398
-
399
-
400
- if($this->colIsVisible('status')) {
401
- $this->addColumn('status',
402
  array(
403
- 'header'=> Mage::helper('catalog')->__('Status'),
404
- 'width' => '70px',
405
- 'index' => 'status',
406
- 'type' => 'options',
407
- 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
408
- ));
409
  }
410
-
411
-
412
- if($this->colIsVisible('websites')) {
413
- if (!Mage::app()->isSingleStoreMode()) {
414
- $this->addColumn('websites',
415
  array(
416
- 'header'=> Mage::helper('catalog')->__('Websites'),
417
- 'width' => '100px',
418
- 'sortable' => false,
419
- 'index' => 'websites',
420
- 'type' => 'options',
421
- 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
422
- ));
 
423
  }
424
  }
425
-
426
- if($this->colIsVisible('categories')) {
427
- $this->addColumn('categories',
428
- array(
429
- 'header'=> Mage::helper('catalog')->__('Categories'),
430
- 'width' => '100px',
431
- 'sortable' => true,
432
- 'index' => 'categories',
433
- 'sort_index' => 'category',
434
- 'filter_index' => 'category',
435
- ));
436
  }
437
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
  // EG: Show all (other) needed columns.
439
- $ignoreCols = array('id'=>true, 'websites'=>true,'status'=>true,'visibility'=>true,'qty'=>true,
440
- 'price'=>true,'sku'=>true,'attribute_set_id'=>true, 'type_id'=>true,'name'=>true,
441
- 'image'=>true, 'thumbnail' => true, 'small_image'=>true, 'categories'=>true);
442
- $currency = $store->getBaseCurrency()->getCode();
443
- $truncate = Mage::getStoreConfig('enhancedgrid/general/truncatelongtextafter');
444
- $defaults = array(
445
- 'cost' => array('type'=>'price', 'width'=>'30px', 'header'=> Mage::helper('catalog')->__('Cost'), 'currency_code' => $currency),
446
- 'weight' => array('type'=>'number', 'width'=>'30px', 'header'=> Mage::helper('catalog')->__('Weight')),
447
- 'url_key' => array('type'=>'text', 'width'=>'100px', 'header'=> Mage::helper('catalog')->__('Url Key')),
448
- 'tier_price' => array('type'=>'price', 'width'=>'100px', 'header'=> Mage::helper('catalog')->__('Tier Price'), 'currency_code' => $currency),
449
- 'tax_class_id' => array('type'=>'text', 'width'=>'100px', 'header'=> Mage::helper('catalog')->__('Tax Class ID')),
450
- 'special_to_date' => array('type'=>'date', 'width'=>'100px', 'header'=> Mage::helper('catalog')->__('Spshl TO Date')),
451
- //@nelkaake Tuesday April 27, 2010 :
452
- 'created_at' => array('type'=>'datetime', 'width'=>'100px', 'header'=> Mage::helper('catalog')->__('Date Created')),
453
- 'special_price' => array('type'=>'price', 'width'=>'30px', 'header'=> Mage::helper('catalog')->__('Special Price'), 'currency_code' => $currency),
454
- 'special_from_date' => array('type'=>'date', 'width'=>'100px', 'header'=> Mage::helper('catalog')->__('Spshl FROM Date')),
455
- 'color' => array('type'=>'text', 'width'=>'70px', 'header'=> Mage::helper('catalog')->__('Color')),
456
- 'size' => array('type'=>'text', 'width'=>'70px', 'header'=> Mage::helper('catalog')->__('Size')),
457
- 'brand' => array('type'=>'text', 'width'=>'70px', 'header'=> Mage::helper('catalog')->__('Brand')),
458
- 'custom_design' => array('type'=>'text', 'width'=>'70px', 'header'=> Mage::helper('catalog')->__('Custom Design')),
459
- 'custom_design_from' => array('type'=>'date', 'width'=>'70px', 'header'=> Mage::helper('catalog')->__('Custom Design FRM')),
460
- 'custom_design_to' => array('type'=>'date', 'width'=>'70px', 'header'=> Mage::helper('catalog')->__('Custom Design TO')),
461
- 'default_category_id' => array('type'=>'text', 'width'=>'70px', 'header'=> Mage::helper('catalog')->__('Default Categry ID')),
462
- 'dimension' => array('type'=>'text', 'width'=>'75px', 'header'=> Mage::helper('catalog')->__('Dimensions')),
463
- 'manufacturer' => array('type'=>'text', 'width'=>'75px', 'header'=> Mage::helper('catalog')->__('Manufacturer')),
464
- 'meta_keyword' => array('type'=>'text', 'width'=>'200px', 'header'=> Mage::helper('catalog')->__('Meta Keywds')),
465
- 'meta_description' => array('type'=>'text', 'width'=>'200px', 'header'=> Mage::helper('catalog')->__('Meta Descr')),
466
- 'meta_title' => array('type'=>'text', 'width'=>'100px', 'header'=> Mage::helper('catalog')->__('Meta Title')),
467
- 'short_description' => array('type'=>'text', 'width'=>'150px', 'header'=> Mage::helper('catalog')->__('Short Description'), 'string_limit'=>$truncate),
468
- 'description' => array('type'=>'text', 'width'=>'200px', 'header'=> Mage::helper('catalog')->__('Description'), 'string_limit'=>$truncate)
469
  );
470
- //id,name,type,attribute_set,sku,price,qty,visibility,status,websites,image
471
- foreach($this->columnSettings as $col => $true) {
472
- if(isset($ignoreCols[$col])) continue;
473
- if(isset($defaults[$col])) {
 
474
  $innerSettings = $defaults[$col];
475
  } else {
476
  $innerSettings = array(
477
- 'header'=> Mage::helper('catalog')->__($col),
478
- 'width' => '100px',
479
- 'type' => 'text',
480
  );
481
  }
482
  $innerSettings['index'] = $col;
483
  //echo print_r($this->columnOptions, true);
484
- if(isset($this->columnOptions[$col])) {
485
  //die($col);
486
  $innerSettings['type'] = 'options';
487
  $innerSettings['options'] = $this->columnOptions[$col];
488
  }
489
- $this->addColumn($col, $innerSettings);
490
  }
491
-
492
- $this->addColumn('action',
493
- array(
494
- 'header' => Mage::helper('catalog')->__('Action'),
495
- 'width' => '50px',
496
- 'type' => 'action',
497
- 'getter' => 'getId',
498
- 'actions' => array(
499
- array(
500
- 'caption' => Mage::helper('catalog')->__('Edit'),
501
- 'id' => "editlink",
502
- 'url' => array(
503
- 'base'=>'adminhtml/*/edit',
504
- 'params'=>array('store'=>$this->getRequest()->getParam('store'))
505
- ),
506
- 'field' => 'id'
507
- )
508
- ),
509
- 'filter' => false,
510
- 'sortable' => false,
511
- 'index' => 'stores',
512
- ));
513
-
514
- $this->addRssList('rss/catalog/notifystock', Mage::helper('catalog')->__('Notify Low Stock RSS'));
515
-
516
- return parent::_prepareColumns();
517
  }
518
 
519
- protected function _prepareMassaction()
520
- {
521
- $this->setMassactionIdField('entity_id');
522
- $this->getMassactionBlock()->setFormFieldName('product');
523
-
524
- $this->getMassactionBlock()->addItem('delete', array(
525
- 'label'=> Mage::helper('catalog')->__('Delete'),
526
- 'url' => $this->getUrl('*/*/massDelete'),
527
- 'confirm' => Mage::helper('catalog')->__('Are you sure?')
528
- ));
529
-
530
- $statuses = Mage::getSingleton('catalog/product_status')->getOptionArray();
531
-
532
- array_unshift($statuses, array('label'=>'', 'value'=>''));
533
- $this->getMassactionBlock()->addItem('status', array(
534
- 'label'=> Mage::helper('catalog')->__('Change status'),
535
- 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
536
- 'additional' => array(
 
 
 
 
 
 
537
  'visibility' => array(
538
- 'name' => 'status',
539
- 'type' => 'select',
540
- 'class' => 'required-entry',
541
- 'label' => Mage::helper('catalog')->__('Status'),
542
- 'values' => $statuses
543
- )
544
- )
545
- ));
546
-
547
- $this->getMassactionBlock()->addItem('attributes', array(
548
- 'label' => Mage::helper('catalog')->__('Update attributes'),
549
- 'url' => $this->getUrl('adminhtml/catalog_product_action_attribute/edit', array('_current'=>true))
550
- ));
551
-
 
 
552
 
553
  // Divider
554
- $this->getMassactionBlock()->addItem('imagesDivider', $this->getMADivider("Images"));
555
 
556
  // Show images...
557
- $imgWidth = Mage::getStoreConfig('enhancedgrid/images/width') ;
558
- $imgHeight = Mage::getStoreConfig('enhancedgrid/images/height');
559
- $this->getMassactionBlock()->addItem('showImages', array(
560
- 'label' => $this->__('Show Selected Images'),
561
- 'url' => $this->getUrl('enhancedgrid/*/index', array('_current'=>true)),
562
- 'callback' => 'showSelectedImages(productGrid_massactionJsObject, '
563
- .'{checkedValues}, \'<img src=\\\'{imgurl}\\\' width='.$imgWidth
564
- .' height='.$imgHeight.' border=0 />\')'
565
-
566
- ));
 
 
567
  // Hide Images
568
- $this->getMassactionBlock()->addItem('hideImages', array(
569
- 'label' => $this->__('Hide Selected Images'),
570
- 'url' => $this->getUrl('enhancedgrid/*/index', array('_current'=>true)),
571
- 'callback' => 'hideSelectedImages(productGrid_massactionJsObject, {checkedValues})'
572
-
573
- ));
 
 
 
574
 
575
  // Divider 3
576
- $this->getMassactionBlock()->addItem('otherDivider', $this->getMADivider("Other"));
577
 
578
  // Opens all products
 
579
 
580
  // Refresh...
581
- $this->getMassactionBlock()->addItem('refreshProducts', array(
582
- 'label' => $this->__('Refresh Products'),
583
- 'url' => $this->getUrl('enhancedgrid/*/massRefreshProducts', array('_current'=>true))
584
- ));
585
-
586
- // $this->getMassactionBlock()->addItem('saveEditables', array(
587
- // 'label' => $this->__('SAVE EDITABLES'),
588
- // 'url' => $this->getUrl('*/*/saveEditables', array('_current'=>true)),
589
- // 'fields' => array('short_description2', '')
590
- // ));
591
 
 
 
 
 
 
592
 
 
593
  return $this;
594
  }
595
-
596
-
597
- public function getRowUrl($row)
598
- {
599
- //@nelkaake -m 16/11/10: Changed to use _getStore function
600
- return $this->getUrl('adminhtml/catalog_product/edit', array(
601
- 'store'=>$this->_getStore(),
602
- 'id'=>$row->getId())
603
- );
604
  }
605
-
606
- public function getGridUrl()
607
- {
608
- return $this->getUrl('enhancedgrid/*/grid', array('_current'=>true));
 
609
  }
610
-
611
-
612
-
613
- protected function getMADivider($dividerHeading="-------") {
614
  $dividerTemplate = array(
615
- 'label' => '--------'.$this->__($dividerHeading).'--------',
616
- 'url' => $this->getUrl('*/*/index', array('_current'=>true)),
617
- 'callback' => "null"
 
 
618
  );
619
  return $dividerTemplate;
620
  }
@@ -622,45 +638,23 @@ class TBT_Enhancedgrid_Block_Catalog_Product_Grid extends Mage_Adminhtml_Block_W
622
  /**
623
  * @nelkaake -a 15/12/10: TODO move this to a decorator class.
624
  */
625
- protected function _preparePage()
626
- {
627
- if(!$this->getJoinCategories()) {
628
- return parent::_preparePage();
629
- }
630
-
631
- $this->getCollection()->getSelect()->reset(Zend_Db_Select::GROUP);
632
-
 
633
  parent::_preparePage();
634
 
635
- $collection = $this->getCollection();
636
- $collection
637
- ->joinField('category_id',
638
- 'catalog/category_product',
639
- 'category_id',
640
- 'product_id=entity_id',
641
- null,
642
- 'left');
643
- $category_name_attribute_id = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_category', 'name')->getId();
644
-
645
- //@nelkaake -m 13/11/10: Added support for tables with prefixes
646
- $ccev_t = Mage::getConfig()->getTablePrefix(). 'catalog_category_entity_varchar';
647
- $collection
648
- ->joinField('categories',
649
- $ccev_t,
650
- 'GROUP_CONCAT(_table_categories.value)',
651
- 'entity_id=category_id',
652
- "_table_categories.attribute_id={$category_name_attribute_id}",
653
- 'left');
654
- $collection
655
- ->joinField('category',
656
- $ccev_t,
657
- 'value',
658
- 'entity_id=category_id',
659
- "_table_category.attribute_id={$category_name_attribute_id}",
660
- 'left');
661
- $collection->groupByAttribute('entity_id');
662
-
663
- }
664
-
665
 
 
 
666
  }
20
  *
21
  * @category WDCA
22
  * @package TBT_Enhancedgrid
23
+ * @copyright Copyright (c) 2008-2011 WDCA (http://www.wdca.ca)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
31
  * @package TBT_Enhancedgrid
32
  * @author WDCA <contact@wdca.ca>
33
  */
34
+ class TBT_Enhancedgrid_Block_Catalog_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid {
35
+
36
  protected $isenhanced = true;
37
+
38
  private $columnSettings = array();
39
+ protected $_columnSettings = null;
40
+
41
  private $columnOptions = array();
42
+
43
  private $isenabled = true;
44
 
45
+ public function __construct() {
46
+
47
+ $this->setTemplate( 'tbt/enhancedgrid/catalog/product/grid.phtml' );
48
  parent::__construct();
49
+ $this->isenabled = Mage::getStoreConfig( 'enhancedgrid/general/isenabled' );
50
+
51
+ $this->setId( 'productGrid' );
52
 
 
 
53
  $this->prepareDefaults();
54
 
55
+ $this->setSaveParametersInSession( true );
56
+ $this->setUseAjax( true );
57
+ $this->setVarNameFilter( 'product_filter' );
58
 
59
  $this->prepareColumnSettings();
 
 
 
60
 
 
 
 
 
 
 
61
  }
62
+
63
+ protected function prepareDefaults() {
64
+ $this->setDefaultLimit( Mage::getStoreConfig( 'enhancedgrid/defaults/limit' ) );
65
+ $this->setDefaultPage( Mage::getStoreConfig( 'enhancedgrid/defaults/page' ) );
66
+ $this->setDefaultSort( Mage::getStoreConfig( 'enhancedgrid/defaults/sort' ) );
67
+ $this->setDefaultDir( Mage::getStoreConfig( 'enhancedgrid/defaults/dir' ) );
68
 
69
+ }
70
+
71
  protected function prepareColumnSettings() {
72
+ $this->_columnSettings = Mage::getModel( 'enhancedgrid/product_grid_settings_columns' )->setStore( $this->_getStore() );
73
+ $this->columnSettings = $this->_getColumnSettings()->getColumnSettingsArray();
 
74
 
75
+ return $this;
 
 
76
  }
77
 
78
+ /**
79
+ * @return TBT_Enhancedgrid_Model_Product_Grid_Settings_Columns
80
+ */
81
+ protected function _getColumnSettings() {
82
+ return $this->_columnSettings;
83
+ }
84
+
85
  public function colIsVisible($code) {
86
+ return isset( $this->columnSettings[$code] );
87
  }
88
+
89
  protected function _isSpecialCol($col) {
90
+ return ($col == 'qty' || $col == 'websites' || $col == 'id' || $col == 'categories');
91
  }
92
+
93
+ protected function _prepareLayout() {
94
+ $this->setChild( 'export_button',
95
+ $this->getLayout()
96
+ ->createBlock( 'adminhtml/widget_button' )
97
+ ->setData(
98
+ array(
99
+ 'label' => Mage::helper( 'adminhtml' )->__( 'Export' ),
100
+ 'onclick' => $this->getJsObjectName() . '.doExport()',
101
+ 'class' => 'task'
102
+ ) ) );
103
+ $this->setChild( 'reset_filter_button',
104
+ $this->getLayout()
105
+ ->createBlock( 'adminhtml/widget_button' )
106
+ ->setData(
107
+ array(
108
+ 'label' => Mage::helper( 'adminhtml' )->__( 'Reset Filter' ),
109
+ 'onclick' => $this->getJsObjectName() . '.resetFilter()'
110
+ ) ) );
111
+ $this->setChild( 'search_button',
112
+ $this->getLayout()
113
+ ->createBlock( 'adminhtml/widget_button' )
114
+ ->setData(
115
+ array(
116
+ 'label' => Mage::helper( 'adminhtml' )->__( 'Search' ),
117
+ 'onclick' => $this->getJsObjectName() . '.doFilter()',
118
+ 'class' => 'task'
119
+ ) ) );
120
  return parent::_prepareLayout();
121
  }
122
+
123
  public function getQueryStr() {
124
+ return urldecode( $this->getParam( 'q' ) );
125
  }
126
+
127
  /**
128
  * get collection object
129
  * //@nelkaake -a 13/11/10: this is just here for the codeassist function
130
  *
131
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
132
  */
133
+ public function getCollection() {
 
134
  return parent::getCollection();
135
  }
136
+
137
+ protected function _prepareCollection() {
138
+
139
  $collection = $this->getCollection();
140
  //@nelkaake -m 13/11/10: Just made it a little nicer
141
  $queryString = $this->getQueryStr();
142
+ if ( $queryString ) {
143
+ $collection = Mage::helper( 'enhancedgrid' )->getSearchCollection( $queryString, $this->getRequest() );
 
144
  }
145
+
146
+ if ( ! $collection ) {
147
+ //@nelkaake -a 15/12/10: To fix categories column issue this is a tempoary way we are going to load the modified collection class.
148
  $collection = new TBT_Enhancedgrid_Model_Resource_Eav_Mysql4_Product_Collection();
149
  }
150
  $store = $this->_getStore();
151
+ $collection->joinField( 'qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left' );
152
+ $collection->addAttributeToSelect( 'sku' );
 
 
 
 
 
 
153
 
154
  //$collection->addAttributeToSelect('attribute_set_id');
155
  //$collection->addAttributeToSelect('type_id');
156
+
157
+
158
+ if ( $store->getId() ) {
159
  //$collection->setStoreId($store->getId());
160
+ $collection->addStoreFilter( $store->getId() );
161
+ $collection->joinAttribute( 'custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId() );
162
+ $collection->joinAttribute( 'status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId() );
163
+ $collection->joinAttribute( 'visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId() );
164
+ $collection->joinAttribute( 'price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId() );
165
+ } else {
166
+ $collection->addAttributeToSelect( 'price' );
167
+ $collection->addAttributeToSelect( 'status' );
168
+ $collection->addAttributeToSelect( 'visibility' );
 
169
  }
170
  // EG: Select all needed columns.
171
  //id,name,type,attribute_set,sku,price,qty,visibility,status,websites,image
172
+ foreach ($this->columnSettings as $col => $true) {
173
+ if ( $this->_isSpecialCol( $col ) ) continue;
174
+ $collection->addAttributeToSelect( $col );
175
  }
176
 
177
+ if ( $this->colIsVisible( 'categories' ) ) {
178
+ $this->setJoinCategories( true );
179
  }
180
 
181
+ $this->setCollection( $collection );
182
 
183
+ $this->addExportType( '*/*/exportCsv', Mage::helper( 'customer' )->__( 'CSV' ) );
184
+ $this->addExportType( '*/*/exportXml', Mage::helper( 'customer' )->__( 'XML' ) );
185
 
186
  parent::_prepareCollection();
187
  $collection->addWebsiteNamesToResult();
188
 
189
  return $this;
190
  }
191
+
192
  /**
193
  * if the attribute has options an options entry will be
194
  * added to $columnOptions
195
+ */
196
  protected function loadColumnOptions($attr_code) {
197
+ $attr = Mage::getModel( 'eav/entity_attribute' )->loadByCode( 'catalog_product', $attr_code );
198
+ if ( sizeof( $attr->getData() ) > 0 ) {
199
+ if ( $attr->getFrontendInput() == 'select' ) {
200
+ //@nelkaake -a 13/11/10:
201
+ if ( $attr->getSourceModel() != null ) {
202
+ $sourcemodel = Mage::getModel( $attr->getSourceModel() );
203
+ //@nelkaake -a 16/11/10:
204
+ $sourcemodel->setAttribute( $attr );
205
+ if ( method_exists( $sourcemodel, 'getAllOptions' ) ) {
206
+ try {
207
+ //die($attr->getSourceModel());
208
+ $values = $sourcemodel->getAllOptions();
209
+
210
+ $options = array();
211
+
212
+ foreach ($values as $value) {
213
+
214
+ $options[$value['value']] = $value['label'];
215
+ }
216
+ //die($attr_code);
217
+ $this->columnOptions[$attr_code] = $options;
218
+ return;
219
+ } catch ( Exception $e ) {
220
+ Mage::log(
221
+ "Tried to get options for {$attr_code} using getAllOptions on {$attr->getSourceModel()}, but an exception occured: " .
222
+ (string) $e );
223
+ }
224
+ }
225
  }
226
+ //@nelkaake -a 13/11/10:
227
+ $values = Mage::getResourceModel( 'eav/entity_attribute_option_collection' )->setAttributeFilter(
228
+ $attr->getId() )
229
+ ->setStoreFilter( $this->_getStore()
230
+ ->getId(), false )
231
  ->load();
232
  $options = array();
233
+ foreach ($values as $value) {
234
  $options[$value->getOptionId()] = $value->getValue();
235
  }
236
  //die($attr_code);
237
  $this->columnOptions[$attr_code] = $options;
238
+
239
+ //die(print_r($this->columnOptions, true));
240
  }
241
  }
 
 
242
 
243
+ }
244
 
245
+ protected function _getStore() {
246
+ $storeId = (int) $this->getRequest()->getParam( 'store', 0 );
247
+ $store = Mage::app()->getStore( $storeId );
248
+ if ( $store->getId() != $storeId ) $store = Mage::app()->getStore( 0 );
 
 
249
  return $store;
250
  }
251
 
252
+ protected function _addColumnFilterToCollection($column) {
253
+ if ( $this->getCollection() ) {
254
+ if ( $column->getId() == 'websites' ) {
255
+ $this->getCollection()->joinField( 'websites', 'catalog/product_website', 'website_id', 'product_id=entity_id', null,
256
+ 'left' );
 
 
 
 
 
 
257
  }
258
  }
259
+ return parent::_addColumnFilterToCollection( $column );
260
  }
261
 
262
+ protected function _prepareColumns() {
 
263
  // Loads all the column options for each applicable column.
264
+ foreach ($this->columnSettings as $col => $true) {
265
+ $this->loadColumnOptions( $col );
266
  }
267
 
268
  $store = $this->_getStore();
269
+ if ( $this->colIsVisible( 'id' ) ) {
270
+ $this->addColumn( 'id',
271
  array(
272
+ 'header' => Mage::helper( 'catalog' )->__( 'ID' ),
273
+ 'width' => '50px',
274
+ 'type' => 'number',
275
+ 'index' => 'entity_id'
276
+ ) );
277
  }
278
 
279
+ $imgWidth = Mage::getStoreConfig( 'enhancedgrid/images/width' ) + "px";
280
 
281
+ if ( $this->colIsVisible( 'thumbnail' ) ) {
282
+ $this->addColumn( 'thumbnail',
283
  array(
284
+ 'header' => Mage::helper( 'catalog' )->__( 'Thumbnail' ),
285
+ 'type' => 'image',
286
+ 'width' => $imgWidth,
287
+ 'index' => 'thumbnail'
288
+ ) );
289
  }
290
+ if ( $this->colIsVisible( 'small_image' ) ) {
291
+ $this->addColumn( 'small_image',
292
  array(
293
+ 'header' => Mage::helper( 'catalog' )->__( 'Small Img' ),
294
+ 'type' => 'image',
295
+ 'width' => $imgWidth,
296
+ 'index' => 'small_image'
297
+ ) );
298
  }
299
+ if ( $this->colIsVisible( 'image' ) ) {
300
+ $this->addColumn( 'image',
301
  array(
302
+ 'header' => Mage::helper( 'catalog' )->__( 'Image' ),
303
+ 'type' => 'image',
304
+ 'width' => $imgWidth,
305
+ 'index' => 'image'
306
+ ) );
307
  }
308
 
309
+ if ( $this->colIsVisible( 'name' ) ) {
310
+ $this->addColumn( 'name',
311
  array(
312
+ 'header' => Mage::helper( 'catalog' )->__( 'Name' ),
313
+ 'index' => 'name'
314
+ )// 'width' => '150px'
315
+ );
316
  }
317
+ if ( $this->colIsVisible( 'name' ) ) {
318
+ if ( $store->getId() ) {
319
+ $this->addColumn( 'custom_name',
320
  array(
321
+ 'header' => Mage::helper( 'catalog' )->__( 'Name In %s', $store->getName() ),
322
+ 'index' => 'custom_name',
323
  'width' => '150px'
324
+ ) );
325
  }
326
  }
327
+
328
+ if ( $this->colIsVisible( 'type_id' ) ) {
329
+ $this->addColumn( 'type',
330
  array(
331
+ 'header' => Mage::helper( 'catalog' )->__( 'Type' ),
332
+ 'width' => '60px',
333
+ 'index' => 'type_id',
334
+ 'type' => 'options',
335
+ 'options' => Mage::getSingleton( 'catalog/product_type' )->getOptionArray()
336
+ ) );
337
  }
 
338
 
339
+ if ( $this->colIsVisible( 'attribute_set_id' ) ) {
340
+ $sets = Mage::getResourceModel( 'eav/entity_attribute_set_collection' )->setEntityTypeFilter(
341
+ Mage::getModel( 'catalog/product' )->getResource()
342
+ ->getTypeId() )
343
  ->load()
344
  ->toOptionHash();
345
+
346
+ $this->addColumn( 'set_name',
347
  array(
348
+ 'header' => Mage::helper( 'catalog' )->__( 'Attrib. Set Name' ),
349
+ 'width' => '100px',
350
+ 'index' => 'attribute_set_id',
351
+ 'type' => 'options',
352
+ 'options' => $sets
353
+ ) );
354
  }
355
 
356
+ if ( $this->colIsVisible( 'sku' ) ) {
357
+ $this->addColumn( 'sku',
358
  array(
359
+ 'header' => Mage::helper( 'catalog' )->__( 'SKU' ),
360
+ 'width' => '80px',
361
+ 'index' => 'sku'
362
+ ) );
363
  }
364
+
365
+ if ( $this->colIsVisible( 'price' ) ) {
366
+ $this->addColumn( 'price',
 
367
  array(
368
+ 'header' => Mage::helper( 'catalog' )->__( 'Price' ),
369
+ 'type' => 'price',
370
+ 'currency_code' => $store->getBaseCurrency()
371
+ ->getCode(),
372
+ 'index' => 'price'
373
+ ) );
374
  }
375
+
376
+ if ( $this->colIsVisible( 'qty' ) ) {
377
+ $this->addColumn( 'qty',
 
378
  array(
379
+ 'header' => Mage::helper( 'catalog' )->__( 'Qty' ),
380
+ 'width' => '100px',
381
+ 'type' => 'number',
382
+ 'index' => 'qty'
383
+ ) );
384
  }
385
+
386
+ if ( $this->colIsVisible( 'visibility' ) ) {
387
+ $this->addColumn( 'visibility',
 
388
  array(
389
+ 'header' => Mage::helper( 'catalog' )->__( 'Visibility' ),
390
+ 'width' => '70px',
391
+ 'index' => 'visibility',
392
+ 'type' => 'options',
393
+ 'options' => Mage::getModel( 'catalog/product_visibility' )->getOptionArray()
394
+ ) );
395
  }
396
+
397
+ if ( $this->colIsVisible( 'status' ) ) {
398
+ $this->addColumn( 'status',
 
399
  array(
400
+ 'header' => Mage::helper( 'catalog' )->__( 'Status' ),
401
+ 'width' => '70px',
402
+ 'index' => 'status',
403
+ 'type' => 'options',
404
+ 'options' => Mage::getSingleton( 'catalog/product_status' )->getOptionArray()
405
+ ) );
406
  }
407
+
408
+ if ( $this->colIsVisible( 'websites' ) ) {
409
+ if ( ! Mage::app()->isSingleStoreMode() ) {
410
+ $this->addColumn( 'websites',
 
411
  array(
412
+ 'header' => Mage::helper( 'catalog' )->__( 'Websites' ),
413
+ 'width' => '100px',
414
+ 'sortable' => false,
415
+ 'index' => 'websites',
416
+ 'type' => 'options',
417
+ 'options' => Mage::getModel( 'core/website' )->getCollection()
418
+ ->toOptionHash()
419
+ ) );
420
  }
421
  }
422
+
423
+ if ( $this->colIsVisible( 'categories' ) ) {
424
+ $this->addColumn( 'categories',
425
+ array(
426
+ 'header' => Mage::helper( 'catalog' )->__( 'Categories' ),
427
+ 'width' => '100px',
428
+ 'sortable' => true,
429
+ 'index' => 'categories',
430
+ 'sort_index' => 'category',
431
+ 'filter_index' => 'category'
432
+ ) );
433
  }
434
+
435
+ $this->_addVariableColumns();
436
+
437
+ $this->addColumn( 'action',
438
+ array(
439
+ 'header' => Mage::helper( 'catalog' )->__( 'Action' ),
440
+ 'width' => '50px',
441
+ 'type' => 'action',
442
+ 'getter' => 'getId',
443
+ 'actions' => array(
444
+ array(
445
+ 'caption' => Mage::helper( 'catalog' )->__( 'Edit' ),
446
+ 'id' => "editlink",
447
+ 'url' => array(
448
+ 'base' => 'adminhtml/*/edit',
449
+ 'params' => array(
450
+ 'store' => $this->getRequest()
451
+ ->getParam( 'store' )
452
+ )
453
+ ),
454
+ 'field' => 'id'
455
+ )
456
+ ),
457
+ 'filter' => false,
458
+ 'sortable' => false,
459
+ 'index' => 'stores'
460
+ ) );
461
+
462
+ $this->addRssList( 'rss/catalog/notifystock', Mage::helper( 'catalog' )->__( 'Notify Low Stock RSS' ) );
463
+
464
+ return parent::_prepareColumns();
465
+ }
466
+
467
+ /**
468
+ * Adds all the columns that are not part of the fixed configuration settings prepared above.
469
+ *
470
+ */
471
+ protected function _addVariableColumns() {
472
+
473
+ $defaults = $this->_getColumnSettings()->getDefaults();
474
+
475
  // EG: Show all (other) needed columns.
476
+ $ignoreCols = array(
477
+ 'id' => true,
478
+ 'websites' => true,
479
+ 'status' => true,
480
+ 'visibility' => true,
481
+ 'qty' => true,
482
+ 'price' => true,
483
+ 'sku' => true,
484
+ 'attribute_set_id' => true,
485
+ 'type_id' => true,
486
+ 'name' => true,
487
+ 'image' => true,
488
+ 'thumbnail' => true,
489
+ 'small_image' => true,
490
+ 'categories' => true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  );
492
+
493
+
494
+ foreach ($this->columnSettings as $col => $true) {
495
+ if ( isset( $ignoreCols[$col] ) ) continue;
496
+ if ( isset( $defaults[$col] ) ) {
497
  $innerSettings = $defaults[$col];
498
  } else {
499
  $innerSettings = array(
500
+ 'header' => Mage::helper( 'catalog' )->__( $col ),
501
+ 'width' => '100px',
502
+ 'type' => 'text'
503
  );
504
  }
505
  $innerSettings['index'] = $col;
506
  //echo print_r($this->columnOptions, true);
507
+ if ( isset( $this->columnOptions[$col] ) ) {
508
  //die($col);
509
  $innerSettings['type'] = 'options';
510
  $innerSettings['options'] = $this->columnOptions[$col];
511
  }
512
+ $this->addColumn( $col, $innerSettings );
513
  }
514
+
515
+ return $this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
  }
517
 
518
+ protected function _prepareMassaction() {
519
+ $this->setMassactionIdField( 'entity_id' );
520
+ $this->getMassactionBlock()->setFormFieldName( 'product' );
521
+
522
+ $this->getMassactionBlock()->addItem( 'delete',
523
+ array(
524
+ 'label' => Mage::helper( 'catalog' )->__( 'Delete' ),
525
+ 'url' => $this->getUrl( '*/*/massDelete' ),
526
+ 'confirm' => Mage::helper( 'catalog' )->__( 'Are you sure?' )
527
+ ) );
528
+
529
+ $statuses = Mage::getSingleton( 'catalog/product_status' )->getOptionArray();
530
+
531
+ array_unshift( $statuses, array(
532
+ 'label' => '',
533
+ 'value' => ''
534
+ ) );
535
+ $this->getMassactionBlock()->addItem( 'status',
536
+ array(
537
+ 'label' => Mage::helper( 'catalog' )->__( 'Change status' ),
538
+ 'url' => $this->getUrl( '*/*/massStatus', array(
539
+ '_current' => true
540
+ ) ),
541
+ 'additional' => array(
542
  'visibility' => array(
543
+ 'name' => 'status',
544
+ 'type' => 'select',
545
+ 'class' => 'required-entry',
546
+ 'label' => Mage::helper( 'catalog' )->__( 'Status' ),
547
+ 'values' => $statuses
548
+ )
549
+ )
550
+ ) );
551
+
552
+ $this->getMassactionBlock()->addItem( 'attributes',
553
+ array(
554
+ 'label' => Mage::helper( 'catalog' )->__( 'Update attributes' ),
555
+ 'url' => $this->getUrl( 'adminhtml/catalog_product_action_attribute/edit', array(
556
+ '_current' => true
557
+ ) )
558
+ ) );
559
 
560
  // Divider
561
+ $this->getMassactionBlock()->addItem( 'imagesDivider', $this->getMADivider( "Images" ) );
562
 
563
  // Show images...
564
+ $imgWidth = Mage::getStoreConfig( 'enhancedgrid/images/width' );
565
+ $imgHeight = Mage::getStoreConfig( 'enhancedgrid/images/height' );
566
+ $this->getMassactionBlock()->addItem( 'showImages',
567
+ array(
568
+ 'label' => $this->__( 'Show Selected Images' ),
569
+ 'url' => $this->getUrl( 'enhancedgrid/*/index', array(
570
+ '_current' => true
571
+ ) ),
572
+ 'callback' => 'showSelectedImages(productGrid_massactionJsObject, ' . '{checkedValues}, \'<img src=\\\'{imgurl}\\\' width=' .
573
+ $imgWidth . ' height=' . $imgHeight . ' border=0 />\')'
574
+ )
575
+ );
576
  // Hide Images
577
+ $this->getMassactionBlock()->addItem( 'hideImages',
578
+ array(
579
+ 'label' => $this->__( 'Hide Selected Images' ),
580
+ 'url' => $this->getUrl( 'enhancedgrid/*/index', array(
581
+ '_current' => true
582
+ ) ),
583
+ 'callback' => 'hideSelectedImages(productGrid_massactionJsObject, {checkedValues})'
584
+ )
585
+ );
586
 
587
  // Divider 3
588
+ $this->getMassactionBlock()->addItem( 'otherDivider', $this->getMADivider( "Other" ) );
589
 
590
  // Opens all products
591
+
592
 
593
  // Refresh...
594
+ $this->getMassactionBlock()->addItem( 'refreshProducts',
595
+ array(
596
+ 'label' => $this->__( 'Refresh Products' ),
597
+ 'url' => $this->getUrl( 'enhancedgrid/*/massRefreshProducts', array(
598
+ '_current' => true
599
+ ) )
600
+ ) );
 
 
 
601
 
602
+ // $this->getMassactionBlock()->addItem('saveEditables', array(
603
+ // 'label' => $this->__('SAVE EDITABLES'),
604
+ // 'url' => $this->getUrl('*/*/saveEditables', array('_current'=>true)),
605
+ // 'fields' => array('short_description2', '')
606
+ // ));
607
 
608
+
609
  return $this;
610
  }
611
+
612
+ public function getRowUrl($row) {
613
+ //@nelkaake -m 16/11/10: Changed to use _getStore function
614
+ return $this->getUrl( 'adminhtml/catalog_product/edit',
615
+ array(
616
+ 'store' => $this->_getStore(),
617
+ 'id' => $row->getId()
618
+ ) );
 
619
  }
620
+
621
+ public function getGridUrl() {
622
+ return $this->getUrl( 'enhancedgrid/*/grid', array(
623
+ '_current' => true
624
+ ) );
625
  }
626
+
627
+ protected function getMADivider($dividerHeading = "-------") {
 
 
628
  $dividerTemplate = array(
629
+ 'label' => '--------' . $this->__( $dividerHeading ) . '--------',
630
+ 'url' => $this->getUrl( '*/*/index', array(
631
+ '_current' => true
632
+ ) ),
633
+ 'callback' => "null"
634
  );
635
  return $dividerTemplate;
636
  }
638
  /**
639
  * @nelkaake -a 15/12/10: TODO move this to a decorator class.
640
  */
641
+ protected function _preparePage() {
642
+ if ( ! $this->getJoinCategories() ) {
643
+ return parent::_preparePage();
644
+ }
645
+
646
+ $this->getCollection()
647
+ ->getSelect()
648
+ ->reset( Zend_Db_Select::GROUP );
649
+
650
  parent::_preparePage();
651
 
652
+ $category_decorator = Mage::getModel( 'enhancedgrid/product_collection_category_decorator' );
653
+ $category_decorator->setCollection( $this->getCollection() )
654
+ ->addCategories();
655
+
656
+ return $this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
657
 
658
+ }
659
+
660
  }
app/code/community/TBT/Enhancedgrid/Block/Catalog/Product/Grid/Columns.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php
app/code/community/TBT/Enhancedgrid/Helper/Version.php ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WDCA
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category WDCA
22
+ * @package TBT_Enhancedgrid
23
+ * @copyright Copyright (c) 2008-2011 WDCA (http://www.wdca.ca)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ /**
27
+ * Version Helper Data
28
+ *
29
+ * @category TBT
30
+ * @package TBT_Enhancedgrid
31
+ * @author WDCA Team <contact@wdca.ca>
32
+ */
33
+ class TBT_Enhancedgrid_Helper_Version extends Mage_Core_Helper_Abstract {
34
+
35
+ /**
36
+ * Returns true if the base version of this Magento installation
37
+ * is equal to the version specified or newer.
38
+ * @param string $version
39
+ * @param unknown_type $task
40
+ */
41
+ public function isBaseMageVersionAtLeast($version, $task = null) {
42
+ // convert Magento Enterprise, Professional, Community to a base version
43
+ $mage_base_version = $this->convertVersionToCommunityVersion ( Mage::getVersion (), $task );
44
+
45
+ if (version_compare ( $mage_base_version, $version, '>=' )) {
46
+ return true;
47
+ }
48
+ return false;
49
+ }
50
+
51
+ /**
52
+ * True if the base version is at least the verison specified without converting version numbers to other versions of Magento.
53
+ *
54
+ * @param string $version
55
+ * @param unknown_type $task
56
+ * @return boolean
57
+ */
58
+ public function isRawVerAtLeast($version) {
59
+ // convert Magento Enterprise, Professional, Community to a base version
60
+ $mage_base_version = Mage::getVersion ();
61
+
62
+ if (version_compare ( $mage_base_version, $version, '>=' )) {
63
+ return true;
64
+ }
65
+ return false;
66
+ }
67
+
68
+ /**
69
+ * True if the base version is at least the verison specified without checking
70
+ * @param string $version
71
+ */
72
+ public function isEnterpriseAtLeast($version) {
73
+ if(!$this->isMageEnterprise()) return false;
74
+
75
+ return $this->isRawVerAtLeast($version);
76
+ }
77
+
78
+ /**
79
+ *
80
+ * @param string $version
81
+ * @param unknown_type $task
82
+ * @return boolean
83
+ */
84
+ public function isBaseMageVersion($version, $task = null) {
85
+ // convert Magento Enterprise, Professional, Community to a base version
86
+ $mage_base_version = $this->convertVersionToCommunityVersion ( Mage::getVersion (), $task );
87
+
88
+ if (version_compare ( $mage_base_version, $version, '=' )) {
89
+ return true;
90
+ }
91
+ return false;
92
+ }
93
+
94
+ /** * @alias isBaseMageVersion */
95
+ public function isMageVersion($version, $task = null) {
96
+ return $this->isBaseMageVersion ( $version, $task );
97
+ }
98
+
99
+ /** * @alias isBaseMageVersion */
100
+ public function isMage($version, $task = null) {
101
+ return $this->isBaseMageVersion ( $version, $task );
102
+ }
103
+
104
+ /** * @alias isBaseMageVersionAtLeast */
105
+ public function isMageVersionAtLeast($version, $task = null) {
106
+ return $this->isBaseMageVersionAtLeast ( $version, $task );
107
+ }
108
+
109
+ /**
110
+ * True if the Magento version currently running is between the versions specified inclusive
111
+ * @nelkaake -a 16/11/10:
112
+ * @param string $version
113
+ * @param unknown_type $task
114
+ * @return boolean
115
+ */
116
+ public function isMageVersionBetween($version1, $version2, $task = null) {
117
+
118
+ $is_between = $this->isBaseMageVersionAtLeast ( $version1, $task ) && ! $this->isBaseMageVersionAtLeast ( $version2, $task );
119
+ $is_later_version = $this->isMageVersion ( $version2 );
120
+ return $is_between || $is_later_version;
121
+ }
122
+
123
+ /**
124
+ * True if the version of Magento currently being rune is Enterprise Edition
125
+ */
126
+ public function isMageEnterprise() {
127
+ return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
128
+ }
129
+
130
+ /**
131
+ * attempt to convert an Enterprise, Professional, Community magento version number to its compatable Community version
132
+ *
133
+ * @param string $task fix problems where direct version numbers cant be changed to a community release without knowing the intent of the task
134
+ */
135
+ public function convertVersionToCommunityVersion($version, $task = null) {
136
+
137
+ /* Enterprise -
138
+ * 1.9 | 1.8 | 1.5
139
+ */
140
+ if ($this->isMageEnterprise()) {
141
+ if (version_compare ( $version, '1.11.0', '>=' ))
142
+ return '1.6.0';
143
+ if (version_compare ( $version, '1.9.1', '>=' ))
144
+ return '1.5.0';
145
+ if (version_compare ( $version, '1.9.0', '>=' ))
146
+ return '1.4.2';
147
+ if (version_compare ( $version, '1.8.0', '>=' ))
148
+ return '1.3.1';
149
+ return '1.3.1';
150
+ }
151
+
152
+ /* Professional -
153
+ * If Entprise_Enterprise module is installed but it didn't pass Enterprise_Enterprise tests
154
+ * then the installation must be Magento Pro edition.
155
+ * 1.7 | 1.8
156
+ */
157
+ if (Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' )) {
158
+ if (version_compare ( $version, '1.8.0', '>=' ))
159
+ return '1.4.1';
160
+ if (version_compare ( $version, '1.7.0', '>=' ))
161
+ return '1.3.1';
162
+ return '1.3.1';
163
+ }
164
+
165
+ /* Community -
166
+ * 1.5rc2 - December 29, 2010
167
+ * 1.4.2 - December 8, 2010
168
+ * 1.4.1 - June 10, 2010
169
+ * 1.3.3.0 - (April 23, 2010) *** does this release work like to 1.4.0.1?
170
+ * 1.4.0.1 - (February 19, 2010)
171
+ * 1.4.0.0 - (February 12, 2010)
172
+ * 1.3.0 - March 30, 2009
173
+ * 1.2.1.1 - February 23, 2009
174
+ * 1.1 - July 24, 2008
175
+ * 0.6.1316 - October 18, 2007
176
+ */
177
+ return $version;
178
+ }
179
+
180
+ /**
181
+ * start E_DEPRECATED =================================================================================
182
+ */
183
+ /**
184
+ * @deprecated use isBaseMageVersion isntead
185
+ * @return boolean
186
+ */
187
+ public function isMageVersion12() {
188
+ return $this->isMageVersion ( '1.2' );
189
+ }
190
+
191
+ /**
192
+ * @deprecated use isBaseMageVersion isntead
193
+ * @return boolean
194
+ */
195
+ public function isMageVersion131() {
196
+ return $this->isMageVersion ( '1.3.1' );
197
+ }
198
+
199
+ /**
200
+ * @deprecated use isBaseMageVersion instead
201
+ * @return boolean
202
+ */
203
+ public function isMageVersion14() {
204
+ return $this->isMageVersion ( '1.4' );
205
+ }
206
+
207
+ /**
208
+ * @deprecated use isMageVersionAtLeast isntead
209
+ * @return boolean
210
+ */
211
+ public function isMageVersionAtLeast14() {
212
+ //@nelkaake Changed on Sunday August 15, 2010:
213
+ return $this->isBaseMageVersionAtLeast ( '1.4.0.0' );
214
+ }
215
+
216
+ /**
217
+ * end E_DEPRECATED =================================================================================
218
+ */
219
+ }
app/code/community/TBT/Enhancedgrid/Model/Collection/Decorator/Abstract.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WDCA
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category WDCA
22
+ * @package TBT_Enhancedgrid
23
+ * @copyright Copyright (c) 2008-2011 WDCA (http://www.wdca.ca)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ abstract class TBT_Enhancedgrid_Model_Collection_Decorator_Abstract extends Varien_Object{
27
+ protected $_collection = null;
28
+ public function setCollection(TBT_Enhancedgrid_Model_Resource_Eav_Mysql4_Product_Collection $collection) {
29
+ $this->_collection = $collection;
30
+
31
+ return $this;
32
+ }
33
+
34
+ public function getCollection() {
35
+ return $this->_collection;
36
+ }
37
+ }
app/code/community/TBT/Enhancedgrid/Model/Product/Collection/Category/Decorator.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WDCA
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category WDCA
22
+ * @package TBT_Enhancedgrid
23
+ * @copyright Copyright (c) 2008-2011 WDCA (http://www.wdca.ca)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class TBT_Enhancedgrid_Model_Product_Collection_Category_Decorator extends TBT_Enhancedgrid_Model_Collection_Decorator_Abstract {
27
+
28
+
29
+ public function setCollection(TBT_Enhancedgrid_Model_Resource_Eav_Mysql4_Product_Collection $collection) {
30
+ return parent::setCollection( $collection );
31
+ }
32
+
33
+ /**
34
+ * Adds category data for the products collection using the currently stored collection model.
35
+ */
36
+ public function addCategories() {
37
+
38
+ $collection = $this->getCollection();
39
+
40
+ $alias_prefix = $this->_getAliasPrefix();
41
+
42
+ $collection->joinField( 'category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left' );
43
+
44
+ $category_name_attribute_id = Mage::getModel( 'eav/entity_attribute' )->loadByCode( 'catalog_category', 'name' )->getId();
45
+
46
+ //@nelkaake -m 13/11/10: Added support for tables with prefixes
47
+ $ccev_t = Mage::getConfig()->getTablePrefix() . 'catalog_category_entity_varchar';
48
+
49
+ $collection->joinField( 'categories', $ccev_t, "GROUP_CONCAT({$alias_prefix}categories.value)", 'entity_id=category_id',
50
+ "{$alias_prefix}categories.attribute_id={$category_name_attribute_id}", 'left' );
51
+
52
+ $collection->joinField( 'category', $ccev_t, 'value', 'entity_id=category_id',
53
+ "{$alias_prefix}category.attribute_id={$category_name_attribute_id}", 'left' );
54
+
55
+ $collection->groupByAttribute( 'entity_id' );
56
+
57
+ return $this;
58
+
59
+ }
60
+
61
+
62
+
63
+ protected function _getAliasPrefix() {
64
+ if(Mage::helper('enhancedgrid/version')->isBaseMageVersionAtLeast('1.6')) {
65
+ return 'at_';
66
+ }
67
+
68
+ return '_table_';
69
+ }
70
+
71
+ }
app/code/community/TBT/Enhancedgrid/Model/Product/Grid/Settings/Columns.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WDCA
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category WDCA
22
+ * @package TBT_Enhancedgrid
23
+ * @copyright Copyright (c) 2008-2011 WDCA (http://www.wdca.ca)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class TBT_Enhancedgrid_Model_Product_Grid_Settings_Columns extends Varien_Object {
27
+
28
+ protected $columnSettings = array();
29
+
30
+ public function getStore() {
31
+ if($this->getData('store')) return $this->getData('store');
32
+
33
+ return Mage::app()->getStore();
34
+ }
35
+
36
+ public function getColumnSettingsArray() {
37
+ $this->columnSettings = array();
38
+ $storeSettings = Mage::getStoreConfig( 'enhancedgrid/columns/showcolumns' );
39
+
40
+ $tempArr = explode( ',', $storeSettings );
41
+
42
+ foreach ($tempArr as $showCol) {
43
+ $this->columnSettings[trim( $showCol )] = true;
44
+ }
45
+
46
+ return $this->columnSettings;
47
+ }
48
+
49
+
50
+ public function getDefaults() {
51
+ $truncate = Mage::getStoreConfig( 'enhancedgrid/general/truncatelongtextafter' );
52
+ $currency = $this->getStore()->getBaseCurrency()->getCode();
53
+ $defaults = array(
54
+ 'cost' => array(
55
+ 'type' => 'price',
56
+ 'width' => '30px',
57
+ 'header' => Mage::helper( 'catalog' )->__( 'Cost' ),
58
+ 'currency_code' => $currency
59
+ ),
60
+ 'weight' => array(
61
+ 'type' => 'number',
62
+ 'width' => '30px',
63
+ 'header' => Mage::helper( 'catalog' )->__( 'Weight' )
64
+ ),
65
+ 'bss_weight' => array(
66
+ 'type' => 'number',
67
+ 'width' => '30px',
68
+ 'header' => Mage::helper( 'catalog' )->__( 'BSS Weight' )
69
+ ),
70
+ 'url_key' => array(
71
+ 'type' => 'text',
72
+ 'width' => '100px',
73
+ 'header' => Mage::helper( 'catalog' )->__( 'Url Key' )
74
+ ),
75
+ 'tier_price' => array(
76
+ 'type' => 'price',
77
+ 'width' => '100px',
78
+ 'header' => Mage::helper( 'catalog' )->__( 'Tier Price' ),
79
+ 'currency_code' => $currency
80
+ ),
81
+ 'tax_class_id' => array(
82
+ 'type' => 'text',
83
+ 'width' => '100px',
84
+ 'header' => Mage::helper( 'catalog' )->__( 'Tax Class ID' )
85
+ ),
86
+ 'special_to_date' => array(
87
+ 'type' => 'date',
88
+ 'width' => '100px',
89
+ 'header' => Mage::helper( 'catalog' )->__( 'Spshl TO Date' )
90
+ ),
91
+ //@nelkaake Tuesday April 27, 2010 :
92
+ 'created_at' => array(
93
+ 'type' => 'datetime',
94
+ 'width' => '100px',
95
+ 'header' => Mage::helper( 'catalog' )->__( 'Date Created' )
96
+ ),
97
+ 'special_price' => array(
98
+ 'type' => 'price',
99
+ 'width' => '30px',
100
+ 'header' => Mage::helper( 'catalog' )->__( 'Special Price' ),
101
+ 'currency_code' => $currency
102
+ ),
103
+ 'special_from_date' => array(
104
+ 'type' => 'date',
105
+ 'width' => '100px',
106
+ 'header' => Mage::helper( 'catalog' )->__( 'Spshl FROM Date' )
107
+ ),
108
+ 'color' => array(
109
+ 'type' => 'text',
110
+ 'width' => '70px',
111
+ 'header' => Mage::helper( 'catalog' )->__( 'Color' )
112
+ ),
113
+ 'size' => array(
114
+ 'type' => 'text',
115
+ 'width' => '70px',
116
+ 'header' => Mage::helper( 'catalog' )->__( 'Size' )
117
+ ),
118
+ 'brand' => array(
119
+ 'type' => 'text',
120
+ 'width' => '70px',
121
+ 'header' => Mage::helper( 'catalog' )->__( 'Brand' )
122
+ ),
123
+ 'custom_design' => array(
124
+ 'type' => 'text',
125
+ 'width' => '70px',
126
+ 'header' => Mage::helper( 'catalog' )->__( 'Custom Design' )
127
+ ),
128
+ 'custom_design_from' => array(
129
+ 'type' => 'date',
130
+ 'width' => '70px',
131
+ 'header' => Mage::helper( 'catalog' )->__( 'Custom Design FRM' )
132
+ ),
133
+ 'custom_design_to' => array(
134
+ 'type' => 'date',
135
+ 'width' => '70px',
136
+ 'header' => Mage::helper( 'catalog' )->__( 'Custom Design TO' )
137
+ ),
138
+ 'default_category_id' => array(
139
+ 'type' => 'text',
140
+ 'width' => '70px',
141
+ 'header' => Mage::helper( 'catalog' )->__( 'Default Categry ID' )
142
+ ),
143
+ 'dimension' => array(
144
+ 'type' => 'text',
145
+ 'width' => '75px',
146
+ 'header' => Mage::helper( 'catalog' )->__( 'Dimensions' )
147
+ ),
148
+ 'manufacturer' => array(
149
+ 'type' => 'text',
150
+ 'width' => '75px',
151
+ 'header' => Mage::helper( 'catalog' )->__( 'Manufacturer' )
152
+ ),
153
+ 'meta_keyword' => array(
154
+ 'type' => 'text',
155
+ 'width' => '200px',
156
+ 'header' => Mage::helper( 'catalog' )->__( 'Meta Keywds' )
157
+ ),
158
+ 'meta_description' => array(
159
+ 'type' => 'text',
160
+ 'width' => '200px',
161
+ 'header' => Mage::helper( 'catalog' )->__( 'Meta Descr' )
162
+ ),
163
+ 'meta_title' => array(
164
+ 'type' => 'text',
165
+ 'width' => '100px',
166
+ 'header' => Mage::helper( 'catalog' )->__( 'Meta Title' )
167
+ ),
168
+ 'short_description' => array(
169
+ 'type' => 'text',
170
+ 'width' => '150px',
171
+ 'header' => Mage::helper( 'catalog' )->__( 'Short Description' ),
172
+ 'string_limit' => $truncate
173
+ ),
174
+ 'description' => array(
175
+ 'type' => 'text',
176
+ 'width' => '200px',
177
+ 'header' => Mage::helper( 'catalog' )->__( 'Description' ),
178
+ 'string_limit' => $truncate
179
+ )
180
+ );
181
+
182
+ return $defaults;
183
+ }
184
+ }
app/code/community/TBT/Enhancedgrid/Model/Resource/Eav/Mysql4/Product/Collection.php CHANGED
@@ -1,4 +1,28 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
  * Enhanced grid Product collection
4
  * @nelkaake -a 15/12/10:
1
  <?php
2
+ /**
3
+ * WDCA
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category WDCA
22
+ * @package TBT_Enhancedgrid
23
+ * @copyright Copyright (c) 2008-2011 WDCA (http://www.wdca.ca)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
  /**
27
  * Enhanced grid Product collection
28
  * @nelkaake -a 15/12/10:
app/code/community/TBT/Enhancedgrid/Model/System/Config/Source/Columns/Show.php CHANGED
@@ -30,8 +30,7 @@ class TBT_Enhancedgrid_Model_System_Config_Source_Columns_Show
30
  public function toOptionArray()
31
  {
32
 
33
- $collection = Mage::getResourceModel('eav/entity_attribute_collection')
34
- ->setEntityTypeFilter( Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId() )
35
  ->addFilter("is_visible", 1);
36
  $cols = array();
37
  $cols[] = array('value' => 'id', 'label' => 'ID');
30
  public function toOptionArray()
31
  {
32
 
33
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
 
34
  ->addFilter("is_visible", 1);
35
  $cols = array();
36
  $cols[] = array('value' => 'id', 'label' => 'ID');
app/code/community/TBT/Enhancedgrid/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <config>
4
  <modules>
5
  <TBT_Enhancedgrid>
6
- <version>1.3.1.3</version>
7
  </TBT_Enhancedgrid>
8
  </modules>
9
  <admin>
3
  <config>
4
  <modules>
5
  <TBT_Enhancedgrid>
6
+ <version>1.3.2.0</version>
7
  </TBT_Enhancedgrid>
8
  </modules>
9
  <admin>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>TBT_Enhancedgrid</name>
4
- <version>1.3.1.3</version>
5
  <stability>stable</stability>
6
  <license>OSL 3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Fixes some issues with the Magento compiler and improves display of some core components.</summary>
10
- <description>Fixes some issues with the Magento compiler and improves display of some core components.</description>
11
- <notes>Fixes some issues with the Magento compiler and improves display of some core components.</notes>
12
  <authors><author><name>Jay</name><user>auto-converted</user><email>contact@wdca.ca</email></author><author><name>Jay</name><user>auto-converted</user><email>nelkaake@wdca.ca</email></author></authors>
13
- <date>2011-07-01</date>
14
- <time>01:03:26</time>
15
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="tbt_enhancedgrid.xml" hash="d0dd492f38558072d5c0dad53703a6c6"/></dir><dir name="template"><dir name="tbt"><dir name="enhancedgrid"><dir name="catalog"><file name="product.phtml" hash="449dec037392f3910b9269a24b99e24a"/><dir name="product"><file name="grid.phtml" hash="8e39bb3abd59ef4ba12fdf4d725dda90"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="tbt"><dir name="enhancedgrid"><file name="egsupplemental.js" hash="da3aa882d47a41c4d2f7d0c48233ae1e"/><file name="enhancedgrid.js" hash="fcbbe08d942719a668d3536246664628"/><dir name="customfunctions"><file name="catalog_products.js" hash="db00553aa26aa6851f92f84447f3cd14"/></dir><dir name="resources"><dir name="css"><file name="enhancedgrid.css" hash="a219b0e656329f2407835dbe346f81d3"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="TBT_Enhancedgrid.xml" hash="85a6ca652ec3777aa244a78c1c4fdac4"/></dir></target><target name="magecommunity"><dir name="TBT"><dir name="Enhancedgrid"><dir name="Block"><dir name="Catalog"><file name="Product.php" hash="68048313967635cce72082d36afb1ac4"/><dir name="Product"><file name="Grid.php" hash="95648279026a015e674fb1f8c0a1f387"/></dir></dir><dir name="System"><file name="Html.php" hash="ae18224ae9a7e450e03ccf22612e3dde"/></dir><dir name="Widget"><file name="Loyalty.php" hash="d1f6919e6bda3e5c201e2b9cd2fb25f1"/><dir name="Grid"><file name="Column.php" hash="b360986bb6f20cb2f7af22bb383c909e"/><dir name="Column"><dir name="Filter"><file name="Category.php" hash="8eb68d6bdb28d08e4aa831f2609be421"/><file name="Image.php" hash="b1e25d3e8d03a0869e1c2edf5fcdd761"/></dir><dir name="Renderer"><file name="Action.php" hash="32c3917ad4c07942e9f0d003c6854b2b"/><file name="Category.php" hash="42eff0eac536ef4b511600b2bd1d2ceb"/><file name="Image.php" hash="ddac5ed4cc015c4dd256f172c802e9cf"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Catalog"><file name="ProductController.php" hash="39ab9a7719710e1454d7f8b1ede4a104"/></dir></dir><dir name="etc"><file name="config.xml" hash="eecb1cc472a616c41eac6e2230b31387"/><file name="system.xml" hash="5e18079f506dae5dc6627f41f1d7336c"/></dir><dir name="Helper"><file name="Data.php" hash="236773d2fc20ccc12702af8a41c5fe96"/></dir><dir name="Model"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><dir name="Product"><file name="Collection.php" hash="8dd3763283b393d0f3efef5556234fa2"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Columns"><file name="Show.php" hash="ef68984f5d56d6c60907e06850a47821"/></dir><dir name="Sort"><file name="Direction.php" hash="23cb37d1af2dd75c3c9537adf90c1bc8"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>TBT_Enhancedgrid</name>
4
+ <version>1.3.2.0</version>
5
  <stability>stable</stability>
6
  <license>OSL 3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Improved some of the architecture to make the grid column handlers more expandable in the future, and resolved issue with Magento Community Edition 1.6+ and Magento Enterprise/Professional Editions 1.11+</summary>
10
+ <description>Enhanced Grid is the most downloaded community-driven extension on Magento Connect with over 15,000 Magento stores world-wide running it. Enhanced Grid makes managing products much easier and more efficient for store administrators.</description>
11
+ <notes>Improved some of the architecture to make the grid column handlers more expandable in the future, and resolved issue with Magento Community Edition 1.6+ and Magento Enterprise/Professional Editions 1.11+</notes>
12
  <authors><author><name>Jay</name><user>auto-converted</user><email>contact@wdca.ca</email></author><author><name>Jay</name><user>auto-converted</user><email>nelkaake@wdca.ca</email></author></authors>
13
+ <date>2011-10-10</date>
14
+ <time>19:15:18</time>
15
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="tbt_enhancedgrid.xml" hash="d0dd492f38558072d5c0dad53703a6c6"/></dir><dir name="template"><dir name="tbt"><dir name="enhancedgrid"><dir name="catalog"><file name="product.phtml" hash="449dec037392f3910b9269a24b99e24a"/><dir name="product"><file name="grid.phtml" hash="8e39bb3abd59ef4ba12fdf4d725dda90"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="tbt"><dir name="enhancedgrid"><file name="egsupplemental.js" hash="da3aa882d47a41c4d2f7d0c48233ae1e"/><file name="enhancedgrid.js" hash="fcbbe08d942719a668d3536246664628"/><dir name="customfunctions"><file name="catalog_products.js" hash="db00553aa26aa6851f92f84447f3cd14"/></dir><dir name="resources"><dir name="css"><file name="enhancedgrid.css" hash="a219b0e656329f2407835dbe346f81d3"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="TBT_Enhancedgrid.xml" hash="85a6ca652ec3777aa244a78c1c4fdac4"/></dir></target><target name="magecommunity"><dir name="TBT"><dir name="Enhancedgrid"><dir name="Block"><dir name="Catalog"><file name="Product.php" hash="68048313967635cce72082d36afb1ac4"/><dir name="Product"><file name="Grid.php" hash="78c9b49ca889805299c9a7e3a369aa6b"/><dir name="Grid"><file name="Columns.php" hash="f84214fc43f665c79b92dc7a092b364f"/></dir></dir></dir><dir name="System"><file name="Html.php" hash="ae18224ae9a7e450e03ccf22612e3dde"/></dir><dir name="Widget"><file name="Loyalty.php" hash="d1f6919e6bda3e5c201e2b9cd2fb25f1"/><dir name="Grid"><file name="Column.php" hash="b360986bb6f20cb2f7af22bb383c909e"/><dir name="Column"><dir name="Filter"><file name="Category.php" hash="8eb68d6bdb28d08e4aa831f2609be421"/><file name="Image.php" hash="b1e25d3e8d03a0869e1c2edf5fcdd761"/></dir><dir name="Renderer"><file name="Action.php" hash="32c3917ad4c07942e9f0d003c6854b2b"/><file name="Category.php" hash="42eff0eac536ef4b511600b2bd1d2ceb"/><file name="Image.php" hash="ddac5ed4cc015c4dd256f172c802e9cf"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Catalog"><file name="ProductController.php" hash="39ab9a7719710e1454d7f8b1ede4a104"/></dir></dir><dir name="etc"><file name="config.xml" hash="7c417ee38f4cb2adc84a0a77001d5616"/><file name="system.xml" hash="5e18079f506dae5dc6627f41f1d7336c"/></dir><dir name="Helper"><file name="Data.php" hash="236773d2fc20ccc12702af8a41c5fe96"/><file name="Version.php" hash="f90fbcb7beffbe1ac6541f529df9b35b"/></dir><dir name="Model"><dir name="Collection"><dir name="Decorator"><file name="Abstract.php" hash="5358ef85d8ad82fef81e220ab5feec46"/></dir></dir><dir name="Product"><dir name="Collection"><dir name="Category"><file name="Decorator.php" hash="16fff625d09211e054e2caebbdd535ce"/></dir></dir><dir name="Grid"><dir name="Settings"><file name="Columns.php" hash="9acfb2ec990f83a25142a35d0bc37989"/></dir></dir></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><dir name="Product"><file name="Collection.php" hash="02e45e6d6dd551431bb29be7cfd165f5"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Columns"><file name="Show.php" hash="d917b5fabc17371eca2701977f112ee6"/></dir><dir name="Sort"><file name="Direction.php" hash="23cb37d1af2dd75c3c9537adf90c1bc8"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>