Expertrec_Recommendation - Version 1.0.13

Version Notes

Expertrec Recommendation plugin for magento sites.

Download this release

Release Info

Developer melchi
Extension Expertrec_Recommendation
Version 1.0.13
Comparing to
See all releases


Code changes from version 1.1.7 to 1.0.13

Files changed (19) hide show
  1. app/code/community/Expertrec/Recommendation/Block/Product/List/Toolbar.php +0 -46
  2. app/code/community/Expertrec/Recommendation/Helper/Autocompletehelper.php +128 -0
  3. app/code/community/Expertrec/Recommendation/Helper/Data.php +16 -14
  4. app/code/community/Expertrec/Recommendation/Helper/Search/Layout.php +447 -8
  5. app/code/community/Expertrec/Recommendation/Helper/Searchhelper.php +0 -224
  6. app/code/community/Expertrec/Recommendation/Model/Catalogsearch/Layer.php +0 -118
  7. app/code/community/Expertrec/Recommendation/Model/Observer.php +47 -2
  8. app/code/community/Expertrec/Recommendation/Model/Validate.php +8 -1
  9. app/code/community/Expertrec/Recommendation/controllers/ApiController.php +3 -2
  10. app/code/community/Expertrec/Recommendation/controllers/CatalogSearch/ResultController.php +10 -1
  11. app/code/community/Expertrec/Recommendation/etc/config.xml +16 -15
  12. app/code/community/Expertrec/Recommendation/sql/expertrec_setup/{mysql4-install-1.1.7.php → mysql4-install-1.0.13.php} +7 -7
  13. app/code/community/Expertrec/Recommendation/sql/expertrec_setup/{mysql4-upgrade-1.1.6-1.1.7.php → mysql4-upgrade-1.0.11-1.0.13.php} +6 -6
  14. app/design/frontend/base/default/layout/expertrec/recommendation.xml +33 -4
  15. app/design/frontend/base/default/template/expertrec/recommendation/tracker.phtml +1 -11
  16. app/design/frontend/base/default/template/expertrec/search/custom.phtml +2 -0
  17. app/design/frontend/base/default/template/expertrec/search/list.phtml +23 -0
  18. app/design/frontend/base/default/template/expertrec/search/view.phtml +16 -0
  19. package.xml +3 -3
app/code/community/Expertrec/Recommendation/Block/Product/List/Toolbar.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
-
3
- class Expertrec_Recommendation_Block_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar {
4
-
5
- /**
6
- * Set collection to pager, overriding this function
7
- *To ignore relevance
8
- *
9
- * @param Varien_Data_Collection $collection
10
- * @return Mage_Catalog_Block_Product_List_Toolbar
11
- */
12
- public function setCollection($collection)
13
- {
14
- $searchEnable = Mage::helper('expertrec_recommendation/searchhelper')->getSearchEnable();
15
- $pageIdentifier = Mage::app()->getFrontController()->getAction()->getFullActionName();
16
- $isSearchPage = $pageIdentifier === 'catalogsearch_result_index' ||
17
- $pageIdentifier === 'expertrec_result_index';
18
-
19
- //Don't use the toolbar when it is not the search page or when the search is not enabled
20
- if(!$isSearchPage || !(isset($searchEnable) && $searchEnable == "true"))
21
- {
22
- Mage::getSingleton('expertrec_recommendation/log')->log(" Default Toolbar call made ");
23
- return parent::setCollection($collection);
24
- }
25
-
26
- $this->_collection = $collection;
27
- $this->_collection->setCurPage($this->getCurrentPage());
28
-
29
- // we need to set pagination only if passed value integer and more that 0
30
- $limit = (int)$this->getLimit();
31
- if ($limit) {
32
- $this->_collection->setPageSize($limit);
33
- }
34
- if ($this->getCurrentOrder() != "relevance") {
35
-
36
- Mage::getSingleton('expertrec_recommendation/log')->log(" I have received order from Magento ".print_r($this->getCurrentOrder(),1),null);
37
- $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
38
-
39
- }
40
-
41
- return $this;
42
- }
43
-
44
- }
45
-
46
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Expertrec/Recommendation/Helper/Autocompletehelper.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Expertrec_Recommendation_Helper_Autocompletehelper extends Mage_Core_Helper_Abstract{
4
+
5
+ const SEARCH_LIST_API = 'search/api';
6
+ const SEARCH_FACET_LIST = 'search/facets_list';
7
+ const SEARCH_ITEMS_PER_PAGE = 'search/items_per_page';
8
+
9
+ protected $_facetList = array();
10
+ protected $_itemsPerPage = 20;
11
+
12
+ protected function getFormatUrl($url){
13
+ $splitedUrl = explode("?", $url);
14
+ $newUrl = preg_replace('/\/ajax/',"",$splitedUrl[0]);
15
+ if(count($splitedUrl) == 2){
16
+ $newUrl .= '?'.$splitedUrl[1];
17
+ }
18
+ return $newUrl;
19
+ }
20
+
21
+ protected function getSearchApi($confArray){
22
+ $searchApi = "";
23
+ try{
24
+ $itemsPerPage = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_ITEMS_PER_PAGE);
25
+ $storeSearchApi = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_LIST_API);
26
+ }catch(Exception $e){
27
+ Mage::getSingleton('expertrec_recommendation/log')->log('Autocompletehelper::getting searchApi exception: '.$e->getMessage());
28
+ }
29
+ if(!empty($itemsPerPage)){
30
+ $this->_itemsPerPage = $itemsPerPage;
31
+ }
32
+
33
+ if(!empty($storeSearchApi)){
34
+ $searchApi = $storeSearchApi;
35
+ $previous = $confArray["curPage"]-1;
36
+ $searchApi .= "?q=".urlencode($confArray["query"])."&page=".$previous."&size=".$this->_itemsPerPage;
37
+ $searchApi .= "&fq=order:".urlencode($confArray["order"]);
38
+ if(isset($confArray['filters'])){
39
+ $filters = $confArray['filters'];
40
+ foreach ($filters as $fkey => $fvalue) {
41
+ $searchApi .= "&fq=".$fkey.":".urlencode($fvalue);
42
+ }
43
+ }
44
+ }
45
+
46
+ return $searchApi;
47
+ }
48
+
49
+ public function getItemsPerPage(){
50
+ return (int)$this->_itemsPerPage;
51
+ }
52
+
53
+ public function prepareLayer($requestParams){
54
+ $confArray = array();
55
+ $filters = array();
56
+ $resultData = array();
57
+ try{
58
+ $confArray["url"] = $this->getFormatUrl(Mage::helper('core/url')->getCurrentUrl());
59
+ $confArray["query"] = htmlentities($requestParams['q'], ENT_QUOTES);
60
+
61
+ $confArray["curPage"] = isset($requestParams['p']) ? (int)$requestParams['p'] : 1;
62
+
63
+ $mode = isset($requestParams['mode']) ? $requestParams['mode'] : 'grid';
64
+ $confArray["mode"] = $mode == 'list' ? $mode : 'grid';
65
+ $confArray["order"] = isset($requestParams["order"]) ? $requestParams["order"] : 'relevance';
66
+
67
+ try{
68
+ $facetList = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_FACET_LIST);
69
+ $this->_facetList = !empty($facetList) ? explode(",", $facetList) : $this->_facetList;
70
+ }catch(Exception $ex){
71
+ Mage::getSingleton('expertrec_recommendation/log')->log('Autocompletehelper::getting facetlist from db exception: '.$ex->getMessage());
72
+ }
73
+
74
+ if(count($this->_facetList) > 0){
75
+ foreach($this->_facetList as $facet){
76
+ $filter = isset($requestParams[$facet]) ? $requestParams[$facet] : '';
77
+ if(!empty($filter)){
78
+ $filters[$facet] = str_replace(" ","+",$filter);
79
+ }
80
+ }
81
+ $confArray['filters'] = $filters;
82
+ }
83
+
84
+ //setup search url
85
+ $searchApi = $this->getSearchApi($confArray);
86
+ //Mage::getSingleton('expertrec_recommendation/log')->log('search url: '.$searchApi);
87
+
88
+ if(!empty($searchApi)){
89
+
90
+ //sending request
91
+ $resp = Mage::helper('expertrec_recommendation')->sendCurl($searchApi);
92
+ $response_json = json_decode($resp,true);
93
+
94
+ if(isset($response_json["res"]) && isset($response_json["res"]["count"])){
95
+ $confArray["count"] = (int)$response_json["res"]["count"];
96
+ }
97
+
98
+ //Initiate search layout
99
+ $layoutHelper = Mage::helper('expertrec_recommendation/search_layout')->init($confArray);
100
+
101
+ $searchListData = $response_json["results"];
102
+ $searchListHtml = $layoutHelper->prepareLayout($searchListData);
103
+
104
+ if(isset($confArray['filters'])){
105
+ $facetData = $response_json["facets"];
106
+ $facetNavHtml = $layoutHelper->prepareFilterLayout($facetData);
107
+ }else{
108
+ $facetNavHtml = '';
109
+ }
110
+
111
+ $resultData["listHtml"] = $searchListHtml;
112
+ $resultData["facetHtml"] = $facetNavHtml;
113
+
114
+
115
+ }
116
+
117
+ }catch (Exception $e) {
118
+ Mage::getSingleton('expertrec_recommendation/log')->log('Autocompletehelper::prepareLayer exception: '.$e->getMessage());
119
+ $resultData["listHtml"] = '<div style="color:red;><span style="font-weight:bold;">Error: </span>Oops. Something went wrong. Please try again later.</div>';
120
+ $resultData["facetHtml"] = '';
121
+ }
122
+
123
+ return $resultData;
124
+ }
125
+
126
+ }
127
+
128
+ ?>
app/code/community/Expertrec/Recommendation/Helper/Data.php CHANGED
@@ -196,6 +196,22 @@ class Expertrec_Recommendation_Helper_Data extends Mage_Core_Helper_Abstract {
196
  }
197
  return '';
198
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
 
200
  public function pushFeed($filepath){
201
  try{
@@ -235,20 +251,6 @@ class Expertrec_Recommendation_Helper_Data extends Mage_Core_Helper_Abstract {
235
  return true;
236
  }
237
 
238
- /*
239
- Fetching number of products per store, per website
240
- */
241
- public function getProductCount($wid,$sid)
242
- {
243
- $productcount = 0;
244
-
245
- $collection = Mage::getResourceModel('catalog/product_collection');
246
- $collection->addStoreFilter($sid);
247
- $collection->addWebsiteFilter($wid);
248
- // Retrieve product count in collection
249
- $productcount = $collection->getSize();
250
 
251
- return $productcount;
252
- }
253
  }
254
  ?>
196
  }
197
  return '';
198
  }
199
+
200
+ /*
201
+ Fetching number of products per store, per website
202
+ */
203
+ public function getProductCount($wid,$sid)
204
+ {
205
+ $productcount = 0;
206
+
207
+ $collection = Mage::getResourceModel('catalog/product_collection');
208
+ $collection->addStoreFilter($sid);
209
+ $collection->addWebsiteFilter($wid);
210
+ // Retrieve product count in collection
211
+ $productcount = $collection->getSize();
212
+
213
+ return $productcount;
214
+ }
215
 
216
  public function pushFeed($filepath){
217
  try{
251
  return true;
252
  }
253
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
 
 
255
  }
256
  ?>
app/code/community/Expertrec/Recommendation/Helper/Search/Layout.php CHANGED
@@ -4,10 +4,16 @@ class Expertrec_Recommendation_Helper_Search_Layout extends Mage_Core_Helper_Abs
4
 
5
  const SEARCH_SINGLE_SELECT_FILTERS = 'search/single_select_filters';
6
  const SEARCH_IS_AJAX = 'search/is_ajax';
7
-
 
 
 
 
 
8
  protected $_isAjax = false;
9
  protected $_confArray;
10
-
 
11
  protected $_singleSelectFilters = array();
12
 
13
  public function init($confArray){
@@ -15,11 +21,17 @@ class Expertrec_Recommendation_Helper_Search_Layout extends Mage_Core_Helper_Abs
15
  try{
16
  $singleFilters = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_SINGLE_SELECT_FILTERS);
17
  $isAjax = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_IS_AJAX);
18
-
 
 
19
 
20
  $this->_singleSelectFilters = isset($singleFilters) ? explode(',', $singleFilters) : $this->_singleSelectFilters;
21
  $this->_isAjax = isset($isAjax) && $isAjax == 'true' ? true : false;
22
-
 
 
 
 
23
  }catch (Exception $e) {
24
  Mage::getSingleton('expertrec_recommendation/log')->log('Search Layout Helper::init exception: '.$e->getMessage());
25
  }
@@ -36,7 +48,268 @@ class Expertrec_Recommendation_Helper_Search_Layout extends Mage_Core_Helper_Abs
36
  return $finalUrl;
37
  }
38
 
39
- /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  * @param string facet-header
41
  * @param string facet-label
42
  * @return string url
@@ -56,8 +329,30 @@ class Expertrec_Recommendation_Helper_Search_Layout extends Mage_Core_Helper_Abs
56
  }else{
57
  $url .= "&".str_replace(" ","_",$fhead).'='.$label;
58
  }
59
- return rtrim($url,'&');
60
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  /*
63
  * @param filterkey string
@@ -69,7 +364,151 @@ class Expertrec_Recommendation_Helper_Search_Layout extends Mage_Core_Helper_Abs
69
  $linkUrl = $baseUrl.'&'.str_replace(' ', '_', $fKey)."=".implode('%2C', $flist);
70
  return $linkUrl;
71
  }
72
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
 
75
  ?>
4
 
5
  const SEARCH_SINGLE_SELECT_FILTERS = 'search/single_select_filters';
6
  const SEARCH_IS_AJAX = 'search/is_ajax';
7
+ const SEARCH_DISPLAY_PAGES = 'search/display_pages';
8
+ const SEARCH_FETCH_PRICE = 'search/fetch_price';
9
+ const SEARCH_CONVERT_PRICE = 'search/convert_price';
10
+
11
+ protected $_itemsPerPage;
12
+ protected $_displayPages = 5;
13
  protected $_isAjax = false;
14
  protected $_confArray;
15
+ protected $_fetchPrice = false;
16
+ protected $_convertPrice = false;
17
  protected $_singleSelectFilters = array();
18
 
19
  public function init($confArray){
21
  try{
22
  $singleFilters = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_SINGLE_SELECT_FILTERS);
23
  $isAjax = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_IS_AJAX);
24
+ $displayPages = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_DISPLAY_PAGES);
25
+ $fetchPrice = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_FETCH_PRICE);
26
+ $convertPrice = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_CONVERT_PRICE);
27
 
28
  $this->_singleSelectFilters = isset($singleFilters) ? explode(',', $singleFilters) : $this->_singleSelectFilters;
29
  $this->_isAjax = isset($isAjax) && $isAjax == 'true' ? true : false;
30
+ $this->_fetchPrice = isset($fetchPrice) && $fetchPrice == 'true' ? true : false;
31
+ $this->_convertPrice = isset($convertPrice) && $convertPrice == 'true' ? true : false;
32
+ $this->_displayPages = !empty($displayPages) ? (int)$displayPages : $this->_displayPages;
33
+
34
+ $this->_itemsPerPage = Mage::helper('expertrec_recommendation/autocompletehelper')->getItemsPerPage();
35
  }catch (Exception $e) {
36
  Mage::getSingleton('expertrec_recommendation/log')->log('Search Layout Helper::init exception: '.$e->getMessage());
37
  }
48
  return $finalUrl;
49
  }
50
 
51
+ protected function getToolbarDiv(){
52
+
53
+ $result = '<div class="toolbar"><div class="sorter">';
54
+ $result .= '<p class="view-mode"><label>'.$this->__('View as').'</label>';
55
+
56
+ if($this->_confArray["mode"] == 'grid'){
57
+ $result .= '<strong title="Grid" class="grid">Grid</strong><a href="'.$this->removeRequestParam("mode").'&mode=list" title="List" class="list">List</a>';
58
+ }else{
59
+ $result .= '<a href= "'.$this->removeRequestParam("mode").'&mode=grid" title="Grid" class="grid">Grid</a><strong title="List" class="list">List</strong>';
60
+ }
61
+
62
+ $result .= '</p>';
63
+ $result .= '<div class="sort-by"><label>'.$this->__('Sort By').'</label>';
64
+ $result .= '<select onchange="setLocation(this.value)" title="'.$this->__('Sort By').'">';
65
+
66
+ //sort by
67
+ $orderArray = array("relevance"=>"Relevance", 'popularity'=>"Popularity", "price+asc"=>"Price - Low to High", "price+desc"=>"Price - High to Low");
68
+ foreach ($orderArray as $oKey => $oValue) {
69
+ if(urlencode($this->_confArray["order"]) == $oKey){
70
+ $result .= '<option value="'.$this->removeRequestParam("order").'&order='.$oKey.'" selected="selected">'.$this->__($oValue).'</option>';
71
+ }else{
72
+ $result .= '<option value="'.$this->removeRequestParam("order").'&order='.$oKey.'">'.$this->__($oValue).' </option>';
73
+ }
74
+ }
75
+
76
+ $result .= '</select>';
77
+ $result .= '</div></div>';//close sorter
78
+
79
+ $result .= '<div class="pager">';
80
+ $result .= '<div class="count-container">';
81
+
82
+ $totalNum = $this->_confArray["count"];
83
+ $totalPage = ceil($totalNum/$this->_itemsPerPage);
84
+ $previous = $this->_confArray["curPage"]-1;
85
+ $firstNum = $previous * $this->_itemsPerPage + 1;
86
+ $lastNum = min(($this->_confArray["curPage"] * $this->_itemsPerPage),$totalNum);
87
+
88
+ if($totalPage > 1){
89
+ $result .= '<p class="amount amount--has-pages">';
90
+ $result .= $this->__('Showing %s - %s of %s', $firstNum, $lastNum, $totalNum);
91
+ }else{
92
+ $result .= '<p class="amount amount--no-pages">';
93
+ $result .= '<strong>'.$this->__('Showing %s Item(s)', $totalNum) .'</strong>';
94
+ }
95
+ $result .= '</p>';
96
+ $result .= '</div>';//close count-container
97
+
98
+ $result .= '<div class="pages"><strong>Page:</strong>';
99
+ $result .= '<ol>';
100
+
101
+ //pager
102
+ if($previous >= 1){
103
+ $result .= '<li><a class="previous i-previous" href="'.$this->removeRequestParam("p").'&p='.(string)$previous.'" title="Previous">Prev</a></li>';
104
+ }
105
+
106
+ $pages = Mage::helper('expertrec_recommendation')
107
+ ->getPages($this->_confArray["curPage"],$totalNum,$this->_displayPages,$this->_itemsPerPage);
108
+ if(count($pages) > 1){
109
+ foreach ($pages as $page){
110
+ if($page == $this->_confArray["curPage"]){
111
+ $result .= '<li class="current">'.(string)($this->_confArray["curPage"]).'</li>';
112
+ }else{
113
+ $result .= '<li><a href="'.$this->removeRequestParam("p").'&p='.(string)$page.'">'.(string)$page.'</a></li>';
114
+ }
115
+ }
116
+ }
117
+
118
+ $next = $this->_confArray["curPage"]+1;
119
+ if($next <= $totalPage){
120
+ $result .= '<li><a class="next i-next" href="'.$this->removeRequestParam("p").'&p='.(string)$next.'" title="Next">Next</a></li>';
121
+ }
122
+
123
+ $result .= '</ol>';
124
+ $result .= '</div>';//close pages
125
+ $result .= '</div>';//close pager
126
+ $result .= '</div>';//close toolbar
127
+
128
+ return $result;
129
+ }
130
+
131
+ protected function getGridProductsDiv($data){
132
+ $confArray = $this->_confArray;
133
+
134
+ $result = '<ul class="products-grid products-grid--max-3-col">';
135
+
136
+ foreach ($data as $item) {
137
+ if(!isset($item["entity_id"]) && !isset($item["title"]) && !isset($item["url"]) && !isset($item["image_url"])){
138
+ continue;
139
+ }
140
+ $msrp = "";
141
+ $price = "";
142
+ $compareUrl = Mage::helper('expertrec_recommendation')->getProductCompareUrl($item['entity_id']);
143
+ $wishlistUrl = Mage::helper('expertrec_recommendation')->getWishlistUrl($item['entity_id']);
144
+ $cartUrl = Mage::helper('expertrec_recommendation')->getAddToCartUrl($item['entity_id']);
145
+
146
+ if(!empty($item["msrp"]) && $item["msrp"] != "None" && $item["msrp"] != "0"){
147
+ $msrp =$item['msrp'];
148
+ }
149
+ if(!empty($item["price"]) && $item["price"] != "None" && $item["price"] != "0"){
150
+ $price = $item['price'];
151
+ }
152
+
153
+ if($this->_convertPrice){
154
+ $price = Mage::helper('expertrec_recommendation')->getFormatCurrency($price,$item['entity_id'],$this->_fetchPrice);
155
+ $msrp = Mage::helper('expertrec_recommendation')->getFormatCurrency($msrp,$item['entity_id'],$this->_fetchPrice);
156
+ }else{
157
+ $price = Mage::helper('expertrec_recommendation')->getFormatPrice($price);
158
+ $msrp = Mage::helper('expertrec_recommendation')->getFormatPrice($msrp);
159
+ }
160
+
161
+ $result .= '<li class="item last">';
162
+ $result .= '<a href="'.$item["url"].'" title="'.$item['title'].'" class="product-image">';
163
+ $result .= '<img id="product-collection-image-'.$item['entity_id'].'" src="'.$item['image_url'].'" alt="'.$item['title'].'">';
164
+ $result .= '</a>';
165
+ $result .= '<div class="product-info" style="padding-bottom: 75px; min-height: 133px;"><h2 class="product-name">';
166
+ $result .= '<a href="'.$item["url"].'" title="'.$item['title'].'">'.$item['title'].'</a>';
167
+ $result .= '</h2>';
168
+ $result .= '<div class="price-box">';
169
+ if(!empty($msrp)){
170
+ $result .= '<p class="old-price">';
171
+ $result .= '<span class="price-label">Regular Price:</span>';
172
+ $result .= '<span class="price" id="old-price-'.$item['entity_id'].'">'.$msrp.'</span>';
173
+ $result .= '</p>';
174
+
175
+ $result .= '<p class="special-price">';
176
+ $result .= '<span class="price-label">Special Price</span>';
177
+ $result .= '<span class="price" id="product-price-'.$item['entity_id'].'">'.$price.'</span>';
178
+ $result .= '</p>';
179
+ }else{
180
+ $result .= '<span class="regular-price" id="product-price-'.$item['entity_id'].'"><span class="price">'.$price.'</span></span>';
181
+ }
182
+ $result .= '</div>';
183
+ $result .= '<div class="actions">';
184
+
185
+ if(!empty($cartUrl)){
186
+ $result .= '<button type="button" title="Add to Cart" class="button btn-cart" onclick="setLocation(\''.$cartUrl.'\')">';
187
+ $result .= '<span><span>Add to Cart</span></span>';
188
+ $result .= '</button>';
189
+ }
190
+ $result .= '<ul class="add-to-links">';
191
+
192
+ if(!empty($wishlistUrl)){
193
+ $result .= '<li><a href="'.$wishlistUrl.'" class="link-wishlist"> <i class="fa fa-heart" aria-hidden="true"></i> Wishlist</a></li>';
194
+ }
195
+ if(!empty($compareUrl)){
196
+ $result .= '<li><span class="separator">|</span>';
197
+ $result .= '<a href="'.$compareUrl.'" class="link-compare"> <i class="fa fa-balance-scale" aria-hidden="true"></i> Compare</a>';
198
+ $result .= '</li>';
199
+ }
200
+ $result .= '</ul>'; //add to links
201
+ $result .= '</div>'; // actions div
202
+ $result .= '</div>'; //product-info div
203
+ $result .= '</li>';
204
+
205
+ }
206
+ $result .= '</ul>';
207
+
208
+ return $result;
209
+ }
210
+
211
+ protected function getListProductsDiv($data){
212
+ $confArray = $this->_confArray;
213
+
214
+ $result = '<ol class="products-list" id="products-list">';
215
+ $index = 1;
216
+ $data_size = count($data);
217
+ foreach ($data as $item) {
218
+ if(!isset($item["entity_id"]) && !isset($item["title"]) && !isset($item["url"]) && !isset($item["image_url"])){
219
+ continue;
220
+ }
221
+ $msrp = "";
222
+ $price = "";
223
+ $compareUrl = Mage::helper('expertrec_recommendation')->getProductCompareUrl($item['entity_id']);
224
+ $wishlistUrl = Mage::helper('expertrec_recommendation')->getWishlistUrl($item['entity_id']);
225
+ $cartUrl = Mage::helper('expertrec_recommendation')->getAddToCartUrl($item['entity_id']);
226
+ $description = isset($item['desc']) ? $item['desc'] : (Mage::helper('expertrec_recommendation')->getProductDescription($item['entity_id']));
227
+
228
+ if(!empty($item["msrp"]) && $item["msrp"] != "None" && $item["msrp"] != "0"){
229
+ $msrp =$item['msrp'];
230
+ }
231
+ if(!empty($item["price"]) && $item["price"] != "None" && $item["price"] != "0"){
232
+ $price = $item['price'];
233
+ }
234
+
235
+ if($this->_convertPrice){
236
+ $price = Mage::helper('expertrec_recommendation')->getFormatCurrency($price,$item['entity_id'],$this->_fetchPrice);
237
+ $msrp = Mage::helper('expertrec_recommendation')->getFormatCurrency($msrp,$item['entity_id'],$this->_fetchPrice);
238
+ }else{
239
+ $price = Mage::helper('expertrec_recommendation')->getFormatPrice($price);
240
+ $msrp = Mage::helper('expertrec_recommendation')->getFormatPrice($msrp);
241
+ }
242
+
243
+ $odd_even = $data_size == $index ? 'last ' : '';
244
+
245
+ $odd_even .= ($index % 2) == 0 ? 'even' : 'odd';
246
+
247
+ $result .= '<li class="item '.$odd_even.'">';
248
+ $result .= '<a href="'.$item["url"].'" title="'.$item['title'].'" class="product-image">';
249
+ $result .= '<img id="product-collection-image-'.$item['entity_id'].'" src="'.$item['image_url'].'" alt="'.$item['title'].'">';
250
+ $result .= '</a>';
251
+ $result .= '<div class="product-shop">';
252
+ $result .= '<div class="f-fix">';
253
+ $result .= '<div class="product-primary">';
254
+ $result .= '<h2 class="product-name">';
255
+ $result .= '<a href="'.$item["url"].'" title="'.$item['title'].'">'.$item['title'].'</a>';
256
+ $result .= '</h2>';
257
+ $result .= '</div>'; //product-primary
258
+ $result .= '<div class="product-secondary">';
259
+ $result .= '<div class="price-box">';
260
+ if(!empty($msrp)){
261
+ $result .= '<p class="old-price">';
262
+ $result .= '<span class="price-label">Regular Price:</span>';
263
+ $result .= '<span class="price" id="old-price-'.$item['entity_id'].'">'.$msrp.'</span>';
264
+ $result .= '</p>';
265
+
266
+ $result .= '<p class="special-price">';
267
+ $result .= '<span class="price-label">Special Price</span>';
268
+ $result .= '<span class="price" id="product-price-'.$item['entity_id'].'">'.$price.'</span>';
269
+ $result .= '</p>';
270
+ }else{
271
+ $result .= '<span class="regular-price" id="product-price-'.$item['entity_id'].'"><span class="price">'.$price.'</span></span>';
272
+ }
273
+ $result .= '</div>'; //price-box
274
+ $result .= '</div>'; //product-secondary
275
+ $result .= '<div class="product-secondary">';
276
+ $result .= '<p class="action">';
277
+
278
+ if(!empty($cartUrl)){
279
+ $result .= '<button type="button" title="Add to Cart" class="button btn-cart" onclick="setLocation(\''.$cartUrl.'\')">';
280
+ $result .= '<span><span>Add to Cart</span></span>';
281
+ $result .= '</button>';
282
+ }
283
+
284
+ $result .= '</p>';
285
+ $result .= '<ul class="add-to-links">';
286
+
287
+ if(!empty($wishlistUrl)){
288
+ $result .= '<li><a href="'.$wishlistUrl.'" class="link-wishlist"> <i class="fa fa-heart" aria-hidden="true"></i> Wishlist</a></li>';
289
+ }
290
+ if(!empty($compareUrl)){
291
+ $result .= '<li><span class="separator">|</span>';
292
+ $result .= '<a href="'.$compareUrl.'" class="link-compare"> <i class="fa fa-balance-scale" aria-hidden="true"></i> Compare</a>';
293
+ $result .= '</li>';
294
+ }
295
+ $result .= '</ul>'; //add to links
296
+ $result .= '</div>'; //product-secondary
297
+ $result .= '<div class="desc std">'.$description;
298
+ $result .= '<a href="'.$item["url"].'" title="'.$item['title'].'" class="link-learn">Learn More</a>';
299
+ $result .= '</div>'; //desc
300
+ $result .= '</div>'; // f-fix
301
+ $result .= '</div>'; //product-shop
302
+ $result .= '</li>';
303
+
304
+ $index = $index + 1;
305
+ }
306
+
307
+ $result .= '</ol>';
308
+
309
+ return $result;
310
+ }
311
+
312
+ /*
313
  * @param string facet-header
314
  * @param string facet-label
315
  * @return string url
329
  }else{
330
  $url .= "&".str_replace(" ","_",$fhead).'='.$label;
331
  }
332
+ return $url;
333
+ }
334
+
335
+ /*
336
+ * @param string facet-header
337
+ * @param string facet-label
338
+ * @return string class
339
+ */
340
+ protected function getFacetClass($fhead,$facetLabel){
341
+ $confArray = $this->_confArray;
342
+
343
+ $class = $fhead == "category" ? "expertrec-filter-cat" : "expertrec-filter-attr";
344
+ $filter = isset($confArray["filters"][$fhead]) ? $confArray["filters"][$fhead] : '';
345
+ $label = str_replace(" ","+",$facetLabel);
346
+
347
+ if(!empty($filter)){
348
+ $att = preg_split('/(%2C|,)/', $filter);
349
+ if(in_array($label, $att)){
350
+ $class .= '-selected';
351
+ }
352
+ }
353
+
354
+ return $class;
355
+ }
356
 
357
  /*
358
  * @param filterkey string
364
  $linkUrl = $baseUrl.'&'.str_replace(' ', '_', $fKey)."=".implode('%2C', $flist);
365
  return $linkUrl;
366
  }
367
+
368
+ protected function getNavigationState(){
369
+ $result = '';
370
+ $confArray = $this->_confArray;
371
+
372
+ try{
373
+ if(!empty($confArray["filters"])){
374
+ $filters = $confArray["filters"];
375
+ $result .= '<div class="currently">';
376
+ $result .= '<p class="block-subtitle">'.$this->__('Currently Shopping by:').'</p>';
377
+ $result .= '<ol>';
378
+ foreach ($filters as $fKey => $fValue){
379
+ $result .= '<li>';
380
+ $result .= '<span class="label">'.$this->__(str_replace('_', ' ', $fKey)).':</span>';
381
+ $listSubFilter = preg_split('/(%2C|,)/', $fValue);
382
+
383
+ if(in_array($fKey, $this->_singleSelectFilters) || count($listSubFilter) == 1){
384
+ $result .= '<span class="value">'.str_replace('+', ' ', $listSubFilter[0]).'</span>';
385
+ $result .= '<a class="btn-remove" href="'.$this->removeRequestParam($fKey).'" title="'.$this->__('Remove This Item').'"><i class="fa fa-times" aria-hidden="true"></i></a>';
386
+ }else{
387
+ foreach ($listSubFilter as $sfKey) {
388
+ $remainSubFilterList = array_diff($listSubFilter, array($sfKey));
389
+
390
+ $result .= '<span class="multivalue">'.str_replace('+', ' ', $sfKey).'</span>';
391
+ $result .= '<a class="btn-remove-inline" href="'.$this->getClearLinkUrl($fKey,$remainSubFilterList).'" title="'.$this->__('Remove This Item').'">';
392
+ $result .= '<i class="fa fa-times-circle" aria-hidden="true"></i>';
393
+ $result .= '</a>';
394
+ $result .= '</span>';
395
+ }
396
+ }
397
+
398
+ $result .= '</li>';
399
+ }
400
+ $result .= '</ol>';
401
+ $result .= '</div>';
402
+ $result .= '<div class="actions">';
403
+ $result .= '<a href="'.strtok($confArray["url"], '?').'?q='.$confArray["query"].'">'.$this->__('Clear All').'</a>';
404
+ $result .= '</div>';
405
+ }
406
+ }catch(Exception $e){
407
+ Mage::getSingleton('expertrec_recommendation/log')->log( "Error in getting navigation state: ".$e->getMessage());
408
+ }
409
+
410
+ return $result;
411
+ }
412
+
413
+ /*
414
+ * @param Array facetlist
415
+ * @return html string
416
+ */
417
+ public function prepareFilterLayout($facets){
418
+ $result = '<div class="listing-filter">';
419
+ $result .= '<a href="javascript:;" onclick="erOpenFilter()">';
420
+ $result .= '<i class="fa fa-filter" aria-hidden="true"></i>&nbsp; Filter By </a>';
421
+ $result .= '</div>';
422
+ $result .= '<div id="er_Filteroption" class="overlay-filter">';
423
+ $result .= '<div class="block block-layered-nav expertrec-overflow-scroll-enabled">';
424
+ $result .= '<div class="block-title">';
425
+ $result .= '<strong><span>'.$this->__('Shop By').'</span></strong>';
426
+ $result .= '</div>';
427
+ $result .= '<div class="block-content toggle-content">';
428
+ $result .= '<div style="clear:both;"></div>';
429
+ $result .= '<p class="block-subtitle mobile-only"><i class="fa fa-filter" aria-hidden="true"></i> &nbsp; Filter By</p>';
430
+ $result .= '<dl id="narrow-by-list">';
431
+
432
+ foreach ($facets as $fKey => $fValue) {
433
+ if(count($fValue)){
434
+
435
+ $result .= '<dt>'.$fKey.'</dt>';
436
+ $result .= '<dd class="filter-search">';
437
+
438
+ $result .= '<ol>';
439
+ foreach ($fValue as $facetLabel => $facetCount) {
440
+ $result .= '<li class="'.$this->getFacetClass($fKey,$facetLabel).'">';
441
+ if($this->_isAjax){
442
+ $result .= '<a href="javascript:;">';
443
+ $result .= '<input class="ajaxUrl" type="hidden" value="'.$this->getFacetUrl($fKey,$facetLabel).'">';
444
+ }else{
445
+ $result .= '<a href="'.$this->getFacetUrl($fKey,$facetLabel).'">';
446
+ }
447
+ if(!in_array($fKey, $this->_singleSelectFilters)){
448
+ $result .= '<i class="fa fa-square-o" aria-hidden="true"></i>';
449
+ $result .= '<i class="fa fa-check-square-o" aria-hidden="true"></i>';
450
+ }
451
+ $result .= '&nbsp;'.ucwords(strip_tags($facetLabel));
452
+
453
+ $result .= ' <span class="count">('.$facetCount.')</span>';
454
+ $result .= '</a>';
455
+ $result .= '</li>';
456
+ }
457
+
458
+ $result .= '</ol>';
459
+ $result .= '</dd>';
460
+ }
461
+
462
+ }
463
+
464
+ $result .= '</dl>';
465
+ $result .= '<script type="text/javascript">decorateDataList(\'narrow-by-list\')</script>';
466
+ $result .= '<div class="mobile-only mobile-filter-closer" onclick="erCloseFilter()"> <i class="fa fa-times" aria-hidden="true"></i> &nbsp; Close Filter </div>';
467
+
468
+ $result .= '</div>'; // block-content close
469
+ $result .= '</div>'; // block-layered-nav close
470
+ $result .= '</div>'; // er_Filteroption close
471
+
472
+ return $result;
473
+ }
474
+
475
+
476
+ /*
477
+ * @param list of products
478
+ * @return html string
479
+ */
480
+
481
+ public function prepareLayout($data){
482
+ $confArray = $this->_confArray;
483
+
484
+ $finalResult = $this->getNavigationState();
485
+
486
+ if(!empty($confArray["count"])){
487
+ $toolbar = $this->getToolbarDiv();
488
+ $finalResult .= '<div class="category-products">';
489
+
490
+ $finalResult .= $toolbar;
491
+
492
+ if($confArray["mode"] == 'grid'){
493
+ $finalResult .= $this->getGridProductsDiv($data);
494
+ $finalResult .= '<script type="text/javascript">decorateGeneric($$("ul.products-grid"), ["odd","even","first","last"])</script>';
495
+ }else{
496
+ $finalResult .= $this->getListProductsDiv($data);
497
+ $finalResult .= '<script type="text/javascript">decorateList("products-list", "none-recursive")</script>';
498
+ }
499
+
500
+ $finalResult .= '<div class="toolbar-bottom">';
501
+ $finalResult .= $toolbar;
502
+ $finalResult .= '</div>';
503
+ $finalResult .= '</div>';
504
+ }else{
505
+ $noResult = $this->__('Your search returns no results.');
506
+ $finalResult .= '<p class="note-msg">'.$noResult.'</p>';
507
+ }
508
+
509
+ return $finalResult;
510
+
511
+ }
512
  }
513
 
514
  ?>
app/code/community/Expertrec/Recommendation/Helper/Searchhelper.php DELETED
@@ -1,224 +0,0 @@
1
- <?php
2
-
3
- class Expertrec_Recommendation_Helper_Searchhelper extends Mage_Core_Helper_Abstract{
4
-
5
- const SEARCH_LIST_API = 'search/api';
6
- const SEARCH_FACET_LIST = 'search/facets_list';
7
- const SEARCH_LIST_ENABLE = 'search/enable';
8
-
9
- protected $_facetList = array();
10
- protected $_resultIds = array();
11
-
12
- public function getResultIds(){
13
- return $this->_resultIds;
14
- }
15
-
16
- protected function getFormatUrl($url){
17
- $splitedUrl = explode("?", $url);
18
- $newUrl = preg_replace('/\/ajax/',"",$splitedUrl[0]);
19
- if(count($splitedUrl) == 2){
20
- $newUrl .= '?'.$splitedUrl[1];
21
- }
22
-
23
- return $newUrl;
24
- }
25
-
26
- public function getSearchEnable(){
27
- $searchEnable = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_LIST_ENABLE);
28
- return $searchEnable;
29
- }
30
-
31
- protected function getSearchApi($confArray){
32
-
33
- $searchApi = "";
34
-
35
- try{
36
- $storeSearchApi = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_LIST_API);
37
- }catch(Exception $e){
38
- Mage::getSingleton('expertrec_recommendation/log')->log('Searchhelper::getting searchApi exception: '.$e->getMessage());
39
- }
40
-
41
- if(!empty($storeSearchApi)){
42
- $searchApi = $storeSearchApi;
43
-
44
- // searching for cat and other facets
45
- // if(isset($confArray["facetPortion"]))
46
- // {
47
- // // $confArray["cat"] is to add cat and facets in searchapi
48
- // $searchApi .= "?q=".urlencode($confArray["query"]).$confArray["facetPortion"]."&page=0&src=magento";
49
- // }
50
-
51
- $searchApi .= "?q=".urlencode($confArray["query"])."&page=0&src=magento";
52
-
53
- $splitedUrl = explode("?",html_entity_decode($confArray["url"]));
54
-
55
- if(count($splitedUrl)==2)
56
- {
57
- $searchApi .= "&oq=".urlencode($splitedUrl[1]);
58
-
59
- }
60
- }
61
-
62
- Mage::getSingleton('expertrec_recommendation/log')->log("The search URL sent to Expertrec BE is : ".print_r($searchApi,1),null);
63
-
64
- //print_r($searchApi);
65
-
66
- return $searchApi;
67
- }
68
-
69
- public function getNonQueryUrlParameters($searchUrl)
70
- {
71
- //checking for cat and facets
72
- $facetPortion = "";
73
- $limitQuery = "";
74
-
75
- if(!strpos($searchUrl,"?q")){
76
-
77
- $parsedUrl = parse_url($searchUrl);
78
- $newQuery = array();
79
- $categoryArr = array();
80
- $query1 = "";
81
-
82
- $getCategory = explode("&",html_entity_decode($parsedUrl["query"]));
83
-
84
- // spliting queries
85
- foreach ($getCategory as $key => $value) {
86
- list($key1, $val) = explode('=', $value);
87
-
88
- //Excluding query term and cifr from categories
89
- if(!in_array($key1,array("q","cifr","limit","dir","order")))
90
- {
91
- $categoryArr[$key1] = $val;
92
- }
93
-
94
- }
95
-
96
- // getting all attributes
97
- $attributes = Mage::getModel('eav/entity_attribute_option')->getCollection()->setStoreFilter(0)->join('attribute','attribute.attribute_id=main_table.attribute_id', 'attribute_code');
98
-
99
- // changing id to name for cat and facets
100
- if(isset($categoryArr))
101
- {
102
- foreach ($categoryArr as $key => $value) {
103
-
104
- if($key == 'cat')
105
- {
106
- $id = $value;
107
- $cat = Mage::getModel('catalog/category')->load($id);
108
- $newQuery['category'] = $cat->getName();
109
- }
110
- else
111
- {
112
- //For all attributes not under the sortables, use attribute table
113
- if(!in_array($key,array("limit","order","dir")))
114
- {
115
- $attrMatched = false;
116
-
117
- foreach ($attributes as $attribute) {
118
- if ($attribute->getOptionId()==$value) {
119
- $newQuery[$key] = $attribute->getValue();
120
- $attrMatched = true;
121
- }
122
- }
123
-
124
- //If the attribute is not a category and it is not matched, just pass it to BE.
125
- if(!$attrMatched)
126
- {
127
- $newQuery[$key] = $value;
128
- }
129
- }
130
- else if($key == 'limit')
131
- {
132
- $limitQuery = "size=".urlencode($value);
133
- }
134
- else if($key == 'order')
135
- {
136
- $newQuery[$key] = $value." ".$categoryArr["dir"];
137
- }
138
- }
139
- }
140
-
141
- // changing to normal array
142
- foreach($newQuery as $k=>$v)
143
- {
144
- $finalQuery[] = $k.":".urlencode($v);
145
- }
146
-
147
- // implode with &fq as in url
148
- if(isset($finalQuery))
149
- {
150
- $query1 = "&fq=".implode("&fq=",$finalQuery);
151
- }
152
-
153
-
154
- if(strlen($limitQuery) > 0)
155
- {
156
- $query1 .= "&".$limitQuery;
157
- }
158
-
159
- $facetPortion = $query1;
160
-
161
- }
162
-
163
- }
164
-
165
- return $facetPortion;
166
- }
167
-
168
- public function prepareLayer($requestParams){
169
- $confArray = array();
170
- $filters = array();
171
-
172
- try{
173
- $confArray["url"] = $this->getFormatUrl(Mage::helper('core/url')->getCurrentUrl(),$confArray);
174
- $confArray["query"] = $requestParams['q'];
175
- //$confArray["facetPortion"] = $this->getNonQueryUrlParameters($confArray["url"]);
176
-
177
- //setup search url, if search URL is not empty
178
- $searchApi = $this->getSearchApi($confArray);
179
-
180
- if(!empty($searchApi)){
181
-
182
- //sending request
183
- $resp = Mage::helper('expertrec_recommendation')->sendCurl($searchApi);
184
- $response_json = json_decode($resp,true);
185
-
186
- // checking for url-resp
187
- if(isset($response_json["redirect"]) && isset($response_json["redirect_url"])){
188
- Mage::app()->getResponse()->setRedirect($response_json["redirect_url"]);
189
-
190
- }
191
- else
192
- {
193
- if(isset($response_json["res"]) && isset($response_json["res"]["count"])){
194
- $confArray["count"] = (int)$response_json["res"]["count"];
195
- Mage::getSingleton('expertrec_recommendation/log')->log("The json data is valid");
196
- }
197
-
198
- //Initiate search layout
199
- $layoutHelper = Mage::helper('expertrec_recommendation/search_layout')->init($confArray);
200
-
201
- $searchListData = $response_json["results"];
202
- $itemIds = array();
203
-
204
- if(isset($searchListData))
205
- {
206
- Mage::getSingleton('expertrec_recommendation/log')->log("Number of items returned by Expertrec BE ".count($searchListData));
207
-
208
- foreach ($searchListData as $item) {
209
- $itemIds[] = $item['entity_id'];
210
- }
211
- }
212
-
213
- $this->_resultIds = $itemIds;
214
- }
215
- }
216
-
217
- }catch (Exception $e) {
218
- Mage::getSingleton('expertrec_recommendation/log')->log('Searchhelper::prepareLayer exception: '.$e->getMessage());
219
-
220
- }
221
- }
222
-
223
- }
224
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Expertrec/Recommendation/Model/Catalogsearch/Layer.php DELETED
@@ -1,118 +0,0 @@
1
- <?php
2
-
3
- class Expertrec_Recommendation_Model_Catalogsearch_Layer extends Mage_CatalogSearch_Model_Layer{
4
-
5
- var $searchEnable;
6
- const SEARCH_LIST_ENABLE = 'search/enable';
7
- const SEARCH_CUSTOM_TEMPLATE = 'search/custom_template';
8
-
9
- private function setSearchEnable()
10
- {
11
-
12
- $this->searchEnable = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_LIST_ENABLE);
13
- }
14
-
15
- private function setExpertrecSearchData(){
16
- try
17
- {
18
- $app = Mage::app();
19
- $pageIdentifier = $app->getFrontController()->getAction()->getFullActionName();
20
-
21
- if ($pageIdentifier === 'catalogsearch_result_index' ||
22
- $pageIdentifier === 'expertrec_result_index')
23
- {
24
-
25
- $customTemplate = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_CUSTOM_TEMPLATE);
26
-
27
- $requestParams = $app->getRequest()->getParams();
28
-
29
- if( (isset($this->searchEnable) && $this->searchEnable == "true") ||
30
- (isset($requestParams["expertrec"]) && $requestParams["expertrec"] == "search"))
31
- {
32
- if(isset($customTemplate) && $customTemplate == "true")
33
- {
34
- $observer->getLayout()
35
- ->getUpdate()
36
- ->addHandle('expertrec_custom_autocomplete');
37
- }
38
- else
39
- {
40
- //This sets the result IDs
41
- Mage::getSingleton('expertrec_recommendation/log')->log(" Fetching search results from expertec ");
42
-
43
- Mage::helper('expertrec_recommendation/searchhelper')->prepareLayer($requestParams);
44
-
45
- }
46
- }
47
- }
48
- }
49
- catch (Exception $e)
50
- {
51
- Mage::getSingleton('expertrec_recommendation/log')->log('setExpertrecSearchData exception: '.$e->getMessage());
52
- }
53
-
54
- }
55
-
56
-
57
- /**
58
- * Prepare product collection
59
- *
60
- * @param Mage_Catalog_Model_Resource_Eav_Resource_Product_Collection $collection
61
- * @return Mage_Catalog_Model_Layer
62
- */
63
- public function prepareProductCollection($collection)
64
- {
65
- $this->setSearchEnable();
66
- //A log line to ensure that our search is called
67
- Mage::getSingleton('expertrec_recommendation/log')->log(" Calling expertrec search function with search: ".$this->searchEnable);
68
-
69
-
70
- if(isset($this->searchEnable) && $this->searchEnable == "true")
71
- {
72
- //Setting product IDs
73
- $this->setExpertrecSearchData();
74
- $product_ids = Mage::helper('expertrec_recommendation/searchhelper')->getResultIds();
75
- Mage::getSingleton('expertrec_recommendation/log')->log(" The expertrec result IDs are ".count($product_ids));
76
- //Mage::log($product_ids);
77
- $collection
78
- ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
79
- ->addFieldToFilter('entity_id',array('in'=>$product_ids))
80
- ->setStore(Mage::app()->getStore())
81
- ->addMinimalPrice()
82
- ->addFinalPrice()
83
- ->addTaxPercents()
84
- ->addStoreFilter()
85
- ->addUrlRewrite();
86
- //->getSelect()->order("find_in_set(e.entity_id, '" . implode(',', $product_ids)."') DESC");
87
- $requestParams = Mage::app()->getRequest()->getParams();
88
-
89
- $orderby = isset($requestParams["order"]) ? $requestParams["order"] : 'relevance';
90
- $dir = isset($requestParams["dir"]) ? $requestParams["dir"] : 'desc';
91
-
92
- if($orderby == "relevance") {
93
- if($dir == 'desc'){
94
- $collection->getSelect()->order("find_in_set(e.entity_id, '" . implode(',', $product_ids)."') ASC");
95
- }
96
- else {
97
- $collection->getSelect()->order("find_in_set(e.entity_id, '" . implode(',', $product_ids)."') DESC");
98
- }
99
- }
100
-
101
- Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
102
- Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
103
- }
104
- else
105
- {
106
- //Call parent function if search is not enabled
107
- Mage::getSingleton('expertrec_recommendation/log')->log(" Default search returned products ");
108
- return parent::prepareProductCollection($collection);
109
- }
110
-
111
-
112
- return $collection;
113
- }
114
-
115
-
116
- }
117
-
118
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Expertrec/Recommendation/Model/Observer.php CHANGED
@@ -313,6 +313,51 @@ class Expertrec_Recommendation_Model_Observer {
313
  Mage::getSingleton('expertrec_recommendation/log')->log("Error in getting feed endpoint: ".$e->getMessage());
314
  return '';
315
  }
316
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  }
318
- ?>
313
  Mage::getSingleton('expertrec_recommendation/log')->log("Error in getting feed endpoint: ".$e->getMessage());
314
  return '';
315
  }
316
+ }
317
+
318
+ /**
319
+ * Load Expertrec Search.
320
+ */
321
+ public function useExpertrecSearch(Varien_Event_Observer $observer){
322
+ try {
323
+ $app = Mage::app();
324
+ $pageIdentifier = $app->getFrontController()->getAction()->getFullActionName();
325
+
326
+ if ($pageIdentifier === 'catalogsearch_result_index' ||
327
+ $pageIdentifier === 'expertrec_result_index')
328
+ {
329
+ $searchEnable = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_LIST_ENABLE);
330
+ $customTemplate = Mage::helper('expertrec_recommendation')->getConfig(self::SEARCH_CUSTOM_TEMPLATE);
331
+
332
+ $requestParams = $app->getRequest()->getParams();
333
+ if( (isset($searchEnable) && $searchEnable == "true") ||
334
+ (isset($requestParams["expertrec"]) && $requestParams["expertrec"] == "search")
335
+ ){
336
+ if(isset($customTemplate) && $customTemplate == "true"){
337
+ $observer->getLayout()
338
+ ->getUpdate()
339
+ ->addHandle('expertrec_custom_autocomplete');
340
+ }else{
341
+ $resultData = Mage::helper('expertrec_recommendation/autocompletehelper')->prepareLayer($requestParams);
342
+
343
+ if(count($resultData) == 0 ){
344
+ throw new Exception("Either Search_api or facets_list has not configured.");
345
+ }
346
+
347
+ Mage::register('expertrec_search_navigation', $resultData["facetHtml"]);
348
+ Mage::register('expertrec_search_list', $resultData["listHtml"]);
349
+
350
+ $observer->getLayout()
351
+ ->getUpdate()
352
+ ->addHandle('expertrec_autocomplete');
353
+ }
354
+ }
355
+ }
356
+ }catch (Exception $e) {
357
+ Mage::getSingleton('expertrec_recommendation/log')->log('useExpertrecSearch exception: '.$e->getMessage());
358
+ }
359
+ return $this;
360
+ }
361
+
362
  }
363
+ ?>
app/code/community/Expertrec/Recommendation/Model/Validate.php CHANGED
@@ -25,7 +25,14 @@ class Expertrec_Recommendation_Model_Validate {
25
  }
26
 
27
  public function getPassword(){
28
- $storedPwd = base64_decode(Mage::getStoreConfig(self::CONFIG_SECRET));
 
 
 
 
 
 
 
29
  return $storedPwd;
30
  }
31
 
25
  }
26
 
27
  public function getPassword(){
28
+ $storedPwd = Mage::getSingleton('expertrec_recommendation/feed_feedconfig')->getSecret();
29
+
30
+ if(empty($storedPwd)){
31
+ $storedPwd = base64_decode(Mage::getStoreConfig(self::CONFIG_SECRET));
32
+ Mage::getSingleton('expertrec_recommendation/feed_feedconfig')
33
+ ->setSecret($storedPwd);
34
+ }
35
+
36
  return $storedPwd;
37
  }
38
 
app/code/community/Expertrec/Recommendation/controllers/ApiController.php CHANGED
@@ -25,7 +25,7 @@ class Expertrec_Recommendation_ApiController extends Mage_Core_Controller_Front_
25
  const MERCHANT_ID = 'expertrec/general/mid';
26
 
27
 
28
- const BUILD_NO = "1487594388";
29
  private $_password;
30
 
31
  //main function which loads the feed API
@@ -668,4 +668,5 @@ class Expertrec_Recommendation_ApiController extends Mage_Core_Controller_Front_
668
  return $result;
669
  }
670
 
671
- }
 
25
  const MERCHANT_ID = 'expertrec/general/mid';
26
 
27
 
28
+ const BUILD_NO = "1487595589";
29
  private $_password;
30
 
31
  //main function which loads the feed API
668
  return $result;
669
  }
670
 
671
+ }
672
+ ?>
app/code/community/Expertrec/Recommendation/controllers/CatalogSearch/ResultController.php CHANGED
@@ -4,10 +4,19 @@ require_once 'Mage/CatalogSearch/controllers/ResultController.php';
4
 
5
  class Expertrec_Recommendation_CatalogSearch_ResultController extends Mage_CatalogSearch_ResultController
6
  {
 
7
  public function indexAction(){
8
  $this->loadLayout();
9
  $this->renderLayout();
10
- }
 
 
 
 
 
 
 
 
11
  }
12
 
13
  ?>
4
 
5
  class Expertrec_Recommendation_CatalogSearch_ResultController extends Mage_CatalogSearch_ResultController
6
  {
7
+
8
  public function indexAction(){
9
  $this->loadLayout();
10
  $this->renderLayout();
11
+ }
12
+
13
+ public function ajaxAction(){
14
+ $requestParams = Mage::app()->getRequest()->getParams();
15
+ $resultData = Mage::helper('expertrec_recommendation/autocompletehelper')
16
+ ->prepareLayer($requestParams);
17
+ header('Content-Type: application/json');
18
+ echo json_encode($resultData);
19
+ }
20
  }
21
 
22
  ?>
app/code/community/Expertrec/Recommendation/etc/config.xml CHANGED
@@ -2,20 +2,15 @@
2
  <config>
3
  <modules>
4
  <Expertrec_Recommendation>
5
- <version>1.1.7</version>
6
  </Expertrec_Recommendation>
7
  </modules>
8
  <global>
9
  <models>
10
  <expertrec_recommendation>
11
  <class>Expertrec_Recommendation_Model</class>
12
- </expertrec_recommendation>
13
- <catalogsearch>
14
- <rewrite>
15
- <layer>Expertrec_Recommendation_Model_Catalogsearch_Layer</layer>
16
- </rewrite>
17
- </catalogsearch>
18
- </models>
19
  <helpers>
20
  <expertrec_recommendation>
21
  <class>Expertrec_Recommendation_Helper</class>
@@ -24,12 +19,7 @@
24
  <blocks>
25
  <expertrec_recommendation>
26
  <class>Expertrec_Recommendation_Block</class>
27
- </expertrec_recommendation>
28
- <catalog>
29
- <rewrite>
30
- <product_list_toolbar>Expertrec_Recommendation_Block_Product_List_Toolbar</product_list_toolbar>
31
- </rewrite>
32
- </catalog>
33
  </blocks>
34
  <resources>
35
  <expertrec_setup>
@@ -130,6 +120,17 @@
130
  <frontName>expertrec</frontName>
131
  </args>
132
  </expertrec>
133
- </routers>
 
 
 
 
 
 
 
 
 
 
 
134
  </frontend>
135
  </config>
2
  <config>
3
  <modules>
4
  <Expertrec_Recommendation>
5
+ <version>1.0.13</version>
6
  </Expertrec_Recommendation>
7
  </modules>
8
  <global>
9
  <models>
10
  <expertrec_recommendation>
11
  <class>Expertrec_Recommendation_Model</class>
12
+ </expertrec_recommendation>
13
+ </models>
 
 
 
 
 
14
  <helpers>
15
  <expertrec_recommendation>
16
  <class>Expertrec_Recommendation_Helper</class>
19
  <blocks>
20
  <expertrec_recommendation>
21
  <class>Expertrec_Recommendation_Block</class>
22
+ </expertrec_recommendation>
 
 
 
 
 
23
  </blocks>
24
  <resources>
25
  <expertrec_setup>
120
  <frontName>expertrec</frontName>
121
  </args>
122
  </expertrec>
123
+ </routers>
124
+ <events>
125
+ <controller_action_layout_load_before>
126
+ <observers>
127
+ <expertrec_search>
128
+ <type>singleton</type>
129
+ <class>expertrec_recommendation/observer</class>
130
+ <method>useExpertrecSearch</method>
131
+ </expertrec_search>
132
+ </observers>
133
+ </controller_action_layout_load_before>
134
+ </events>
135
  </frontend>
136
  </config>
app/code/community/Expertrec/Recommendation/sql/expertrec_setup/{mysql4-install-1.1.7.php → mysql4-install-1.0.13.php} RENAMED
@@ -1,24 +1,24 @@
1
  <?php
2
 
3
  //echo 'Installing extension: '.get_class($this)."\n <br /> \n";
4
- Mage::log("Installing magento : 1.1.6 ");
5
 
6
 
7
  $installer = $this;
8
 
9
- $host = $_SERVER['HTTP_HOST'];
10
- $uri = $_SERVER['REQUEST_URI'];
11
- //$uuu = $_SERVER['PHP_SELF'];
12
 
13
  $installer->startSetup();
14
 
15
  $result =array();
16
 
17
- //install/upgrade status
18
  $result['status'] = "Installed";
 
 
19
  //hostname
20
  $result['site_host'] = $host;
21
- $result['site_subdomain'] = $uri;
22
  //selecting for site_details
23
  $site_data = $installer->getConnection()->fetchAll("select * from {$this->getTable('core_config_data')} where `path` like '%trans_email%'");
24
  //site name and email
@@ -66,4 +66,4 @@ $installer->run("
66
 
67
  $installer->endSetup();
68
 
69
- ?>
1
  <?php
2
 
3
  //echo 'Installing extension: '.get_class($this)."\n <br /> \n";
4
+ Mage::log("Installing magento : 1.0.12 ");
5
 
6
 
7
  $installer = $this;
8
 
9
+ $host = $_SERVER['HTTP_HOST'];
10
+ $uri = $_SERVER['REQUEST_URI'];
 
11
 
12
  $installer->startSetup();
13
 
14
  $result =array();
15
 
16
+ //Status
17
  $result['status'] = "Installed";
18
+ //Subdomain
19
+ $result['site_subdomain'] = $uri;
20
  //hostname
21
  $result['site_host'] = $host;
 
22
  //selecting for site_details
23
  $site_data = $installer->getConnection()->fetchAll("select * from {$this->getTable('core_config_data')} where `path` like '%trans_email%'");
24
  //site name and email
66
 
67
  $installer->endSetup();
68
 
69
+ ?>
app/code/community/Expertrec/Recommendation/sql/expertrec_setup/{mysql4-upgrade-1.1.6-1.1.7.php → mysql4-upgrade-1.0.11-1.0.13.php} RENAMED
@@ -1,22 +1,22 @@
1
  <?php
2
 
3
  //echo 'Running The Upgrade from 1.1.5 to 1.1.6 : '.get_class($this)."\n <br /> \n";
4
- Mage::log("Running The Upgrade from 1.1.5 to 1.1.6 : ".get_class($this));
5
 
6
  $installer = $this;
7
 
8
  $host = $_SERVER['HTTP_HOST'];
9
- $uri = $_SERVER['REQUEST_URI'];
10
- //$uuu = $_SERVER['PHP_SELF'];
11
 
12
  $installer->startSetup();
13
 
14
  $result =array();
15
-
16
- //install/upgrade status
17
  $result['status'] = "Upgraded";
18
  //hostname
19
  $result['site_host'] = $host;
 
20
  $result['site_subdomain'] = $uri;
21
  //selecting for site_details
22
  $site_data = $installer->getConnection()->fetchAll("select * from {$this->getTable('core_config_data')} where `path` like '%trans_email%'");
@@ -65,4 +65,4 @@ $installer->run("
65
 
66
  $installer->endSetup();
67
 
68
- ?>
1
  <?php
2
 
3
  //echo 'Running The Upgrade from 1.1.5 to 1.1.6 : '.get_class($this)."\n <br /> \n";
4
+ Mage::log("Running The Upgrade from 1.0.11 to 1.0.12 : ".get_class($this));
5
 
6
  $installer = $this;
7
 
8
  $host = $_SERVER['HTTP_HOST'];
9
+ $uri = $_SERVER['REQUEST_URI'];
10
+
11
 
12
  $installer->startSetup();
13
 
14
  $result =array();
15
+ //status
 
16
  $result['status'] = "Upgraded";
17
  //hostname
18
  $result['site_host'] = $host;
19
+ //Subdomain
20
  $result['site_subdomain'] = $uri;
21
  //selecting for site_details
22
  $site_data = $installer->getConnection()->fetchAll("select * from {$this->getTable('core_config_data')} where `path` like '%trans_email%'");
65
 
66
  $installer->endSetup();
67
 
68
+ ?>
app/design/frontend/base/default/layout/expertrec/recommendation.xml CHANGED
@@ -5,16 +5,45 @@
5
  <reference name="head">
6
  <block name="expertrec.rec.tracking" template="expertrec/recommendation/tracker.phtml" after="-" type="core/template"/>
7
  </reference>
8
- </default>
9
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  <expertrec_custom_autocomplete>
11
  <remove name="right"/>
12
  <remove name="left"/>
13
  <reference name="root">
14
  <action method="setTemplate"><template>page/1column.phtml</template></action>
15
- </reference>
 
 
 
 
16
  </expertrec_custom_autocomplete>
17
- <!--route the infoAction function in ApiController to info.phtml, which can access Api.php block functions-->
 
 
 
 
18
  <expertrec_recommendation_api_info>
19
  <reference name="root">
20
  <action method="setTemplate"><template>page/1column.phtml</template></action>
5
  <reference name="head">
6
  <block name="expertrec.rec.tracking" template="expertrec/recommendation/tracker.phtml" after="-" type="core/template"/>
7
  </reference>
8
+ </default>
9
+ <!-- PRODUCT PAGE -->
10
+ <catalog_product_view>
11
+ <reference name="before_body_end">
12
+ <block name="expertrec.rec.analytics.producttracking" template="expertrec/recommendation/tracking/product.phtml" after="-" type="core/template"/>
13
+ </reference>
14
+ </catalog_product_view>
15
+
16
+ <!-- Search -->
17
+ <expertrec_autocomplete>
18
+ <reference name="root">
19
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
20
+ </reference>
21
+ <reference name="catalogsearch.leftnav">
22
+ <action method="setTemplate">
23
+ <value>expertrec/search/view.phtml</value>
24
+ </action>
25
+ </reference>
26
+ <remove name="search.result"/>
27
+ <reference name="content">
28
+ <block type="core/template" name="search_result_list" template="expertrec/search/list.phtml"/>
29
+ </reference>
30
+ </expertrec_autocomplete>
31
  <expertrec_custom_autocomplete>
32
  <remove name="right"/>
33
  <remove name="left"/>
34
  <reference name="root">
35
  <action method="setTemplate"><template>page/1column.phtml</template></action>
36
+ </reference>
37
+ <remove name="search.result"/>
38
+ <reference name="content">
39
+ <block type="core/template" name="expertrec_search_result" template="expertrec/search/custom.phtml"/>
40
+ </reference>
41
  </expertrec_custom_autocomplete>
42
+ <expertrec_result_index>
43
+ <reference name="left">
44
+ <block type="core/template" name="expertrec.leftnav" after="currency" template="expertrec/search/view.phtml"/>
45
+ </reference>
46
+ </expertrec_result_index>
47
  <expertrec_recommendation_api_info>
48
  <reference name="root">
49
  <action method="setTemplate"><template>page/1column.phtml</template></action>
app/design/frontend/base/default/template/expertrec/recommendation/tracker.phtml CHANGED
@@ -4,7 +4,7 @@
4
  <?php $category = Mage::registry("current_category");?>
5
  <?php
6
  $formKey = '';
7
- $currencyRates = array();
8
  try{
9
  $formkey_html = $this->getBlockHtml('formkey');
10
  $pattern = '/.*form_key.*value=\"([^\"]+)\"/s';
@@ -13,13 +13,6 @@ try{
13
  $formKey = $match[1];
14
  }
15
  }
16
-
17
- //currency rate
18
- $baseCurrencyCode = Mage::app()->getBaseCurrencyCode();
19
- $allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
20
- $currencyRates = Mage::getModel('directory/currency')
21
- ->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
22
-
23
  } catch (Exception $e){
24
  Mage::logException($e);
25
  }
@@ -33,9 +26,6 @@ if(typeof expertSiteConf == 'undefined' || expertSiteConf == null) {
33
  <?php if (isset($category)) { ?>
34
  ,category:"<?php echo $category->getName(); ?>"
35
  <?php } ?>
36
- <?php if (!empty($currencyRates)) { ?>
37
- ,rates: <?php echo json_encode($currencyRates); ?>
38
- <?php } ?>
39
  };
40
  }
41
 
4
  <?php $category = Mage::registry("current_category");?>
5
  <?php
6
  $formKey = '';
7
+
8
  try{
9
  $formkey_html = $this->getBlockHtml('formkey');
10
  $pattern = '/.*form_key.*value=\"([^\"]+)\"/s';
13
  $formKey = $match[1];
14
  }
15
  }
 
 
 
 
 
 
 
16
  } catch (Exception $e){
17
  Mage::logException($e);
18
  }
26
  <?php if (isset($category)) { ?>
27
  ,category:"<?php echo $category->getName(); ?>"
28
  <?php } ?>
 
 
 
29
  };
30
  }
31
 
app/design/frontend/base/default/template/expertrec/search/custom.phtml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
2
+ <div id="expertrec_search_result_list"></div>
app/design/frontend/base/default/template/expertrec/search/list.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="page-title">
2
+ <h1>
3
+ <?php echo ($this->getHeaderText() || $this->getHeaderText() === false) ? $this->getHeaderText() : $this->__("Search results for '%s'", $this->helper('catalogsearch')->getEscapedQueryText()) ?>
4
+ </h1>
5
+ </div>
6
+
7
+ <div id="expertrec_search_result_list">
8
+ <?php
9
+ echo Mage::registry('expertrec_search_list');
10
+ ?>
11
+ </div>
12
+
13
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
14
+ <script type="text/javascript">
15
+ var erjq=jQuery.noConflict(true);function erOpenFilter(){erjq("#er_Filteroption").css("width","100%");erjq("body").css("overflow","hidden")}function erCloseFilter(){erjq("#er_Filteroption").css("width","0px");erjq("body").css("overflow","visible")}function erShowProduct(a){var c=a,d=c.listHtml||"",b=c.facetHtml||"";d&&erjq("#expertrec_search_result_list").html(d);b&&erjq("#expertrec_search_result_navigation").html(b);if(typeof erDisplayPriceFilter=="function"){erDisplayPriceFilter()}erjq("#expertrec-overlay").css("display","none");erAttachFilterEvent();erToggleNavigation()}function erMakeDealsCall(a){erjq.ajax({url:a,type:"GET",dataType:"json",success:erShowProduct,error:function(){erjq("#expertrec-overlay").css("display","none")}})}function erToggleNavigation(){erjq(".toggle-content").each(function(){var a=erjq(this);var c=a.hasClass("tabs");var g=a.hasClass("accordion");var e=a.hasClass("open");var j=a.children("dl:first");var d=j.children("dt");var l=j.children("dd");var b=new Array(d,l);if(c){var k=erjq('<ul class="toggle-tabs"></ul>');d.each(function(){var n=erjq(this);var i=erjq("<li></li>");i.html(n.html());k.append(i)});k.insertBefore(j);var m=k.children();b.push(m)}var f;for(f=0;f<b.length;f++){b[f].filter(":last").addClass("last")}function h(o,q){var n=q.index(o);var p;for(p=0;p<b.length;p++){b[p].removeClass("current");b[p].eq(n).addClass("current")}}d.on("click",function(i){if(erjq(this).hasClass("current")&&a.hasClass("accordion-open")){a.removeClass("accordion-open")}else{a.addClass("accordion-open")}h(erjq(this),d)});if(c){m.on("click",function(i){h(erjq(this),m)});m.eq(0).trigger("click")}if(e){d.eq(0).trigger("click")}})}erjq(document).ready(function(){var a=function(){if(erjq(window).width()<=771){erjq("#er_Filteroption").css("width","0px");erjq("#expertrec_search_result_navigation").prependTo(erjq("#expertrec_search_result_list"))}else{erjq("#er_Filteroption").css("width","100%");erjq(".col-left").first().prepend(erjq("#expertrec_search_result_navigation"))}};a();erjq(window).resize(function(){a()})});
16
+
17
+ <?php if(Mage::helper('expertrec_recommendation/search_layout')->getIsAjax()){ ?>
18
+
19
+ function erAttachFilterEvent(){erjq("#er_Filteroption .filter-search a").each(function(){var b=this,c="",e="",d=[],a=erjq(window).width();erjq(this).click(function(){if(a<771){erCloseFilter()}erjq("#expertrec-overlay").css("display","block");c=erjq(b).find("input").val();if(c){d=c.split("?");if(d.length==2){e=/\/$/.test(d[0])?d[0]+"ajax":d[0]+"/ajax";e+="?"+d[1];e=typeof erGetFilterPrice=="function"?erGetFilterPrice(e):e;erMakeDealsCall(e)}else{window.location.href=c}}})})}erjq(document).ready(function(){erAttachFilterEvent()});
20
+
21
+ <?php }?>
22
+
23
+ </script>
app/design/frontend/base/default/template/expertrec/search/view.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
2
+ <style type="text/css">
3
+ #expertrec_search_result_list .note-msg {color:red;font-size:1.2em;}#er_Filteroption .no-display {display: block !important;}#expertrec_search_result_list .products-grid>li{position:relative;margin-bottom:20px;text-align:center}#expertrec_search_result_list .products-grid>li{float:left;width:47.72727%;}#expertrec_search_result_list .products-grid>li:nth-child(2n+1){clear:left}#expertrec_search_result_list .products-grid .product-image{margin-bottom:5px;text-align:center;margin-left:auto;margin-right:auto;display:block;width:100%}#expertrec_search_result_list .products-grid .product-info{min-height:inherit!important;padding-bottom:10px!important;position:relative}#expertrec_search_result_list .products-grid .product-name,#expertrec_search_result_list .products-list .product-name{text-transform:uppercase;margin-bottom:5px;font-size:14px;font-weight:normal;line-height:1.4;font-style:normal}#expertrec_search_result_list .products-grid .actions{position:relative;bottom:0;padding-top:10px;min-height:85px;width:100%;font-size:14px}#expertrec_search_result_list .add-to-links{margin:7px 0}#expertrec_search_result_list .add-to-links a{display:inline-block;padding:0 3px 3px}#expertrec_search_result_list .products-grid li.item button.btn-cart{width:100%}#expertrec_search_result_list .currently ol li .value,#expertrec_search_result_list .currently ol li .multivalue{padding:0 10px}#expertrec_search_result_list .currently ol li .label{text-transform:capitalize;font-weight:bold}#expertrec_search_result_list .currently ol li{margin-bottom:5px}#expertrec_search_result_list .currently ol li::after{content:'';display:table;clear:both}#expertrec_search_result_navigation .mobile-only,#expertrec_search_result_navigation p.mobile-only{display:none}#expertrec_search_result_navigation .listing-filter{display:none}#er_Filteroption .toggle-content .block-subtitle{float:none;text-align:center}#expertrec_search_result_navigation .block-layered-nav.expertrec-overflow-scroll-enabled .block-content>dl>dd{background:#fff}#expertrec_search_result_navigation .block-layered-nav.expertrec-overflow-scroll-enabled dl dd ol>li>a .count{color:#949494;font-size:12px}#expertrec_search_result_navigation .block-layered-nav.expertrec-overflow-scroll-enabled dl dd ol>li>a.expertrec-attr-selected{color:#5a647c}#expertrec_search_result_navigation .block-layered-nav.expertrec-overflow-scroll-enabled dl dd ol>li>a.expertrec-attr-selected:hover{text-decoration:none}#expertrec_search_result_navigation .block-layered-nav.expertrec-overflow-scroll-enabled .currently ol{padding-left:0;margin-bottom:10px}#expertrec_search_result_navigation #narrow-by-list{border-radius:3px;box-shadow:0 0 4px rgba(0,0,0,.2)}#expertrec_search_result_navigation .expertrec-overflow-scroll-enabled .block-content dl dd>ol{max-height:250px;overflow-y:auto}.expertrec-filter-attr .fa-square-o,.expertrec-filter-cat .fa-square-o{display:inline-block}.expertrec-filter-attr .fa-check-square-o,.expertrec-filter-cat .fa-check-square-o{display:none}.expertrec-filter-attr-selected .fa-square-o,.expertrec-filter-cat-selected .fa-square-o{display:none}.expertrec-filter-attr-selected .fa-check-square-o,.expertrec-filter-cat-selected .fa-check-square-o{display:inline-block}#expertrec-overlay{display:none;background-color:#000;height:100%;left:0;opacity:.7;filter:alpha(opacity= 50);position:fixed;top:0;width:100%;z-index:999}#expertrec-overlay img{top:45%;left:48%;display:block;position:fixed;z-index:900}#expertrec_search_result_list .products-grid .actions{position:relative;bottom:0}#expertrec_search_result_list .products-grid .product-info{min-height:inherit!important;padding-bottom:10px!important}#expertrec_search_result_list .products-grid .product-image img{width:100%;height:auto}@media only screen and (max-width:770px){#er_Filteroption .block-title{display:none}#expertrec_search_result_navigation .expertrec-overflow-scroll-enabled .block-content dl dd>ol{max-height:150px}#expertrec_search_result_navigation .mobile-only,#expertrec_search_result_navigation p.mobile-only{display:block}#expertrec_search_result_navigation .mobile-filter-closer{text-align:center;padding:10px 5px;background:#f04f25;color:#fff;width:99%;margin:10px auto;max-width:300px;clear:both;cursor:pointer}#expertrec_search_result_navigation .listing-filter{display:block;font-size:12px}#expertrec_search_result_navigation .listing-filter{display:block;border:1px solid #e7e7e7;text-align:center;margin-bottom:15px;width:80%;margin:0 auto 15px;padding:10px 5px;border-radius:5px}#expertrec_search_result_navigation .overlay-filter{height:100%;width:0;position:fixed;z-index:2000;top:0;left:0;background-color:#f3f3f3;overflow-x:hidden;transition:.5s}}@media only screen and (max-width:600px){#expertrec_search_result_list .products-list .desc{display:none}}@media only screen and (min-width:480px){#expertrec_search_result_list .products-grid>li:nth-child(odd){clear:none}#expertrec_search_result_list .products-grid>li:nth-child(even){margin-right:3.7037%}#expertrec_search_result_list .products-grid>li{width:30.8642%;margin-right:3.7037%}#expertrec_search_result_list .products-grid>li:nth-child(3n+1){clear:left}#expertrec_search_result_list .products-grid>li:nth-child(3n){margin-right:0}}
4
+ </style>
5
+
6
+
7
+ <div id="expertrec_search_result_navigation">
8
+ <?php
9
+ $expertrec_search_navigation = Mage::registry('expertrec_search_navigation');
10
+ echo $expertrec_search_navigation;
11
+ ?>
12
+ </div>
13
+
14
+ <div id="expertrec-overlay">
15
+ <img src="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif">
16
+ </div>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Expertrec_Recommendation</name>
4
- <version>1.1.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
@@ -11,8 +11,8 @@
11
  <notes>Expertrec Recommendation plugin for magento sites.</notes>
12
  <authors><author><name>melchi</name><user>melchi</user><email>magento@cloudinfra.in</email></author><author><name>magento</name><user>magento</user><email>magento-team@cloudinfra.in</email></author></authors>
13
  <date>2017-02-20</date>
14
- <time>12:42:40</time>
15
- <contents><target name="magecommunity"><dir name="Expertrec"><dir name="Recommendation"><dir name="Block"><file name="Api.php" hash="ce87654622f030c6e8b5a992713da5d8"/><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="bd05a0d7473829c47662e6b763907ea6"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="364ab05880bed5e6a02f20bcca1b993c"/><file name="Filehelper.php" hash="5ac956e12548398dc159a16eb1a03e8b"/><dir name="Search"><file name="Layout.php" hash="d7b7ec5f4bbd846dd063934f8a267d48"/></dir><file name="Searchhelper.php" hash="dfc4fc81fea519c15517f53645488c7a"/><file name="Suggestionhelper.php" hash="93f3aa295761a510f782856c0180a799"/></dir><dir name="Model"><dir name="Api"><file name="Request.php" hash="7df8b22d74b6a05de86da287687a6e96"/></dir><dir name="Catalogsearch"><file name="Layer.php" hash="bbfbad54d1c5688cc5627a6c25ba7d20"/></dir><dir name="Feed"><file name="Feedconfig.php" hash="013bd447dccc7cc4f073be5bd53a18c9"/><file name="Feedcreator.php" hash="fa6cf4590cf81073325b6717c8951486"/><file name="Feedfilter.php" hash="d7599a63a8d1f2033cb1e56204809c2d"/><file name="Formatter.php" hash="4c78f1f2eaa65a9a46f46d129f62f662"/></dir><file name="Feed.php" hash="ddac87d6a060bc77fb7718e7b19e1273"/><file name="Log.php" hash="27fcee49e67fe2be761b4af94aecff2b"/><file name="Observer.php" hash="4aa575eea33402932390f4e30625a67e"/><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="6b660487988035cd715fa3c51b2b58b6"/></dir></dir><dir name="Translator"><file name="Category.php" hash="0050de4918d73af310008aa8f49239d1"/></dir><file name="Validate.php" hash="7a5fd226b0055e39b725975113e42ee5"/><dir name="Writer"><file name="Abstract.php" hash="6b5153c0a09f8d4ee6fe4cedc5ec8a64"/><file name="Csv.php" hash="427fea44d988302f409e1860c18875b1"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="c4f80c214d11fd531496e71b4951b27f"/></dir><file name="ApiController.php" hash="7ead355ff1fb74ca8cdbdfb766225fe3"/><dir name="CatalogSearch"><file name="ResultController.php" hash="9cb1406e901701ea58e663433358a4c6"/></dir><file name="ConfigController.php" hash="0fd9a9686806c26635c7db0a57a0f4ab"/><file name="IndexController.php" hash="7bfaa867dfa9bed0c7b0ebd634d2e2bb"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e86ff2b7aac4d09a4c359f0047b06ca3"/><file name="config.xml" hash="09b49197e59ef47c9adce7873d068c8a"/></dir><dir name="sql"><dir name="expertrec_setup"><file name="mysql4-install-1.1.7.php" hash="017dd7dc0c683db749f490a632481f05"/><file name="mysql4-upgrade-1.1.6-1.1.7.php" hash="87ed11c4a652d8493e4afb503e66a1d6"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Expertrec_Recommendation.xml" hash="c314465f907c89dfe912035be8d48e71"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="expertrec"><file name="recommendation.xml" hash="061b28ab9009ff2346977cebe2333cb8"/></dir></dir><dir name="template"><dir name="expertrec"><dir name="feed"><file name="info.phtml" hash="e386121a2d08b754ace87ab8a146e941"/></dir><dir name="recommendation"><file name="tracker.phtml" hash="c4da6289ad644d96d7dac9b5521ae3a1"/><dir name="tracking"><file name="product.phtml" hash="e02d3f870397cf351bc0ff7ca864c7e2"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Expertrec_Recommendation</name>
4
+ <version>1.0.13</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
11
  <notes>Expertrec Recommendation plugin for magento sites.</notes>
12
  <authors><author><name>melchi</name><user>melchi</user><email>magento@cloudinfra.in</email></author><author><name>magento</name><user>magento</user><email>magento-team@cloudinfra.in</email></author></authors>
13
  <date>2017-02-20</date>
14
+ <time>13:01:41</time>
15
+ <contents><target name="magecommunity"><dir name="Expertrec"><dir name="Recommendation"><dir name="Block"><file name="Api.php" hash="ce87654622f030c6e8b5a992713da5d8"/></dir><dir name="Helper"><file name="Autocompletehelper.php" hash="7bd733d91f69091c1f6f5bb162467a43"/><file name="Data.php" hash="8a2760edc960d6a1bc72d80e73944cb3"/><file name="Filehelper.php" hash="5ac956e12548398dc159a16eb1a03e8b"/><dir name="Search"><file name="Layout.php" hash="c68c9d6c4def7daca0a0ae332dceaff3"/></dir><file name="Suggestionhelper.php" hash="93f3aa295761a510f782856c0180a799"/></dir><dir name="Model"><dir name="Api"><file name="Request.php" hash="7df8b22d74b6a05de86da287687a6e96"/></dir><dir name="Feed"><file name="Feedconfig.php" hash="013bd447dccc7cc4f073be5bd53a18c9"/><file name="Feedcreator.php" hash="fa6cf4590cf81073325b6717c8951486"/><file name="Feedfilter.php" hash="d7599a63a8d1f2033cb1e56204809c2d"/><file name="Formatter.php" hash="4c78f1f2eaa65a9a46f46d129f62f662"/></dir><file name="Feed.php" hash="ddac87d6a060bc77fb7718e7b19e1273"/><file name="Log.php" hash="27fcee49e67fe2be761b4af94aecff2b"/><file name="Observer.php" hash="2c332472ed4cd1ccea25bec705dbda06"/><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="6b660487988035cd715fa3c51b2b58b6"/></dir></dir><dir name="Translator"><file name="Category.php" hash="0050de4918d73af310008aa8f49239d1"/></dir><file name="Validate.php" hash="2d4619284f24309b77668f07cb1ef9f4"/><dir name="Writer"><file name="Abstract.php" hash="6b5153c0a09f8d4ee6fe4cedc5ec8a64"/><file name="Csv.php" hash="427fea44d988302f409e1860c18875b1"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="c4f80c214d11fd531496e71b4951b27f"/></dir><file name="ApiController.php" hash="1d311e8d58f6f410793f41d68bc061c1"/><dir name="CatalogSearch"><file name="ResultController.php" hash="e740f44c0cef4aa83545f2278626e7de"/></dir><file name="ConfigController.php" hash="0fd9a9686806c26635c7db0a57a0f4ab"/><file name="IndexController.php" hash="7bfaa867dfa9bed0c7b0ebd634d2e2bb"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e86ff2b7aac4d09a4c359f0047b06ca3"/><file name="config.xml" hash="b373376c708c044325e58a66f25de1e7"/></dir><dir name="sql"><dir name="expertrec_setup"><file name="mysql4-install-1.0.13.php" hash="6bc0c68d07f14bc6309858454f5ad0ae"/><file name="mysql4-upgrade-1.0.11-1.0.13.php" hash="8d41a83f73f16ea6a90ad4827e5b0385"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Expertrec_Recommendation.xml" hash="c314465f907c89dfe912035be8d48e71"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="expertrec"><file name="recommendation.xml" hash="a1d166c3c3e665b476aaef69e0e6b792"/></dir></dir><dir name="template"><dir name="expertrec"><dir name="feed"><file name="info.phtml" hash="e386121a2d08b754ace87ab8a146e941"/></dir><dir name="recommendation"><file name="tracker.phtml" hash="6e8219c5d1e46642d7915cedaa974313"/><dir name="tracking"><file name="product.phtml" hash="e02d3f870397cf351bc0ff7ca864c7e2"/></dir></dir><dir name="search"><file name="custom.phtml" hash="0f162aa949c00329e3697f0a71abc43d"/><file name="list.phtml" hash="cda3f434a1e70f1272f62bb9f0848726"/><file name="view.phtml" hash="ecb9a55f6128bef2f10d66528dc5424b"/></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>