Year_Make_Model_Filter_Box - Version 4.0

Version Notes

Category navigation become filtered by ymm.

Layered navigation "SHOP BY" was added to the ymm/product/list page.

The products without ymm restrictions are not longer considered as universal and are not shown.

Download this release

Release Info

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


Code changes from version 3.4 to 4.0

app/code/local/Pektsekye/Catalog/Model/Category.php CHANGED
@@ -11,51 +11,9 @@ class Pektsekye_Catalog_Model_Category extends Mage_Catalog_Model_Category
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')
20
- $Make_selected_var = $_GET['Make'];
21
- } elseif (isset($_COOKIE['Make_selected']) && $_COOKIE['Make_selected'] != 'all')
22
- $Make_selected_var = $_COOKIE['Make_selected'];
23
-
24
- if (isset($_GET['Model'])){
25
- setcookie("Model_selected", $_GET['Model'], $expire,'/');
26
- if ($_GET['Model'] != 'all')
27
- $Model_selected_var = $_GET['Model'];
28
- } elseif (isset($_COOKIE['Model_selected']) && $_COOKIE['Model_selected'] != 'all')
29
- $Model_selected_var = $_COOKIE['Model_selected'];
30
-
31
- if (isset($_GET['Year'])){
32
- setcookie("Year_selected", $_GET['Year'], $expire,'/');
33
- if ($_GET['Year'] != 0)
34
- $Year_selected_var = $_GET['Year'];
35
- } elseif (isset($_COOKIE['Year_selected']) && $_COOKIE['Year_selected'] != 0)
36
- $Year_selected_var = $_COOKIE['Year_selected'];
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())
11
  public function getProductCollection()
12
  {
13
 
14
+ $helper = new Pektsekye_Ymm_Helper_Data;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ if($ids = $helper->getProductIds()){
 
17
 
18
  $collection = Mage::getResourceModel('catalog/product_collection')
19
  ->setStoreId($this->getStoreId())
app/code/local/Pektsekye/Catalog/Model/Resource/Eav/Mysql4/Category.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Pektsekye_Catalog_Model_Resource_Eav_Mysql4_Category extends Mage_Catalog_Model_Resource_Eav_Mysql4_Category
4
+ {
5
+
6
+
7
+ /**Override core magento class
8
+ * Retrieve categories
9
+ *
10
+ * @param integer $parent
11
+ * @param integer $recursionLevel
12
+ * @param boolean|string $sorted
13
+ * @param boolean $asCollection
14
+ * @param boolean $toLoad
15
+ * @return Varien_Data_Tree_Node_Collection|Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
16
+ */
17
+ public function getCategories($parent, $recursionLevel = 0, $sorted=false, $asCollection=false, $toLoad=true)
18
+ {
19
+ $tree = Mage::getResourceModel('catalog/category_tree');
20
+ /** @var $tree Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree */
21
+
22
+ $helper = new Pektsekye_Ymm_Helper_Data;
23
+
24
+ if($ids = $helper->getProductIds()){
25
+
26
+ $pids = implode(',',$ids);
27
+ $resource = Mage::getSingleton('core/resource');
28
+ $read= $resource->getConnection('core_read');
29
+ $categoryTable = $resource->getTableName('catalog_category_entity');
30
+ $category_productTable = $resource->getTableName('catalog/category_product_index');
31
+ $rows = $read->fetchAll("SELECT entity_id FROM $categoryTable WHERE entity_id NOT IN (SELECT DISTINCT category_id FROM $category_productTable WHERE product_id in ($pids)) ");
32
+
33
+ if(count($rows)>0)
34
+ foreach ($rows as $r)
35
+ $ids [] = $r['entity_id'];
36
+
37
+ $tree->addInactiveCategoryIds($ids);
38
+
39
+ }
40
+
41
+ $nodes = $tree->loadNode($parent)
42
+ ->loadChildren($recursionLevel)
43
+ ->getChildren();
44
+
45
+ $tree->addCollectionData(null, $sorted, $parent, $toLoad, true);
46
+
47
+ if ($asCollection) {
48
+ return $tree->getCollection();
49
+ }
50
+ return $nodes;
51
+ }
52
+
53
+
54
+ }
app/code/local/Pektsekye/CatalogSearch/Model/Layer.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Pektsekye_CatalogSearch_Model_Layer extends Mage_CatalogSearch_Model_Layer
5
+ {
6
+
7
+ /**Override core magento method
8
+ * Get current layer product collection
9
+ *
10
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
11
+ */
12
+ public function getProductCollection()
13
+ {
14
+ if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
15
+ $collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
16
+ }
17
+ else {
18
+
19
+ $helper = new Pektsekye_Ymm_Helper_Data;
20
+ $ids = $helper->getProductIds();
21
+
22
+ if($ids && isset($_GET['Make'])){
23
+
24
+ $collection = Mage::getResourceModel('catalog/product_collection')
25
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
26
+ ->addIdFilter($ids)
27
+ ->setStore(Mage::app()->getStore())
28
+ ->addMinimalPrice()
29
+ ->addFinalPrice()
30
+ ->addTaxPercents()
31
+ ->addStoreFilter()
32
+ ->addUrlRewrite();
33
+
34
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
35
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
36
+
37
+ } else {
38
+
39
+ $collection = Mage::getResourceModel('catalogsearch/fulltext_collection');
40
+ $this->prepareProductCollection($collection);
41
+ }
42
+
43
+ $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
44
+ }
45
+
46
+ return $collection;
47
+ }
48
+
49
+ }
app/code/local/Pektsekye/Ymm/Block/Product/Result.php CHANGED
@@ -41,51 +41,9 @@ class Pektsekye_Ymm_Block_Product_Result extends Mage_Catalog_Block_Product_Abst
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())
@@ -96,6 +54,7 @@ class Pektsekye_Ymm_Block_Product_Result extends Mage_Catalog_Block_Product_Abst
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')
41
 
42
  protected function _getProductCollection()
43
  {
44
+ $helper = new Pektsekye_Ymm_Helper_Data;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ if($ids = $helper->getProductIds()){
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  $this->_productCollection = Mage::getResourceModel('catalog/product_collection')
49
  ->setStoreId($this->getStoreId())
54
  ->addUrlRewrite();
55
  Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_productCollection);
56
  Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($this->_productCollection);
57
+
58
  } else {
59
 
60
  $this->_productCollection = Mage::getResourceModel('catalog/product_collection')
app/code/local/Pektsekye/Ymm/Block/Ymm.php CHANGED
@@ -1,11 +1,10 @@
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();
10
  }
11
 
@@ -17,12 +16,5 @@ class Pektsekye_Ymm_Block_Ymm extends Mage_Core_Block_Template
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
  }
1
  <?php
2
  class Pektsekye_Ymm_Block_Ymm extends Mage_Core_Block_Template
3
  {
 
 
4
 
5
  public function _prepareLayout()
6
+ {
7
+ Mage::app()->cleanCache(array(Mage_Catalog_Model_Category::CACHE_TAG));
8
  return parent::_prepareLayout();
9
  }
10
 
16
  return $this->getData('ymm');
17
 
18
  }
 
 
 
 
 
 
 
19
 
20
  }
app/code/local/Pektsekye/Ymm/Helper/Data.php CHANGED
@@ -2,5 +2,60 @@
2
 
3
  class Pektsekye_Ymm_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  }
2
 
3
  class Pektsekye_Ymm_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
+
6
+ public function getProductIds()
7
+ {
8
+ $where = '';
9
+
10
+ if (isset($_GET['Make'])){
11
+ if ($_GET['Make'] != 'all')
12
+ $Make_selected_var = $_GET['Make'];
13
+ } elseif (isset($_COOKIE['Make_selected']) && $_COOKIE['Make_selected'] != 'all')
14
+ $Make_selected_var = $_COOKIE['Make_selected'];
15
+
16
+ if (isset($_GET['Model'])){
17
+ if ($_GET['Model'] != 'all')
18
+ $Model_selected_var = $_GET['Model'];
19
+ } elseif (isset($_COOKIE['Model_selected']) && $_COOKIE['Model_selected'] != 'all')
20
+ $Model_selected_var = $_COOKIE['Model_selected'];
21
+
22
+ if (isset($_GET['Year'])){
23
+ if ($_GET['Year'] != 0)
24
+ $Year_selected_var = $_GET['Year'];
25
+ } elseif (isset($_COOKIE['Year_selected']) && $_COOKIE['Year_selected'] != 0)
26
+ $Year_selected_var = $_COOKIE['Year_selected'];
27
+
28
+
29
+ if (isset($Make_selected_var))
30
+ $where .= " (make='".$Make_selected_var."' or make='') ";
31
+
32
+ if (isset($Model_selected_var))
33
+ $where .= ($where != '' ? ' and ' : '') . " (model='".$Model_selected_var."' or model='') ";
34
+
35
+ if (isset($Year_selected_var))
36
+ $where .= ($where != '' ? ' and ' : '') . " ((year_bof <= '".$Year_selected_var."' and year_eof >= '".$Year_selected_var."') or (year_bof=0 and year_eof=0)) ";
37
+
38
+
39
+ if ($where != ''){
40
+
41
+ $resource = Mage::getSingleton('core/resource');
42
+ $read= $resource->getConnection('core_read');
43
+ $productTable = $resource->getTableName('catalog_product_entity');
44
+ $ymmTable = $resource->getTableName('ymm');
45
+ $rows = $read->fetchAll("SELECT entity_id FROM $productTable LEFT JOIN $ymmTable USING (entity_id) WHERE $where");//ymm_id IS NULL OR
46
+
47
+ if(count($rows)>0){
48
+ foreach ($rows as $r)
49
+ $ids [] = $r['entity_id'];
50
+
51
+ return $ids;
52
+
53
+ } else return false;
54
+
55
+ }
56
+
57
+ return false;
58
+
59
+ }
60
 
61
  }
app/code/local/Pektsekye/Ymm/controllers/ProductController.php CHANGED
@@ -6,7 +6,7 @@ class Pektsekye_Ymm_ProductController extends Mage_Core_Controller_Front_Action
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();
6
  public function listAction()
7
  {
8
  if(!$this->getRequest()->getParam('Make') || $this->getRequest()->getParam('Make') == 'all') {
9
+ $this->getResponse()->setRedirect(Mage::getBaseUrl());
10
  return;
11
  }
12
  $this->loadLayout();
app/code/local/Pektsekye/Ymm/etc/config.xml CHANGED
@@ -82,7 +82,17 @@
82
  <rewrite>
83
  <category>Pektsekye_Catalog_Model_Category</category>
84
  </rewrite>
85
- </catalog>
 
 
 
 
 
 
 
 
 
 
86
  <ymm>
87
  <class>Pektsekye_Ymm_Model</class>
88
  <resourceModel>ymm_mysql4</resourceModel>
@@ -96,7 +106,8 @@
96
  </entities>
97
  </ymm_mysql4>
98
  </models>
99
- <resources>
 
100
  <ymm_setup>
101
  <setup>
102
  <module>Pektsekye_Ymm</module>
82
  <rewrite>
83
  <category>Pektsekye_Catalog_Model_Category</category>
84
  </rewrite>
85
+ </catalog>
86
+ <catalog_resource_eav_mysql4>
87
+ <rewrite>
88
+ <category>Pektsekye_Catalog_Model_Resource_Eav_Mysql4_Category</category>
89
+ </rewrite>
90
+ </catalog_resource_eav_mysql4>
91
+ <catalogsearch>
92
+ <rewrite>
93
+ <layer>Pektsekye_CatalogSearch_Model_Layer</layer>
94
+ </rewrite>
95
+ </catalogsearch>
96
  <ymm>
97
  <class>Pektsekye_Ymm_Model</class>
98
  <resourceModel>ymm_mysql4</resourceModel>
106
  </entities>
107
  </ymm_mysql4>
108
  </models>
109
+ <resources>
110
+
111
  <ymm_setup>
112
  <setup>
113
  <module>Pektsekye_Ymm</module>
app/design/frontend/default/default/layout/ymm.xml CHANGED
@@ -2,20 +2,23 @@
2
  <layout version="0.1.0">
3
  <catalog_category_view>
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>
@@ -23,11 +26,6 @@
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
 
2
  <layout version="0.1.0">
3
  <catalog_category_view>
4
  <reference name="right">
5
+ <block type="ymm/ymm" name="ymm" before="-" 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" before="-" 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
+ <reference name="right">
19
+ <block type="ymm/ymm" name="ymm" before="-" template="ymm/ymm.phtml"/>
20
+ <block type="catalogsearch/layer" name="catalogsearch.leftnav" after="ymm" template="catalog/layer/view.phtml"/>
21
+ </reference>
22
  <reference name="content">
23
  <block type="ymm/product_result" name="ymm_products" template="catalogsearch/result.phtml">
24
  <block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml"></block>
26
  <action method="setListModes"/>
27
  <action method="setListCollection"/>
28
  </block>
 
 
 
 
 
29
  </reference>
30
  </ymm_product_list>
31
 
app/design/frontend/default/default/template/ymm/ymm.phtml CHANGED
@@ -1,10 +1,10 @@
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');
@@ -122,20 +122,25 @@ function pop_year(){
122
  }
123
  </script>';
124
 
 
 
125
  if (isset($_GET['Make'])){
126
- if($_GET['Make'] != 'all')
 
127
  $Make_selected_var = $_GET['Make'];
128
  } elseif (isset($_COOKIE['Make_selected']) && $_COOKIE['Make_selected'] != 'all')
129
  $Make_selected_var = $_COOKIE['Make_selected'];
130
 
131
  if (isset($_GET['Model'])){
132
- if($_GET['Model'] != 'all')
 
133
  $Model_selected_var = $_GET['Model'];
134
  } elseif (isset($_COOKIE['Model_selected']) && $_COOKIE['Model_selected'] != 'all')
135
  $Model_selected_var = $_COOKIE['Model_selected'];
136
 
137
  if (isset($_GET['Year'])){
138
- if($_GET['Year'] != 0)
 
139
  $Year_selected_var = $_GET['Year'];
140
  } elseif (isset($_COOKIE['Year_selected']) && $_COOKIE['Year_selected'] != 0)
141
  $Year_selected_var = $_COOKIE['Year_selected'];
@@ -154,7 +159,7 @@ function pop_year(){
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,7 +184,7 @@ function pop_year(){
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>
1
  <?php
2
  /*
3
+ Written by pektsekye@gmail.com on Wednesday Jul 29 2009
4
+ version 4.0
5
  */
6
 
7
+ $module = $this->getRequest()->getModuleName();
8
  $resource = Mage::getSingleton('core/resource');
9
  $read= $resource->getConnection('core_read');
10
  $ymmTable = $resource->getTableName('ymm');
122
  }
123
  </script>';
124
 
125
+ $expire = time()+60*60*24*90;
126
+
127
  if (isset($_GET['Make'])){
128
+ setcookie("Make_selected", $_GET['Make'], $expire,'/');
129
+ if ($_GET['Make'] != 'all')
130
  $Make_selected_var = $_GET['Make'];
131
  } elseif (isset($_COOKIE['Make_selected']) && $_COOKIE['Make_selected'] != 'all')
132
  $Make_selected_var = $_COOKIE['Make_selected'];
133
 
134
  if (isset($_GET['Model'])){
135
+ setcookie("Model_selected", $_GET['Model'], $expire,'/');
136
+ if ($_GET['Model'] != 'all')
137
  $Model_selected_var = $_GET['Model'];
138
  } elseif (isset($_COOKIE['Model_selected']) && $_COOKIE['Model_selected'] != 'all')
139
  $Model_selected_var = $_COOKIE['Model_selected'];
140
 
141
  if (isset($_GET['Year'])){
142
+ setcookie("Year_selected", $_GET['Year'], $expire,'/');
143
+ if ($_GET['Year'] != 0)
144
  $Year_selected_var = $_GET['Year'];
145
  } elseif (isset($_COOKIE['Year_selected']) && $_COOKIE['Year_selected'] != 0)
146
  $Year_selected_var = $_COOKIE['Year_selected'];
159
  <div class="head">
160
  <h4><span><?php echo $this->__('Select Vehicle') ?></span></h4>
161
  </div>
162
+ <form name="make_model_year" action="<?php echo $module == 'cms' || $module == 'ymm' ? Mage::getUrl('ymm/product/list') : '' ;?>" method="get">
163
  <div class="content">
164
  <select name="Make" onChange="pop_model();" style="width: 100%">
165
  <?php
184
  </div>
185
  <div class="actions">
186
  <button class="form-button-alt right" type="submit"><span><?php echo $this->__('Go') ?></span></button>
187
+ <?php if(isset($Make_selected_var)): ?><a href="<?php echo $module == 'ymm' ? Mage::getBaseUrl() : '' ; ?>?Make=all&Model=all&Year=0">Clear Vehicle</a>&nbsp;&nbsp;&nbsp;&nbsp;<?php endif ?>
188
  </div>
189
  </form>
190
  </div>
app/etc/modules/Pektsekye_CatalogSearch.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <Pektsekye_CatalogSearch>
4
+ <active>true</active>
5
+ <codePool>local</codePool>
6
+ </Pektsekye_CatalogSearch>
7
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Year_Make_Model_Filter_Box</name>
4
- <version>3.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -12,21 +12,19 @@
12
  HOW TO USE:
13
  Go to your Magento admin panel -&gt; Ymm -&gt; Manage Items and add YMM items to all your products.
14
 
15
-
16
- NOTE: The products without model/make/year/ set are treated as for all models, all years, all makes.
17
- If you want to select BMW and see only BMW products all the other products should be set to another car.
18
- So you have to add YMM items to all your products to see the effect.
19
-
20
-
21
  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>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-27</date>
28
- <time>23:32: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="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="a1ce0bf50fe98f779809792e7918cd55"/></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.2.0.php" hash="f84214fc43f665c79b92dc7a092b364f"/><file name="mysql4-upgrade-0.2.0-0.3.0.php" hash="b3c26ec790ce60161c9317b01f111ea5"/></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>4.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>
12
  HOW TO USE:
13
  Go to your Magento admin panel -&gt; Ymm -&gt; Manage Items and add YMM items to all your products.
14
 
 
 
 
 
 
 
15
  NOTE: You should know your product id to be able to add an YMM item to it.
16
  You can find product id in the product description page url:
17
  http://yoursite.com/magento/catalog/product/view/id/119/s/coalesce-functioning-on-impatience-t-shirt/category/4/
18
  The number 119 is the product id in the url.</description>
19
+ <notes>Category navigation become filtered by ymm.
20
+
21
+ Layered navigation "SHOP BY" was added to the ymm/product/list page.
22
+
23
+ The products without ymm restrictions are not longer considered as universal and are not shown.</notes>
24
  <authors><author><name>Stanislav</name><user>auto-converted</user><email>pektsekye@gmail.com</email></author></authors>
25
+ <date>2009-07-30</date>
26
+ <time>16:31:29</time>
27
+ <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="a4d2c8b0669d5ccd486daf73735b6930"/></dir><dir name="template"><dir name="ymm"><file name="ymm.phtml" hash="e30ff6707bc4606db700629b9374f1aa"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Pektsekye_Catalog.xml" hash="89e3ec6056b4ba53d06df1370b347d42"/><file name="Pektsekye_CatalogSearch.xml" hash="c1152b8350ae4906db9736369c8e5edf"/><file name="Pektsekye_Ymm.xml" hash="990f4f561816481bd0c517f4fa131436"/></dir></target><target name="magelocal"><dir name="Pektsekye"><dir name="Catalog"><dir name="Model"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Category.php" hash="5d8d5cd3a20472b66306e161c06865a8"/></dir></dir></dir><file name="Category.php" hash="c1e9b8cfd53a2bf466cbb80d4a9bb227"/></dir></dir><dir name="CatalogSearch"><dir name="Model"><file name="Layer.php" hash="d9576052f726186cbf8d9d23e7ced335"/></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="f6239cbf910841bcff607e37db3f6a61"/></dir><file name="Ymm.php" hash="e3aaa2b05fb14bd52da70d27ae962604"/></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="84c655e892f90dd4b7442243390ebb4a"/></dir><dir name="etc"><file name="config.xml" hash="9a8fe4bc8baab099ee0c9f34acce2ebc"/></dir><dir name="Helper"><file name="Data.php" hash="181c50a246f314fc20991571c4980e5c"/></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.2.0.php" hash="f84214fc43f665c79b92dc7a092b364f"/><file name="mysql4-upgrade-0.2.0-0.3.0.php" hash="b3c26ec790ce60161c9317b01f111ea5"/></dir></dir></dir></dir></target></contents>
28
  <compatible/>
29
  <dependencies/>
30
  </package>