Year_Make_Model_Filter_Box - Version 3.0

Version Notes

List all products if you click the Go button from main page feature was added.

Download this release

Release Info

Developer Magento Core Team
Extension Year_Make_Model_Filter_Box
Version 3.0
Comparing to
See all releases


Code changes from version 2.0 to 3.0

app/code/local/Pektsekye/Catalog/Model/Category.php CHANGED
@@ -1,9 +1,4 @@
1
  <?php
2
- /*
3
- Written by pektsekye@gmail.com on Monday Jul 20 2009
4
- version 1.0
5
- */
6
-
7
 
8
  class Pektsekye_Catalog_Model_Category extends Mage_Catalog_Model_Category
9
  {
@@ -16,9 +11,9 @@ class Pektsekye_Catalog_Model_Category extends Mage_Catalog_Model_Category
16
  public function getProductCollection()
17
  {
18
 
19
- $expire=time()+60*60*24*90;
20
  $where = "";
21
-
22
  if (isset($_GET['Make'])){
23
  setcookie("Make_selected", $_GET['Make'], $expire,'/');
24
  if ($_GET['Make'] != 'all')
@@ -42,43 +37,26 @@ class Pektsekye_Catalog_Model_Category extends Mage_Catalog_Model_Category
42
 
43
 
44
  if (isset($Make_selected_var))
45
- $where .= " (products_car_make='".$Make_selected_var."' or products_car_make='') ";
46
 
47
  if (isset($Model_selected_var))
48
- $where .= ($where != '' ? ' and ' : '') . " (products_car_model='".$Model_selected_var."' or products_car_model='') ";
49
 
50
  if (isset($Year_selected_var))
51
- $where .= ($where != '' ? ' and ' : '') . " ((products_car_year_bof <= '".$Year_selected_var."' and products_car_year_eof >= '".$Year_selected_var."') or (products_car_year_bof=0 and products_car_year_eof=0)) ";
52
 
53
 
54
  if ($where != ''){
55
 
56
- $resource = Mage::getSingleton('core/resource');
57
  $read= $resource->getConnection('core_read');
58
- $ymmTable = $resource->getTableName('ymm');
59
- $select = $read->select()
60
- ->distinct()
61
- ->from($ymmTable,array('products_id'))
62
- ->where($where);
63
- $rows = $read->fetchAll($select);
64
-
65
- $ids = array();
66
-
67
- if (count($rows) > 0)
68
- foreach ($rows as $r)
69
- $ids [] = $r['products_id'];
70
-
71
  $productTable = $resource->getTableName('catalog_product_entity');
72
- $select = $read->select()
73
- ->distinct()
74
- ->from($productTable,array('entity_id'))
75
- ->where("entity_id not in (SELECT DISTINCT products_id FROM ymm)");
76
- $rows = $read->fetchAll($select);
77
 
78
- if (count($rows) > 0)
79
- foreach ($rows as $r)
80
- $ids [] = $r['entity_id'];
81
-
82
  $collection = Mage::getResourceModel('catalog/product_collection')
83
  ->setStoreId($this->getStoreId())
84
  ->addCategoryFilter($this)
1
  <?php
 
 
 
 
 
2
 
3
  class Pektsekye_Catalog_Model_Category extends Mage_Catalog_Model_Category
4
  {
11
  public function getProductCollection()
12
  {
13
 
14
+ $expire = time()+60*60*24*90;
15
  $where = "";
16
+
17
  if (isset($_GET['Make'])){
18
  setcookie("Make_selected", $_GET['Make'], $expire,'/');
19
  if ($_GET['Make'] != 'all')
37
 
38
 
39
  if (isset($Make_selected_var))
40
+ $where .= " (make='".$Make_selected_var."' or make='') ";
41
 
42
  if (isset($Model_selected_var))
43
+ $where .= ($where != '' ? ' and ' : '') . " (model='".$Model_selected_var."' or model='') ";
44
 
45
  if (isset($Year_selected_var))
46
+ $where .= ($where != '' ? ' and ' : '') . " ((year_bof <= '".$Year_selected_var."' and year_eof >= '".$Year_selected_var."') or (year_bof=0 and year_eof=0)) ";
47
 
48
 
49
  if ($where != ''){
50
 
51
+ $resource = Mage::getSingleton('core/resource');
52
  $read= $resource->getConnection('core_read');
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  $productTable = $resource->getTableName('catalog_product_entity');
54
+ $ymmTable = $resource->getTableName('ymm');
55
+ $rows = $read->fetchAll("SELECT entity_id FROM $productTable LEFT JOIN $ymmTable USING (entity_id) WHERE ymm_id IS NULL OR $where");
56
+
57
+ foreach ($rows as $r)
58
+ $ids [] = $r['entity_id'];
59
 
 
 
 
 
60
  $collection = Mage::getResourceModel('catalog/product_collection')
61
  ->setStoreId($this->getStoreId())
62
  ->addCategoryFilter($this)
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit/Tab/Form.php CHANGED
@@ -8,34 +8,34 @@ class Pektsekye_Ymm_Block_Adminhtml_Ymm_Edit_Tab_Form extends Mage_Adminhtml_Blo
8
  $this->setForm($form);
9
  $fieldset = $form->addFieldset('ymm_form', array('legend'=>Mage::helper('ymm')->__('Item information')));
10
 
11
- $fieldset->addField('products_id', 'text', array(
12
  'label' => Mage::helper('ymm')->__('Products ID'),
13
  'required' => true,
14
- 'name' => 'products_id',
15
  ));
16
 
17
- $fieldset->addField('products_car_make', 'text', array(
18
  'label' => Mage::helper('ymm')->__('Vehicle Make'),
19
  'required' => true,
20
- 'name' => 'products_car_make',
21
  ));
22
 
23
- $fieldset->addField('products_car_model', 'text', array(
24
  'label' => Mage::helper('ymm')->__('Vehicle Model'),
25
  'required' => false,
26
- 'name' => 'products_car_model',
27
  ));
28
 
29
- $fieldset->addField('products_car_year_bof', 'text', array(
30
  'label' => Mage::helper('ymm')->__('From Year (dddd)'),
31
  'required' => false,
32
- 'name' => 'products_car_year_bof',
33
  ));
34
 
35
- $fieldset->addField('products_car_year_eof', 'text', array(
36
  'label' => Mage::helper('ymm')->__('To Year (dddd)'),
37
  'required' => false,
38
- 'name' => 'products_car_year_eof',
39
  ));
40
 
41
  if ( Mage::getSingleton('adminhtml/session')->getYmmData() )
8
  $this->setForm($form);
9
  $fieldset = $form->addFieldset('ymm_form', array('legend'=>Mage::helper('ymm')->__('Item information')));
10
 
11
+ $fieldset->addField('entity_id', 'text', array(
12
  'label' => Mage::helper('ymm')->__('Products ID'),
13
  'required' => true,
14
+ 'name' => 'entity_id',
15
  ));
16
 
17
+ $fieldset->addField('make', 'text', array(
18
  'label' => Mage::helper('ymm')->__('Vehicle Make'),
19
  'required' => true,
20
+ 'name' => 'make',
21
  ));
22
 
23
+ $fieldset->addField('model', 'text', array(
24
  'label' => Mage::helper('ymm')->__('Vehicle Model'),
25
  'required' => false,
26
+ 'name' => 'model',
27
  ));
28
 
29
+ $fieldset->addField('year_bof', 'text', array(
30
  'label' => Mage::helper('ymm')->__('From Year (dddd)'),
31
  'required' => false,
32
+ 'name' => 'year_bof',
33
  ));
34
 
35
+ $fieldset->addField('year_eof', 'text', array(
36
  'label' => Mage::helper('ymm')->__('To Year (dddd)'),
37
  'required' => false,
38
+ 'name' => 'year_eof',
39
  ));
40
 
41
  if ( Mage::getSingleton('adminhtml/session')->getYmmData() )
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Grid.php CHANGED
@@ -6,7 +6,7 @@ class Pektsekye_Ymm_Block_Adminhtml_Ymm_Grid extends Mage_Adminhtml_Block_Widget
6
  {
7
  parent::__construct();
8
  $this->setId('ymmGrid');
9
- $this->setDefaultSort('id');
10
  $this->setDefaultDir('ASC');
11
  $this->setSaveParametersInSession(true);
12
  }
@@ -21,34 +21,34 @@ class Pektsekye_Ymm_Block_Adminhtml_Ymm_Grid extends Mage_Adminhtml_Block_Widget
21
  protected function _prepareColumns()
22
  {
23
 
24
- $this->addColumn('products_id', array(
25
  'header' => Mage::helper('ymm')->__('Products ID'),
26
  'align' =>'left',
27
- 'index' => 'products_id',
28
  ));
29
 
30
- $this->addColumn('products_car_make', array(
31
  'header' => Mage::helper('ymm')->__('Vehicle Make'),
32
  'align' =>'left',
33
- 'index' => 'products_car_make',
34
  ));
35
 
36
- $this->addColumn('products_car_model', array(
37
  'header' => Mage::helper('ymm')->__('Vehicle Model'),
38
  'align' =>'left',
39
- 'index' => 'products_car_model',
40
  ));
41
 
42
- $this->addColumn('products_car_year_bof', array(
43
  'header' => Mage::helper('ymm')->__('From Year'),
44
  'align' =>'left',
45
- 'index' => 'products_car_year_bof',
46
  ));
47
 
48
- $this->addColumn('products_car_year_eof', array(
49
  'header' => Mage::helper('ymm')->__('To Year'),
50
  'align' =>'left',
51
- 'index' => 'products_car_year_eof',
52
  ));
53
 
54
  $this->addColumn('action',
@@ -76,7 +76,7 @@ class Pektsekye_Ymm_Block_Adminhtml_Ymm_Grid extends Mage_Adminhtml_Block_Widget
76
 
77
  protected function _prepareMassaction()
78
  {
79
- $this->setMassactionIdField('id');
80
  $this->getMassactionBlock()->setFormFieldName('ymm');
81
 
82
  $this->getMassactionBlock()->addItem('delete', array(
6
  {
7
  parent::__construct();
8
  $this->setId('ymmGrid');
9
+ $this->setDefaultSort('ymm_id');
10
  $this->setDefaultDir('ASC');
11
  $this->setSaveParametersInSession(true);
12
  }
21
  protected function _prepareColumns()
22
  {
23
 
24
+ $this->addColumn('entity_id', array(
25
  'header' => Mage::helper('ymm')->__('Products ID'),
26
  'align' =>'left',
27
+ 'index' => 'entity_id',
28
  ));
29
 
30
+ $this->addColumn('make', array(
31
  'header' => Mage::helper('ymm')->__('Vehicle Make'),
32
  'align' =>'left',
33
+ 'index' => 'make',
34
  ));
35
 
36
+ $this->addColumn('model', array(
37
  'header' => Mage::helper('ymm')->__('Vehicle Model'),
38
  'align' =>'left',
39
+ 'index' => 'model',
40
  ));
41
 
42
+ $this->addColumn('year_bof', array(
43
  'header' => Mage::helper('ymm')->__('From Year'),
44
  'align' =>'left',
45
+ 'index' => 'year_bof',
46
  ));
47
 
48
+ $this->addColumn('year_eof', array(
49
  'header' => Mage::helper('ymm')->__('To Year'),
50
  'align' =>'left',
51
+ 'index' => 'year_eof',
52
  ));
53
 
54
  $this->addColumn('action',
76
 
77
  protected function _prepareMassaction()
78
  {
79
+ $this->setMassactionIdField('ymm_id');
80
  $this->getMassactionBlock()->setFormFieldName('ymm');
81
 
82
  $this->getMassactionBlock()->addItem('delete', array(
app/code/local/Pektsekye/Ymm/Block/Product/Result.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Pektsekye_Ymm_Block_Product_Result extends Mage_Catalog_Block_Product_Abstract
5
+ {
6
+ protected $_productCollection;
7
+
8
+ protected function _prepareLayout()
9
+ {
10
+ $title = $this->getHeaderText();
11
+ $this->getLayout()->getBlock('head')->setTitle($title);
12
+ $this->getLayout()->getBlock('root')->setHeaderTitle($title);
13
+ return parent::_prepareLayout();
14
+ }
15
+
16
+ public function setListOrders() {
17
+ $this->getChild('search_result_list')
18
+ ->setAvailableOrders(array(
19
+ 'name' => Mage::helper('ymm')->__('Name'),
20
+ 'price'=>Mage::helper('ymm')->__('Price'))
21
+ );
22
+ }
23
+
24
+ public function setListModes() {
25
+ $this->getChild('search_result_list')
26
+ ->setModes(array(
27
+ 'grid' => Mage::helper('ymm')->__('Grid'),
28
+ 'list' => Mage::helper('ymm')->__('List'))
29
+ );
30
+ }
31
+
32
+ public function setListCollection() {
33
+ $this->getChild('search_result_list')
34
+ ->setCollection($this->_getProductCollection());
35
+ }
36
+
37
+ public function getProductListHtml()
38
+ {
39
+ return $this->getChildHtml('search_result_list');
40
+ }
41
+
42
+ protected function _getProductCollection()
43
+ {
44
+ $expire = time()+60*60*24*90;
45
+ $where = "";
46
+
47
+ if (isset($_GET['Make'])){
48
+ setcookie("Make_selected", $_GET['Make'], $expire,'/');
49
+ if ($_GET['Make'] != 'all')
50
+ $Make_selected_var = $_GET['Make'];
51
+ } elseif (isset($_COOKIE['Make_selected']) && $_COOKIE['Make_selected'] != 'all')
52
+ $Make_selected_var = $_COOKIE['Make_selected'];
53
+
54
+ if (isset($_GET['Model'])){
55
+ setcookie("Model_selected", $_GET['Model'], $expire,'/');
56
+ if ($_GET['Model'] != 'all')
57
+ $Model_selected_var = $_GET['Model'];
58
+ } elseif (isset($_COOKIE['Model_selected']) && $_COOKIE['Model_selected'] != 'all')
59
+ $Model_selected_var = $_COOKIE['Model_selected'];
60
+
61
+ if (isset($_GET['Year'])){
62
+ setcookie("Year_selected", $_GET['Year'], $expire,'/');
63
+ if ($_GET['Year'] != 0)
64
+ $Year_selected_var = $_GET['Year'];
65
+ } elseif (isset($_COOKIE['Year_selected']) && $_COOKIE['Year_selected'] != 0)
66
+ $Year_selected_var = $_COOKIE['Year_selected'];
67
+
68
+
69
+ if (isset($Make_selected_var))
70
+ $where .= " (make='".$Make_selected_var."' or make='') ";
71
+
72
+ if (isset($Model_selected_var))
73
+ $where .= ($where != '' ? ' and ' : '') . " (model='".$Model_selected_var."' or model='') ";
74
+
75
+ if (isset($Year_selected_var))
76
+ $where .= ($where != '' ? ' and ' : '') . " ((year_bof <= '".$Year_selected_var."' and year_eof >= '".$Year_selected_var."') or (year_bof=0 and year_eof=0)) ";
77
+
78
+
79
+ if ($where != ''){
80
+
81
+ $resource = Mage::getSingleton('core/resource');
82
+ $read= $resource->getConnection('core_read');
83
+ $productTable = $resource->getTableName('catalog_product_entity');
84
+ $ymmTable = $resource->getTableName('ymm');
85
+ $rows = $read->fetchAll("SELECT entity_id FROM $productTable LEFT JOIN $ymmTable USING (entity_id) WHERE ymm_id IS NULL OR $where");
86
+
87
+ foreach ($rows as $r)
88
+ $ids [] = $r['entity_id'];
89
+
90
+ $this->_productCollection = Mage::getResourceModel('catalog/product_collection')
91
+ ->setStoreId($this->getStoreId())
92
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
93
+ ->addIdFilter($ids)
94
+ ->addStoreFilter()
95
+ ->addMinimalPrice()
96
+ ->addUrlRewrite();
97
+ Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_productCollection);
98
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($this->_productCollection);
99
+ } else {
100
+
101
+ $this->_productCollection = Mage::getResourceModel('catalog/product_collection')
102
+ ->setStoreId($this->getStoreId())
103
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
104
+ ->addStoreFilter()
105
+ ->addMinimalPrice()
106
+ ->addUrlRewrite();
107
+ Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_productCollection);
108
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($this->_productCollection);
109
+ }
110
+
111
+ return $this->_productCollection;
112
+ }
113
+
114
+ public function getResultCount()
115
+ {
116
+ if (!$this->getData('result_count')) {
117
+ $size = $this->_getProductCollection()->getSize();
118
+ $this->setResultCount($size);
119
+ }
120
+ return $this->getData('result_count');
121
+ }
122
+
123
+ public function getHeaderText()
124
+ {
125
+
126
+ $make = $this->getRequest()->getParam('Make');
127
+ $model = $this->getRequest()->getParam('Model');
128
+ $year = $this->getRequest()->getParam('Year');
129
+
130
+ if($make && $make != 'all') {
131
+ $make = $this->getRequest()->getParam('Make');
132
+
133
+ if($model == 'all')
134
+ $model = '';
135
+
136
+ if($year == 0)
137
+ $year = '';
138
+
139
+ return Mage::helper('ymm')->__("Products for %s", $this->htmlEscape("$make $model $year"));
140
+
141
+ } else {
142
+ return false;
143
+ }
144
+ }
145
+
146
+ public function getSubheaderText()
147
+ {
148
+ return false;
149
+ }
150
+
151
+ public function getNoResultText()
152
+ {
153
+ return Mage::helper('ymm')->__('No matches found.');
154
+ }
155
+ }
app/code/local/Pektsekye/Ymm/Block/Ymm.php CHANGED
@@ -1,6 +1,9 @@
1
  <?php
2
  class Pektsekye_Ymm_Block_Ymm extends Mage_Core_Block_Template
3
- {
 
 
 
4
  public function _prepareLayout()
5
  {
6
  return parent::_prepareLayout();
@@ -13,5 +16,13 @@ class Pektsekye_Ymm_Block_Ymm extends Mage_Core_Block_Template
13
  }
14
  return $this->getData('ymm');
15
 
16
- }
 
 
 
 
 
 
 
 
17
  }
1
  <?php
2
  class Pektsekye_Ymm_Block_Ymm extends Mage_Core_Block_Template
3
+ {
4
+
5
+ protected $_resultPage = null;
6
+
7
  public function _prepareLayout()
8
  {
9
  return parent::_prepareLayout();
16
  }
17
  return $this->getData('ymm');
18
 
19
+ }
20
+
21
+ public function setResultPage($resultPage)
22
+ {
23
+ $this->_resultPage = $resultPage;
24
+
25
+ return $this;
26
+ }
27
+
28
  }
app/code/local/Pektsekye/Ymm/Model/Mysql4/Ymm.php CHANGED
@@ -5,6 +5,6 @@ class Pektsekye_Ymm_Model_Mysql4_Ymm extends Mage_Core_Model_Mysql4_Abstract
5
  public function _construct()
6
  {
7
  // Note that the ymm_id refers to the key field in your database table.
8
- $this->_init('ymm/ymm', 'id');
9
  }
10
  }
5
  public function _construct()
6
  {
7
  // Note that the ymm_id refers to the key field in your database table.
8
+ $this->_init('ymm/ymm', 'ymm_id');
9
  }
10
  }
app/code/local/Pektsekye/Ymm/controllers/Adminhtml/YmmController.php CHANGED
@@ -52,11 +52,11 @@ class Pektsekye_Ymm_Adminhtml_YmmController extends Mage_Adminhtml_Controller_ac
52
  public function saveAction() {
53
  if ($data = $this->getRequest()->getPost()) {
54
 
55
- $data ['products_id'] = (int) $data ['products_id'];
56
- $data ['products_car_make'] = trim(preg_replace('/[^\w\s-]/','',$data ['products_car_make']));
57
- $data ['products_car_model'] = trim(preg_replace('/[^\w\s-]/','',$data ['products_car_model']));
58
- $data ['products_car_year_bof'] = (int) $data ['products_car_year_bof'];
59
- $data ['products_car_year_eof'] = (int) $data ['products_car_year_eof'];
60
 
61
  $model = Mage::getModel('ymm/ymm');
62
  $model->setData($data)
@@ -243,12 +243,12 @@ class Pektsekye_Ymm_Adminhtml_YmmController extends Mage_Adminhtml_Controller_ac
243
  $read= $resource->getConnection('core_read');
244
  $ymmTable = $resource->getTableName('ymm');
245
  $select = $read->select()
246
- ->from($ymmTable,array('id'))
247
- ->where("products_id=?",(int)$v[0])
248
- ->where("products_car_make=?",$v[1])
249
- ->where("products_car_model=?",$v[2])
250
- ->where("products_car_year_bof=?",(int)$v[3])
251
- ->where("products_car_year_eof=?",(int)$v[4])
252
  ->limit(1);
253
 
254
  if($read->fetchOne($select)){
@@ -256,11 +256,11 @@ class Pektsekye_Ymm_Adminhtml_YmmController extends Mage_Adminhtml_Controller_ac
256
  }
257
 
258
  $data = array(
259
- 'products_id'=>$v[0],
260
- 'products_car_make' => $v[1],
261
- 'products_car_model' => $v[2],
262
- 'products_car_year_bof' => $v[3],
263
- 'products_car_year_eof'=>$v[4],
264
  );
265
 
266
  $model = Mage::getModel('ymm/ymm');
@@ -271,7 +271,7 @@ class Pektsekye_Ymm_Adminhtml_YmmController extends Mage_Adminhtml_Controller_ac
271
  }
272
  }
273
  else {
274
- Mage::throwException(Mage::helper('tax')->__('Invalid file format upload attempt'));
275
  }
276
 
277
  return $number;
52
  public function saveAction() {
53
  if ($data = $this->getRequest()->getPost()) {
54
 
55
+ $data ['entity_id'] = (int) $data ['entity_id'];
56
+ $data ['make'] = trim(preg_replace('/[^\w\s-]/','',$data ['make']));
57
+ $data ['model'] = trim(preg_replace('/[^\w\s-]/','',$data ['model']));
58
+ $data ['year_bof'] = (int) $data ['year_bof'];
59
+ $data ['year_eof'] = (int) $data ['year_eof'];
60
 
61
  $model = Mage::getModel('ymm/ymm');
62
  $model->setData($data)
243
  $read= $resource->getConnection('core_read');
244
  $ymmTable = $resource->getTableName('ymm');
245
  $select = $read->select()
246
+ ->from($ymmTable,array('ymm_id'))
247
+ ->where("entity_id=?",(int)$v[0])
248
+ ->where("make=?",$v[1])
249
+ ->where("model=?",$v[2])
250
+ ->where("year_bof=?",(int)$v[3])
251
+ ->where("year_eof=?",(int)$v[4])
252
  ->limit(1);
253
 
254
  if($read->fetchOne($select)){
256
  }
257
 
258
  $data = array(
259
+ 'entity_id'=>$v[0],
260
+ 'make' => $v[1],
261
+ 'model' => $v[2],
262
+ 'year_bof' => $v[3],
263
+ 'year_eof'=>$v[4],
264
  );
265
 
266
  $model = Mage::getModel('ymm/ymm');
271
  }
272
  }
273
  else {
274
+ Mage::throwException(Mage::helper('ymm')->__('Invalid file format upload attempt'));
275
  }
276
 
277
  return $number;
app/code/local/Pektsekye/Ymm/controllers/ProductController.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Pektsekye_Ymm_ProductController extends Mage_Core_Controller_Front_Action
4
+ {
5
+
6
+ public function listAction()
7
+ {
8
+ if(!$this->getRequest()->getParam('Make') || $this->getRequest()->getParam('Make') == 'all') {
9
+ $this->_redirectReferer();
10
+ return;
11
+ }
12
+ $this->loadLayout();
13
+ $this->_initLayoutMessages('checkout/session');
14
+ $this->_initLayoutMessages('tag/session');
15
+ $this->renderLayout();
16
+ }
17
+ }
app/code/local/Pektsekye/Ymm/sql/ymm_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //core_resource table
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+ ALTER TABLE `ymm` CHANGE `id` `ymm_id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
9
+ CHANGE `products_id` `entity_id` INT( 11 ) NOT NULL ,
10
+ CHANGE `products_car_make` `make` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
11
+ CHANGE `products_car_model` `model` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
12
+ CHANGE `products_car_year_bof` `year_bof` INT( 11 ) NOT NULL ,
13
+ CHANGE `products_car_year_eof` `year_eof` INT( 11 ) NOT NULL ;
14
+ ");
15
+
16
+ $installer->endSetup();
app/design/frontend/default/default/layout/ymm.xml CHANGED
@@ -4,5 +4,31 @@
4
  <reference name="right">
5
  <block type="ymm/ymm" name="ymm" template="ymm/ymm.phtml" />
6
  </reference>
7
- </catalog_category_view>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  </layout>
4
  <reference name="right">
5
  <block type="ymm/ymm" name="ymm" template="ymm/ymm.phtml" />
6
  </reference>
7
+ </catalog_category_view>
8
+
9
+ <cms_page>
10
+ <reference name="right">
11
+ <block type="ymm/ymm" name="ymm" template="ymm/ymm.phtml">
12
+ <action method="setResultPage"><resultPage>ymm/product/list</resultPage></action>
13
+ </block>
14
+ </reference>
15
+ </cms_page>
16
+
17
+ <ymm_product_list>
18
+ <!-- Mage_Tag -->
19
+ <reference name="content">
20
+ <block type="ymm/product_result" name="ymm_products" template="catalogsearch/result.phtml">
21
+ <block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml"></block>
22
+ <action method="setListOrders"/>
23
+ <action method="setListModes"/>
24
+ <action method="setListCollection"/>
25
+ </block>
26
+ </reference>
27
+ <reference name="right">
28
+ <block type="ymm/ymm" name="ymm" template="ymm/ymm.phtml">
29
+ <action method="setResultPage"><resultPage>ymm/product/list</resultPage></action>
30
+ </block>
31
+ </reference>
32
+ </ymm_product_list>
33
+
34
  </layout>
app/design/frontend/default/default/template/ymm/ymm.phtml CHANGED
@@ -1,21 +1,22 @@
1
  <?php
2
  /*
3
- Written by pektsekye@gmail.com on Friday Jul 24 2009
4
- version 1.0
5
  */
6
 
 
7
  $resource = Mage::getSingleton('core/resource');
8
  $read= $resource->getConnection('core_read');
9
  $ymmTable = $resource->getTableName('ymm');
10
 
11
  $select = $read->select()
12
  ->distinct()
13
- ->from($ymmTable,array('products_car_make','products_car_model','products_car_year_bof','products_car_year_eof'))
14
- ->where('products_car_make != ?','')
15
- ->where('products_car_model != ?','')
16
- ->where('products_car_year_bof != ?',0)
17
- ->where('products_car_year_eof != ?',0)
18
- ->order(array('products_car_make', 'products_car_model', 'products_car_year_bof', 'products_car_year_eof')) ;
19
 
20
  $rows = $read->fetchAll($select);
21
 
@@ -35,34 +36,29 @@ var c = new Array();';
35
  $make_old = '';
36
  $model_old = '';
37
 
38
- foreach ($rows as $Makes) {
39
-
40
- $make = $Makes['products_car_make'];
41
- $model = $Makes['products_car_model'];
42
- $year_bof = $Makes['products_car_year_bof'];
43
- $year_eof = $Makes['products_car_year_eof'];
44
 
45
- if (!isset($M_a [$make]))
46
- $Make_array[] = array('id' => $make, 'text' => $make);
47
 
48
- if (!isset($M_a [$make][$model]) && count($y) > 0){
49
  $M_a [$make_old][$model_old]=$y;
50
  $y = array();
51
  }
52
 
53
- if ($year_bof != 0 && $year_eof != 0){
54
- if ($year_bof == $year_eof){
55
- $y [$year_bof] = 1;
56
- } elseif ($year_bof < $year_eof){
57
- while ($year_bof <= $year_eof){
58
- $y [$year_bof] = 1;
59
- $year_bof++;
60
  }
61
  }
62
  }
63
- $make_old = $make;
64
- $model_old = $model;
65
- $M_a [$make][$model] = array();
66
  }
67
 
68
  $M_a [$make_old][$model_old]=$y;
@@ -158,7 +154,7 @@ function pop_year(){
158
  <div class="head">
159
  <h4><span><?php echo $this->__('Select Vehicle') ?></span></h4>
160
  </div>
161
- <form name="make_model_year" method="get">
162
  <div class="content">
163
  <select name="Make" onChange="pop_model();" style="width: 100%">
164
  <?php
@@ -183,7 +179,7 @@ function pop_year(){
183
  </div>
184
  <div class="actions">
185
  <button class="form-button-alt right" type="submit"><span><?php echo $this->__('Go') ?></span></button>
186
- <a href="?Make=all&Model=all&Year=0">Clear Vehicle</a>&nbsp;&nbsp;&nbsp;&nbsp;
187
  </div>
188
  </form>
189
  </div>
1
  <?php
2
  /*
3
+ Written by pektsekye@gmail.com on Monday Jul 27 2009
4
+ version 3.0
5
  */
6
 
7
+
8
  $resource = Mage::getSingleton('core/resource');
9
  $read= $resource->getConnection('core_read');
10
  $ymmTable = $resource->getTableName('ymm');
11
 
12
  $select = $read->select()
13
  ->distinct()
14
+ ->from($ymmTable,array('make','model','year_bof','year_eof'))
15
+ ->where('make != ?','')
16
+ ->where('model != ?','')
17
+ ->where('year_bof != ?',0)
18
+ ->where('year_eof != ?',0)
19
+ ->order(array('make', 'model', 'year_bof', 'year_eof')) ;
20
 
21
  $rows = $read->fetchAll($select);
22
 
36
  $make_old = '';
37
  $model_old = '';
38
 
39
+ foreach ($rows as $r) {
 
 
 
 
 
40
 
41
+ if (!isset($M_a [$r['make']]))
42
+ $Make_array[] = array('id' => $r['make'], 'text' => $r['make']);
43
 
44
+ if (!isset($M_a [$r['make']][$r['model']]) && count($y) > 0){
45
  $M_a [$make_old][$model_old]=$y;
46
  $y = array();
47
  }
48
 
49
+ if ($r['year_bof'] != 0 && $r['year_eof'] != 0){
50
+ if ($r['year_bof'] == $r['year_eof']){
51
+ $y [$r['year_bof']] = 1;
52
+ } elseif ($r['year_bof'] < $r['year_eof']){
53
+ while ($r['year_bof'] <= $r['year_eof']){
54
+ $y [$r['year_bof']] = 1;
55
+ $r['year_bof']++;
56
  }
57
  }
58
  }
59
+ $make_old = $r['make'];
60
+ $model_old = $r['model'];
61
+ $M_a [$r['make']][$r['model']] = array();
62
  }
63
 
64
  $M_a [$make_old][$model_old]=$y;
154
  <div class="head">
155
  <h4><span><?php echo $this->__('Select Vehicle') ?></span></h4>
156
  </div>
157
+ <form name="make_model_year" action="<?php echo $this->_resultPage != null ? Mage::getUrl($this->_resultPage) : '' ;?>" method="get">
158
  <div class="content">
159
  <select name="Make" onChange="pop_model();" style="width: 100%">
160
  <?php
179
  </div>
180
  <div class="actions">
181
  <button class="form-button-alt right" type="submit"><span><?php echo $this->__('Go') ?></span></button>
182
+ <?php if($this->_resultPage == null && isset($Make_selected_var)): ?><a href="?Make=all&Model=all&Year=0">Clear Vehicle</a>&nbsp;&nbsp;&nbsp;&nbsp;<?php endif ?>
183
  </div>
184
  </form>
185
  </div>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Year_Make_Model_Filter_Box</name>
4
- <version>2.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -22,11 +22,11 @@ NOTE: You should know your product id to be able to add an YMM item to it.
22
  You can find product id in the product description page url:
23
  http://yoursite.com/magento/catalog/product/view/id/119/s/coalesce-functioning-on-impatience-t-shirt/category/4/
24
  The number 119 is the product id in the url.</description>
25
- <notes>Import feature was added</notes>
26
  <authors><author><name>Stanislav</name><user>auto-converted</user><email>pektsekye@gmail.com</email></author></authors>
27
- <date>2009-07-24</date>
28
- <time>02:30:33</time>
29
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="ymm.xml" hash="07bb5759f6ff145da493c94452f029af"/></dir><dir name="template"><dir name="ymm"><file name="importExport.phtml" hash="962cd5005434dfb5878b59af757f796e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="ymm.xml" hash="1db60ab2dc6f85b6866d9162a252a4ad"/></dir><dir name="template"><dir name="ymm"><file name="ymm.phtml" hash="fa5b0beff2dbf244f077385019f1bdd8"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Pektsekye_Catalog.xml" hash="89e3ec6056b4ba53d06df1370b347d42"/><file name="Pektsekye_Ymm.xml" hash="990f4f561816481bd0c517f4fa131436"/></dir></target><target name="magelocal"><dir name="Pektsekye"><dir name="Catalog"><dir name="Model"><file name="Category.php" hash="adb2fc5d69c5c122033d336236a3c88f"/></dir></dir><dir name="Ymm"><dir name="Block"><dir name="Adminhtml"><dir name="Ymm"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="37e926941c2510b54e4d3048f7ee1b18"/></dir><file name="Form.php" hash="c673af9d5e772ee2230a838971a633e1"/><file name="Tabs.php" hash="9048cfd443135e36e2b9cb5de38fcb47"/></dir><file name="Edit.php" hash="fb03b2d7cc9d282221af18c6ce9f6f9f"/><file name="Grid.php" hash="57d72d01ed8140f55b2490a8b08b8409"/><file name="ImportExport.php" hash="e1b161394a704c51c454ead1ca04e6cd"/></dir><file name="Ymm.php" hash="2c2d280c93d8839cd67515cd2d6c7ddd"/></dir><file name="Ymm.php" hash="3b7b316856d66630a6a926b5645cd4db"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="YmmController.php" hash="bef44e8dc00bfd6e0cf20bbfaf4f3fad"/></dir><file name="IndexController.php" hash="241a989b18c6309977568c050215730a"/></dir><dir name="etc"><file name="config.xml" hash="8290182a510c6e471fe0396a61419283"/></dir><dir name="Helper"><file name="Data.php" hash="0cd0de912f0412670f9657b395861d90"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Ymm"><file name="Collection.php" hash="1c6a50ea1416ce936892156806d20e15"/></dir><file name="Ymm.php" hash="8ac41d6fdf44dbf5bea1e9b01a0a0389"/></dir><file name="Status.php" hash="a10da0eebafef60fcceb6a8c396ad201"/><file name="Ymm.php" hash="fdf6dbac2b9595f7183ca1f951538b97"/></dir><dir name="sql"><dir name="ymm_setup"><file name="mysql4-install-0.1.0.php" hash="9e4d9d55d8996105775b26c667eff6d1"/></dir></dir></dir></dir></target></contents>
30
  <compatible/>
31
  <dependencies/>
32
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Year_Make_Model_Filter_Box</name>
4
+ <version>3.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
22
  You can find product id in the product description page url:
23
  http://yoursite.com/magento/catalog/product/view/id/119/s/coalesce-functioning-on-impatience-t-shirt/category/4/
24
  The number 119 is the product id in the url.</description>
25
+ <notes>List all products if you click the Go button from main page feature was added.</notes>
26
  <authors><author><name>Stanislav</name><user>auto-converted</user><email>pektsekye@gmail.com</email></author></authors>
27
+ <date>2009-07-26</date>
28
+ <time>23:54:23</time>
29
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="ymm.xml" hash="07bb5759f6ff145da493c94452f029af"/></dir><dir name="template"><dir name="ymm"><file name="importExport.phtml" hash="962cd5005434dfb5878b59af757f796e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="ymm.xml" hash="4c4dcedb9e05745a45c4208388e207dc"/></dir><dir name="template"><dir name="ymm"><file name="ymm.phtml" hash="e9252af0c926446a662fd5180c15a59a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Pektsekye_Catalog.xml" hash="89e3ec6056b4ba53d06df1370b347d42"/><file name="Pektsekye_Ymm.xml" hash="990f4f561816481bd0c517f4fa131436"/></dir></target><target name="magelocal"><dir name="Pektsekye"><dir name="Catalog"><dir name="Model"><file name="Category.php" hash="b34d5e7961c62332569fdb6eb3945e3f"/></dir></dir><dir name="Ymm"><dir name="Block"><dir name="Adminhtml"><dir name="Ymm"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="df436e6aad93d09f7d3082e08373ae22"/></dir><file name="Form.php" hash="c673af9d5e772ee2230a838971a633e1"/><file name="Tabs.php" hash="9048cfd443135e36e2b9cb5de38fcb47"/></dir><file name="Edit.php" hash="fb03b2d7cc9d282221af18c6ce9f6f9f"/><file name="Grid.php" hash="ada75e652f9d9920c08a229242181a05"/><file name="ImportExport.php" hash="e1b161394a704c51c454ead1ca04e6cd"/></dir><file name="Ymm.php" hash="2c2d280c93d8839cd67515cd2d6c7ddd"/></dir><dir name="Product"><file name="Result.php" hash="6e2516eba80668dc7229825d578596d2"/></dir><file name="Ymm.php" hash="d3fe55f0fb108ec9407d90857f0415b5"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="YmmController.php" hash="917dbf072d01849a01aa3d35945ef14a"/></dir><file name="IndexController.php" hash="241a989b18c6309977568c050215730a"/><file name="ProductController.php" hash="269f3e7dbf8ba28581e46e2800392ac7"/></dir><dir name="etc"><file name="config.xml" hash="8290182a510c6e471fe0396a61419283"/></dir><dir name="Helper"><file name="Data.php" hash="0cd0de912f0412670f9657b395861d90"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Ymm"><file name="Collection.php" hash="1c6a50ea1416ce936892156806d20e15"/></dir><file name="Ymm.php" hash="1608c162d190561029817336de386205"/></dir><file name="Status.php" hash="a10da0eebafef60fcceb6a8c396ad201"/><file name="Ymm.php" hash="fdf6dbac2b9595f7183ca1f951538b97"/></dir><dir name="sql"><dir name="ymm_setup"><file name="mysql4-install-0.1.0.php" hash="9e4d9d55d8996105775b26c667eff6d1"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="b3c26ec790ce60161c9317b01f111ea5"/></dir></dir></dir></dir></target></contents>
30
  <compatible/>
31
  <dependencies/>
32
  </package>