Flagbit_Factfinder - Version 3.5.1

Version Notes

[+BUGFIX] set $graceful parameter to true. This avoid exceptions on Mage::register if the key already exists. This happens if the layered navigation will be included more than once. i. e. left and content
[+BUGFIX] issue #34 selected filters are displayed twice
[+BUGFIX] trim category values before encoding them
[+BUGFIX] don't send clicktracking if disabled
[~BUGFIX] don't allow default attributes inside the attribute-setup
[+TASK] updated FF PHP framework
[~TASK] improved export memory usage, by unsetting some bigger variables
[~TASK] remove typical magento parameters from the request to ff
[~TASK] extracted method sendClickTrackingForSingleProduct

Download this release

Release Info

Developer Magento Core Team
Extension Flagbit_Factfinder
Version 3.5.1
Comparing to
See all releases


Code changes from version 3.4.8 to 3.5.1

Files changed (86) hide show
  1. app/code/community/Flagbit/FactFinder/Block/Adminhtml/Exportlink.php +1 -1
  2. app/code/community/Flagbit/FactFinder/Block/Product/List/Upsell.php +16 -14
  3. app/code/community/Flagbit/FactFinder/Block/Scic.php +0 -89
  4. app/code/community/Flagbit/FactFinder/Block/Tracking.php +108 -0
  5. app/code/community/Flagbit/FactFinder/Block/XmlConnect/Catalog/Product/List.php +39 -29
  6. app/code/community/Flagbit/FactFinder/Block/XmlConnect/Catalog/Search.php +27 -17
  7. app/code/community/Flagbit/FactFinder/Helper/Data.php +10 -0
  8. app/code/community/Flagbit/FactFinder/Helper/Search.php +5 -4
  9. app/code/community/Flagbit/FactFinder/Model/Export/Product.php +1 -1
  10. app/code/community/Flagbit/FactFinder/Model/Facade.php +31 -1
  11. app/code/community/Flagbit/FactFinder/Model/Handler/ProductDetailCampaign.php +1 -1
  12. app/code/community/Flagbit/FactFinder/Model/Handler/Search.php +10 -1
  13. app/code/community/Flagbit/FactFinder/Model/Handler/Tracking.php +64 -0
  14. app/code/community/Flagbit/FactFinder/Model/Handler/Tracking/Scic.php +73 -0
  15. app/code/community/Flagbit/FactFinder/Model/Layer/Filter/Item.php +2 -2
  16. app/code/community/Flagbit/FactFinder/Model/Mysql4/Search/Collection.php +10 -3
  17. app/code/community/Flagbit/FactFinder/Model/Observer.php +114 -82
  18. app/code/community/Flagbit/FactFinder/Model/Processor.php +5 -0
  19. app/code/community/Flagbit/FactFinder/Model/System/Config/Source/Ffversion.php +4 -0
  20. app/code/community/Flagbit/FactFinder/controllers/ProxyController.php +13 -7
  21. app/code/community/Flagbit/FactFinder/etc/config.xml +20 -15
  22. app/design/frontend/base/default/layout/factfinder.xml +2 -2
  23. app/design/frontend/base/default/template/factfinder/form.advancedsuggest68.phtml +10 -2
  24. app/design/frontend/base/default/template/factfinder/{scic.phtml → tracking.phtml} +7 -6
  25. app/locale/de_DE/Flagbit_FactFinder.csv +2 -1
  26. js/factfinder/{scic.js → tracking.js} +2 -3
  27. lib/FACTFinder/Abstract/Adapter.php +1 -5
  28. lib/FACTFinder/AsnSliderFilter.php +8 -0
  29. lib/FACTFinder/Default/CompareAdapter.php +0 -12
  30. lib/FACTFinder/Default/RecommendationAdapter.php +2 -2
  31. lib/FACTFinder/Default/SimilarRecordsAdapter.php +1 -1
  32. lib/FACTFinder/Default/TagCloudAdapter.php +13 -0
  33. lib/FACTFinder/Default/TrackingAdapter.php +103 -0
  34. lib/FACTFinder/Http/DummyProvider.php +10 -16
  35. lib/FACTFinder/Http/TrackingAdapter.php +31 -0
  36. lib/FACTFinder/Item.php +8 -0
  37. lib/FACTFinder/Json66/CompareAdapter.php +71 -0
  38. lib/FACTFinder/Json66/ImportAdapter.php +74 -0
  39. lib/FACTFinder/Json66/RecommendationAdapter.php +11 -0
  40. lib/FACTFinder/Json66/SearchAdapter.php +515 -0
  41. lib/FACTFinder/Json66/SimilarRecordsAdapter.php +75 -0
  42. lib/FACTFinder/Json66/SuggestAdapter.php +58 -0
  43. lib/FACTFinder/Json66/TagCloudAdapter.php +55 -0
  44. lib/FACTFinder/Json67/CompareAdapter.php +7 -0
  45. lib/FACTFinder/Json67/ImportAdapter.php +10 -0
  46. lib/FACTFinder/Json67/ProductCampaignAdapter.php +160 -0
  47. lib/FACTFinder/Json67/RecommendationAdapter.php +88 -0
  48. lib/FACTFinder/Json67/SearchAdapter.php +138 -0
  49. lib/FACTFinder/Json67/SimilarRecordsAdapter.php +7 -0
  50. lib/FACTFinder/Json67/SuggestAdapter.php +10 -0
  51. lib/FACTFinder/Json67/TagCloudAdapter.php +10 -0
  52. lib/FACTFinder/Json68/CompareAdapter.php +7 -0
  53. lib/FACTFinder/Json68/ImportAdapter.php +10 -0
  54. lib/FACTFinder/Json68/ProductCampaignAdapter.php +25 -0
  55. lib/FACTFinder/Json68/RecommendationAdapter.php +10 -0
  56. lib/FACTFinder/Json68/SearchAdapter.php +42 -0
  57. lib/FACTFinder/Json68/SimilarRecordsAdapter.php +4 -0
  58. lib/FACTFinder/Json68/SuggestAdapter.php +22 -0
  59. lib/FACTFinder/Json68/TagCloudAdapter.php +10 -0
  60. lib/FACTFinder/Json69/CompareAdapter.php +7 -0
  61. lib/FACTFinder/Json69/ImportAdapter.php +10 -0
  62. lib/FACTFinder/Json69/ProductCampaignAdapter.php +8 -0
  63. lib/FACTFinder/Json69/RecommendationAdapter.php +10 -0
  64. lib/FACTFinder/Json69/SearchAdapter.php +74 -0
  65. lib/FACTFinder/Json69/SimilarRecordsAdapter.php +7 -0
  66. lib/FACTFinder/Json69/SuggestAdapter.php +17 -0
  67. lib/FACTFinder/Json69/TagCloudAdapter.php +11 -0
  68. lib/FACTFinder/Paging.php +16 -2
  69. lib/FACTFinder/ParametersParser.php +8 -2
  70. lib/FACTFinder/Record.php +1 -1
  71. lib/FACTFinder/Result.php +21 -0
  72. lib/FACTFinder/SuggestQuery.php +22 -13
  73. lib/FACTFinder/Util.php +36 -4
  74. lib/FACTFinder/Xml65/SearchAdapter.php +115 -87
  75. lib/FACTFinder/Xml66/SearchAdapter.php +7 -23
  76. lib/FACTFinder/Xml68/SearchAdapter.php +2 -66
  77. lib/FACTFinder/Xml69/CompareAdapter.php +17 -0
  78. lib/FACTFinder/Xml69/ImportAdapter.php +17 -0
  79. lib/FACTFinder/Xml69/ProductCampaignAdapter.php +18 -0
  80. lib/FACTFinder/Xml69/RecommendationAdapter.php +17 -0
  81. lib/FACTFinder/Xml69/SearchAdapter.php +67 -0
  82. lib/FACTFinder/Xml69/SimilarRecordsAdapter.php +17 -0
  83. lib/FACTFinder/Xml69/SuggestAdapter.php +17 -0
  84. lib/FACTFinder/Xml69/TagCloudAdapter.php +11 -0
  85. lib/FACTFinder/Xml69/TrackingAdapter.php +7 -0
  86. package.xml +13 -14
app/code/community/Flagbit/FactFinder/Block/Adminhtml/Exportlink.php CHANGED
@@ -52,7 +52,7 @@ class Flagbit_FactFinder_Block_Adminhtml_Exportlink extends Mage_Adminhtml_Block
52
}
53
}
54
55
- $password = Mage::getStoreConfig('factfinder/search/auth_password');
56
57
if ($store) $storeParam = '&store='.(int)Mage::getConfig()->getNode('stores/' . $store . '/system/store/id');
58
else $storeParam = '';
52
}
53
}
54
55
+ $password = Mage::getStoreConfig('factfinder/search/auth_password', $store);
56
57
if ($store) $storeParam = '&store='.(int)Mage::getConfig()->getNode('stores/' . $store . '/system/store/id');
58
else $storeParam = '';
app/code/community/Flagbit/FactFinder/Block/Product/List/Upsell.php CHANGED
@@ -26,18 +26,20 @@ class Flagbit_FactFinder_Block_Product_List_Upsell extends Mage_Catalog_Block_Pr
26
27
protected function _prepareLayout()
28
{
29
- $productIds = array(
30
- Mage::registry('current_product')->getData(Mage::helper('factfinder/search')->getIdFieldName())
31
- );
32
-
33
if(Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign')) {
34
$this->_productCampaignHandler = Mage::getSingleton('factfinder/handler_productDetailCampaign', $productIds);
35
}
36
-
37
if (Mage::getStoreConfigFlag('factfinder/activation/upsell')) {
38
$this->_recommendationsHandler = Mage::getSingleton('factfinder/handler_recommendations', $productIds);
39
}
40
-
41
return parent::_prepareLayout();
42
}
43
@@ -64,7 +66,7 @@ class Flagbit_FactFinder_Block_Product_List_Upsell extends Mage_Catalog_Block_Pr
64
$mergedUpsell = array_merge($pushedProducts, (array) $recommendations);
65
$this->applyUpsells($mergedUpsell);
66
}
67
-
68
return $this;
69
}
70
@@ -73,10 +75,10 @@ class Flagbit_FactFinder_Block_Product_List_Upsell extends Mage_Catalog_Block_Pr
73
try {
74
$product = Mage::registry('product');
75
/* @var $product Mage_Catalog_Model_Product */
76
-
77
- // build new FACTFinder_Result with combined data
78
$recommendations = FF::getInstance('result', $upsells, count($upsells));
79
-
80
if ($recommendations == null) {
81
throw new Exception('No recommendations given - check connection to FACT-Finder and FACT-Finder configuration');
82
}
@@ -118,10 +120,10 @@ class Flagbit_FactFinder_Block_Product_List_Upsell extends Mage_Catalog_Block_Pr
118
$this->_itemCollection = new Varien_Data_Collection();
119
}
120
}
121
-
122
/**
123
* get pushed products to combine with recommendations
124
- *
125
* @return array
126
*/
127
protected function getPushedProducts()
@@ -133,8 +135,8 @@ class Flagbit_FactFinder_Block_Product_List_Upsell extends Mage_Catalog_Block_Pr
133
if($_campaigns && $_campaigns->hasPushedProducts()){
134
$pushedProducts = $_campaigns->getPushedProducts();
135
}
136
-
137
return $pushedProducts;
138
}
139
-
140
}
26
27
protected function _prepareLayout()
28
{
29
+ $productIds = array();
30
+
31
+ if(Mage::registry('current_product') instanceof Mage_Catalog_Model_Product){
32
+ $productIds[] = Mage::registry('current_product')->getData(Mage::helper('factfinder/search')->getIdFieldName());
33
+ }
34
+
35
if(Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign')) {
36
$this->_productCampaignHandler = Mage::getSingleton('factfinder/handler_productDetailCampaign', $productIds);
37
}
38
+
39
if (Mage::getStoreConfigFlag('factfinder/activation/upsell')) {
40
$this->_recommendationsHandler = Mage::getSingleton('factfinder/handler_recommendations', $productIds);
41
}
42
+
43
return parent::_prepareLayout();
44
}
45
66
$mergedUpsell = array_merge($pushedProducts, (array) $recommendations);
67
$this->applyUpsells($mergedUpsell);
68
}
69
+
70
return $this;
71
}
72
75
try {
76
$product = Mage::registry('product');
77
/* @var $product Mage_Catalog_Model_Product */
78
+
79
+ // build new FACTFinder_Result with combined data
80
$recommendations = FF::getInstance('result', $upsells, count($upsells));
81
+
82
if ($recommendations == null) {
83
throw new Exception('No recommendations given - check connection to FACT-Finder and FACT-Finder configuration');
84
}
120
$this->_itemCollection = new Varien_Data_Collection();
121
}
122
}
123
+
124
/**
125
* get pushed products to combine with recommendations
126
+ *
127
* @return array
128
*/
129
protected function getPushedProducts()
135
if($_campaigns && $_campaigns->hasPushedProducts()){
136
$pushedProducts = $_campaigns->getPushedProducts();
137
}
138
+
139
return $pushedProducts;
140
}
141
+
142
}
app/code/community/Flagbit/FactFinder/Block/Scic.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- /**
3
- * Flagbit_FactFinder
4
- *
5
- * @category Mage
6
- * @package Flagbit_FactFinder
7
- * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
8
- */
9
-
10
- /**
11
- * Block class
12
- *
13
- * This class is used to disable Magento´s default Price and Category Filter Output
14
- *
15
- * @category Mage
16
- * @package Flagbit_FactFinder
17
- * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
18
- * @author Joerg Weller <weller@flagbit.de>
19
- * @version $Id$
20
- */
21
- class Flagbit_FactFinder_Block_Scic extends Mage_Core_Block_Template
22
- {
23
-
24
- /**
25
- * get Product Result Collection
26
- *
27
- * @return Flagbit_FactFinder_Model_Mysql4_Search_Collection
28
- */
29
- protected function _getProductResultCollection()
30
- {
31
- return Mage::getSingleton('factfinder/layer')->getProductCollection();
32
- }
33
-
34
- /**
35
- * get Product URL to ID Mapping JSON Object
36
- *
37
- * @return string
38
- */
39
- public function getJsonUrlToIdMappingObject()
40
- {
41
- $data = array();
42
- foreach($this->_getProductResultCollection() as $product){
43
- $data[$product->getProductUrl()] = $product->getId();
44
- }
45
- return Mage::helper('core')->jsonEncode($data);
46
- }
47
-
48
- /**
49
- * get Product and Search Details by ID as JSON Object
50
- *
51
- * @return string
52
- */
53
- public function getJsonDataObject()
54
- {
55
- $searchHelper = Mage::helper('factfinder/search');
56
- $idFieldName = $searchHelper->getIdFieldName();
57
-
58
- $dataTemplate = array(
59
- 'query' => $searchHelper->getQuery()->getQueryText(),
60
- 'page' => $searchHelper->getCurrentPage(),
61
- 'sid' => md5(Mage::getSingleton('core/session')->getSessionId()),
62
- 'pageSize' => $searchHelper->getPageLimit(),
63
- 'origPageSize' => $searchHelper->getDefaultPerPageValue(),
64
- 'channel' => Mage::getStoreConfig('factfinder/search/channel'),
65
- 'event' => 'click'
66
- );
67
-
68
- $customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
69
- if ($customerId) {
70
- $dataTemplate['userId'] = md5('customer_' . $customerId);
71
- }
72
-
73
- $data = array();
74
- foreach($this->_getProductResultCollection() as $product){
75
- $key = $product->getId();
76
- $data[$key] = array(
77
- 'id' => $product->getData($idFieldName),
78
- 'pos' => $product->getPosition(),
79
- 'origPos' => $product->getOriginalPosition(),
80
- 'title' => $product->getName(),
81
- 'simi' => $product->getSimilarity()
82
- );
83
- $data[$key] += $dataTemplate;
84
- }
85
-
86
- return Mage::helper('core')->jsonEncode($data);
87
- }
88
-
89
- }
app/code/community/Flagbit/FactFinder/Block/Tracking.php ADDED
@@ -0,0 +1,108 @@
1
+ <?php
2
+ /**
3
+ * Flagbit_FactFinder
4
+ *
5
+ * @category Mage
6
+ * @package Flagbit_FactFinder
7
+ * @copyright Copyright (c) 2013 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
8
+ */
9
+
10
+ /**
11
+ * Tracking block class
12
+ *
13
+ * @category Mage
14
+ * @package Flagbit_FactFinder
15
+ * @copyright Copyright (c) 2013 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
16
+ * @author Joerg Weller <joerg.weller@flagbit.de>
17
+ * @author Nicolai Essig <nicolai.essig@flagbit.de>
18
+ * @version $Id$
19
+ */
20
+ class Flagbit_FactFinder_Block_Tracking extends Mage_Core_Block_Template
21
+ {
22
+
23
+ /**
24
+ * get Product Result Collection
25
+ *
26
+ * @return Flagbit_FactFinder_Model_Mysql4_Search_Collection
27
+ */
28
+ protected function _getProductResultCollection()
29
+ {
30
+ return Mage::getSingleton('factfinder/layer')->getProductCollection();
31
+ }
32
+
33
+ /**
34
+ * get Product URL to ID Mapping JSON Object
35
+ *
36
+ * @return string
37
+ */
38
+ public function getJsonUrlToIdMappingObject()
39
+ {
40
+ $data = array();
41
+ foreach($this->_getProductResultCollection() as $product){
42
+ $data[$product->getProductUrl()] = $product->getId();
43
+ }
44
+ return Mage::helper('core')->jsonEncode($data);
45
+ }
46
+
47
+ /**
48
+ * get Product and Search Details by ID as JSON Object
49
+ *
50
+ * @return string
51
+ */
52
+ public function getJsonDataObject()
53
+ {
54
+ $searchHelper = Mage::helper('factfinder/search');
55
+ $idFieldName = $searchHelper->getIdFieldName();
56
+
57
+ $customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
58
+ if ($customerId) {
59
+ $customerId = md5('customer_' . $customerId);
60
+ }
61
+
62
+ if(Mage::helper('factfinder')->useOldTracking())
63
+ {
64
+ $dataTemplate = array(
65
+ 'query' => $searchHelper->getQuery()->getQueryText(),
66
+ 'page' => $searchHelper->getCurrentPage(),
67
+ 'sid' => md5(Mage::getSingleton('core/session')->getSessionId()),
68
+ 'pageSize' => $searchHelper->getPageLimit(),
69
+ 'origPageSize' => $searchHelper->getDefaultPerPageValue(),
70
+ 'channel' => Mage::getStoreConfig('factfinder/search/channel'),
71
+ 'userId' => $customerId,
72
+ 'event' => 'click'
73
+ );
74
+ } else {
75
+ $dataTemplate = array(
76
+ 'sourceRefKey' => Mage::getSingleton('core/session')->getFactFinderRefKey(),
77
+ 'sid' => md5(Mage::getSingleton('core/session')->getSessionId()),
78
+ 'uid' => $customerId,
79
+ 'site' => Mage::app()->getStore()->getCode(),
80
+ 'event' => FACTFinder_Default_TrackingAdapter::EVENT_INSPECT
81
+ );
82
+ }
83
+
84
+ $data = array();
85
+ foreach($this->_getProductResultCollection() as $product){
86
+ $key = $product->getId();
87
+
88
+ $data[$key] = array(
89
+ 'id' => $product->getData($idFieldName),
90
+ );
91
+
92
+ if(Mage::helper('factfinder')->useOldTracking())
93
+ {
94
+ $data[$key] += array(
95
+ 'pos' => $product->getPosition(),
96
+ 'origPos' => $product->getOriginalPosition(),
97
+ 'title' => $product->getName(),
98
+ 'simi' => $product->getSimilarity()
99
+ );
100
+ }
101
+
102
+ $data[$key] += $dataTemplate;
103
+ }
104
+
105
+ return Mage::helper('core')->jsonEncode($data);
106
+ }
107
+
108
+ }
app/code/community/Flagbit/FactFinder/Block/XmlConnect/Catalog/Product/List.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
/**
3
* Flagbit_FactFinder
4
*
@@ -9,9 +9,9 @@
9
10
/**
11
* Block class
12
- *
13
- * This class is used to disable Magento´s default apply Filter
14
- *
15
* @category Mage
16
* @package Flagbit_FactFinder
17
* @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
@@ -19,7 +19,7 @@
19
* @version $Id$
20
*/
21
class Flagbit_FactFinder_Block_XmlConnect_Catalog_Product_List extends Mage_XmlConnect_Block_Catalog_Product_List {
22
-
23
/**
24
* Retrieve product collection with all prepared data and limitations
25
*
@@ -29,24 +29,20 @@ class Flagbit_FactFinder_Block_XmlConnect_Catalog_Product_List extends Mage_XmlC
29
{
30
if(!Mage::helper('factfinder/search')->getIsEnabled()){
31
return parent::_getProductCollection();
32
- }
33
-
34
- if (is_null($this->_productCollection)) {
35
- switch($this->getRequest()->getActionName()){
36
-
37
- case 'search':
38
- $this->__getSearchProductCollection();
39
- break;
40
-
41
- default:
42
- parent::_getProductCollection();
43
- break;
44
}
45
}
46
return $this->_productCollection;
47
}
48
-
49
-
50
/**
51
* Retrieve product collection with all prepared data and limitations
52
*
@@ -73,16 +69,32 @@ class Flagbit_FactFinder_Block_XmlConnect_Catalog_Product_List extends Mage_XmlC
73
* Apply filters
74
*/
75
foreach ($attributes as $attributeItem) {
76
-
77
$attributeCode = $attributeItem->getAttributeCode();
78
- $filterModel = $this->helper('xmlconnect')->getFilterByKey($attributeCode);
79
80
- $filterModel->setLayer($layer)
81
- ->setAttributeModel($attributeItem);
82
83
$filterParam = parent::REQUEST_FILTER_PARAM_REFIX . $attributeCode;
84
$filters[] = $filterModel;
85
}
86
$this->_collectedFilters = $filters;
87
}
88
@@ -103,20 +115,18 @@ class Flagbit_FactFinder_Block_XmlConnect_Catalog_Product_List extends Mage_XmlC
103
$offset = (int)$request->getParam('offset', 0);
104
$count = (int)$request->getParam('count', 0);
105
$count = $count <= 0 ? 1 : $count;
106
- if($offset + $count < $collection->getSize()){
107
$this->setHasProductItems(1);
108
}
109
$collection->getSelect()->limit($count, $offset);
110
-
111
$collection->setFlag('require_stock_items', true);
112
-
113
$this->_productCollection = $collection;
114
}
115
-
116
return $this->_productCollection;
117
- }
118
119
-
120
}
121
122
1
+ <?php
2
/**
3
* Flagbit_FactFinder
4
*
9
10
/**
11
* Block class
12
+ *
13
+ * This class is used to disable Magento´s default apply Filter
14
+ *
15
* @category Mage
16
* @package Flagbit_FactFinder
17
* @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
19
* @version $Id$
20
*/
21
class Flagbit_FactFinder_Block_XmlConnect_Catalog_Product_List extends Mage_XmlConnect_Block_Catalog_Product_List {
22
+
23
/**
24
* Retrieve product collection with all prepared data and limitations
25
*
29
{
30
if(!Mage::helper('factfinder/search')->getIsEnabled()){
31
return parent::_getProductCollection();
32
+ }
33
+
34
+ if (is_null($this->_productCollection)) {
35
+ if (strpos($this->getRequest()->getActionName(), 'search') !== false) {
36
+ $this->__getSearchProductCollection();
37
+ }
38
+ else {
39
+ parent::_getProductCollection();
40
}
41
}
42
return $this->_productCollection;
43
}
44
+
45
+
46
/**
47
* Retrieve product collection with all prepared data and limitations
48
*
69
* Apply filters
70
*/
71
foreach ($attributes as $attributeItem) {
72
$attributeCode = $attributeItem->getAttributeCode();
73
+ list($filterModel, $filterBlock) = $this->helper('xmlconnect')->getFilterByKey($attributeCode);
74
75
+ $filterModel->setLayer($layer)->setAttributeModel($attributeItem);
76
77
$filterParam = parent::REQUEST_FILTER_PARAM_REFIX . $attributeCode;
78
+ /**
79
+ * Set new request var
80
+ */
81
+ if (isset($requestParams[$filterParam])) {
82
+ $filterModel->setRequestVar($filterParam);
83
+ }
84
+ $filterModel->apply($request, $filterBlock);
85
$filters[] = $filterModel;
86
}
87
+
88
+ /**
89
+ * Separately apply and save category filter
90
+ */
91
+ list($categoryFilter, $categoryFilterBlock) = $this->helper('xmlconnect')->getFilterByKey('category');
92
+ $filterParam = parent::REQUEST_FILTER_PARAM_REFIX . $categoryFilter->getRequestVar();
93
+
94
+ $categoryFilter->setLayer($layer)->setRequestVar($filterParam)
95
+ ->apply($this->getRequest(), $categoryFilterBlock);
96
+ $filters[] = $categoryFilter;
97
+
98
$this->_collectedFilters = $filters;
99
}
100
115
$offset = (int)$request->getParam('offset', 0);
116
$count = (int)$request->getParam('count', 0);
117
$count = $count <= 0 ? 1 : $count;
118
+ if ($offset + $count < $collection->getSize()) {
119
$this->setHasProductItems(1);
120
}
121
$collection->getSelect()->limit($count, $offset);
122
$collection->setFlag('require_stock_items', true);
123
+
124
$this->_productCollection = $collection;
125
}
126
return $this->_productCollection;
127
+ }
128
+
129
130
}
131
132
app/code/community/Flagbit/FactFinder/Block/XmlConnect/Catalog/Search.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
/**
3
* Flagbit_FactFinder
4
*
@@ -9,9 +9,9 @@
9
10
/**
11
* Block class
12
- *
13
* This class is used provide FAC-Finder filters
14
- *
15
* @category Mage
16
* @package Flagbit_FactFinder
17
* @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
@@ -19,8 +19,8 @@
19
* @version $Id$
20
*/
21
class Flagbit_FactFinder_Block_XmlConnect_Catalog_Search extends Mage_XmlConnect_Block_Catalog_Search {
22
-
23
-
24
/**
25
* Search results xml renderer
26
* XML also contains filters that can be apply (accorfingly already applyed filters and search query)
@@ -32,8 +32,8 @@ class Flagbit_FactFinder_Block_XmlConnect_Catalog_Search extends Mage_XmlConnect
32
{
33
if(!Mage::helper('factfinder/search')->getIsEnabled()){
34
return parent::_toHtml();
35
- }
36
-
37
$searchXmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<search></search>');
38
$filtersXmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<filters></filters>');
39
@@ -80,28 +80,27 @@ class Flagbit_FactFinder_Block_XmlConnect_Catalog_Search extends Mage_XmlConnect
80
}
81
if ($isLayeredNavigationAllowed && $productListBlock && $showFiltersAndOrders) {
82
$filters = $productListBlock->getCollectedFilters();
83
-
84
/**
85
* Render filters xml
86
*/
87
foreach ($filters as $filter) {
88
- if (!count($filter->getAttributeModel()->getItems())) {
89
continue;
90
}
91
-
92
$item = $filtersXmlObject->addChild('item');
93
$item->addChild('name', $searchXmlObject->xmlentities($filter->getName()));
94
$item->addChild('code', $filter->getRequestVar());
95
$values = $item->addChild('values');
96
97
- foreach ($filter->getAttributeModel()->getItems() as $valueArray) {
98
- $valueItem = new Varien_Object($valueArray);
99
$count = (int)$valueItem->getCount();
100
if (!$count) {
101
continue;
102
}
103
$value = $values->addChild('value');
104
- $value->addChild('id', base64_encode($valueItem->getValue()));
105
$value->addChild('label', $searchXmlObject->xmlentities(strip_tags($valueItem->getLabel())));
106
$value->addChild('count', $count);
107
}
@@ -113,11 +112,22 @@ class Flagbit_FactFinder_Block_XmlConnect_Catalog_Search extends Mage_XmlConnect
113
* Sort fields
114
*/
115
if ($showFiltersAndOrders) {
116
- $searchXmlObject->appendChild($this->getProductSortFeildsXmlObject());
117
}
118
119
return $searchXmlObject->asNiceXml();
120
}
121
-
122
-
123
- }
1
+ <?php
2
/**
3
* Flagbit_FactFinder
4
*
9
10
/**
11
* Block class
12
+ *
13
* This class is used provide FAC-Finder filters
14
+ *
15
* @category Mage
16
* @package Flagbit_FactFinder
17
* @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
19
* @version $Id$
20
*/
21
class Flagbit_FactFinder_Block_XmlConnect_Catalog_Search extends Mage_XmlConnect_Block_Catalog_Search {
22
+
23
+
24
/**
25
* Search results xml renderer
26
* XML also contains filters that can be apply (accorfingly already applyed filters and search query)
32
{
33
if(!Mage::helper('factfinder/search')->getIsEnabled()){
34
return parent::_toHtml();
35
+ }
36
+
37
$searchXmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<search></search>');
38
$filtersXmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<filters></filters>');
39
80
}
81
if ($isLayeredNavigationAllowed && $productListBlock && $showFiltersAndOrders) {
82
$filters = $productListBlock->getCollectedFilters();
83
+
84
/**
85
* Render filters xml
86
*/
87
foreach ($filters as $filter) {
88
+ if (!$this->_isFilterItemsHasValues($filter)) {
89
continue;
90
}
91
+
92
$item = $filtersXmlObject->addChild('item');
93
$item->addChild('name', $searchXmlObject->xmlentities($filter->getName()));
94
$item->addChild('code', $filter->getRequestVar());
95
$values = $item->addChild('values');
96
97
+ foreach ($filter->getItems() as $valueItem) {
98
$count = (int)$valueItem->getCount();
99
if (!$count) {
100
continue;
101
}
102
$value = $values->addChild('value');
103
+ $value->addChild('id', $valueItem->getValueString());
104
$value->addChild('label', $searchXmlObject->xmlentities(strip_tags($valueItem->getLabel())));
105
$value->addChild('count', $count);
106
}
112
* Sort fields
113
*/
114
if ($showFiltersAndOrders) {
115
+ $searchXmlObject->appendChild($this->getProductSortFieldsXmlObject());
116
}
117
118
return $searchXmlObject->asNiceXml();
119
}
120
+
121
+ /**
122
+ * Overwrite original fallback, because they forgot to return
123
+ *
124
+ * @return Mage_XmlConnect_Model_Simplexml_Element
125
+ */
126
+ public function getProductSortFieldsXmlObject()
127
+ {
128
+ if(method_exists(get_parent_class($this), 'getProductSortFieldsXmlObject')) {
129
+ return parent::getProductSortFieldsXmlObject();
130
+ }
131
+ return parent::getProductSortFeildsXmlObject();
132
+ }
133
+ }
app/code/community/Flagbit/FactFinder/Helper/Data.php CHANGED
@@ -32,5 +32,15 @@ class Flagbit_FactFinder_Helper_Data extends Mage_Core_Helper_Abstract {
32
$model = Mage::getConfig()->getNode("global/models/$code");
33
return $module && $module->is('active') || $model;
34
}
35
36
}
32
$model = Mage::getConfig()->getNode("global/models/$code");
33
return $module && $module->is('active') || $model;
34
}
35
+
36
+ /**
37
+ * Decide which tracking should be used
38
+ *
39
+ * @return bool
40
+ */
41
+ public function useOldTracking()
42
+ {
43
+ return (Mage::getStoreConfig('factfinder/search/ffversion') < 69);
44
+ }
45
46
}
app/code/community/Flagbit/FactFinder/Helper/Search.php CHANGED
@@ -112,7 +112,7 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
112
$nextRetryTimestamp = intval(time() / 60) + $delay;
113
Mage::app()->saveCache($nextRetryTimestamp, $this->_getCacheId('nextRetryTimestamp'), array(self::CACHE_TAG));
114
}
115
-
116
protected function _disableFallback()
117
{
118
self::$_skipFactFinder = false;
@@ -145,7 +145,7 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
145
146
return self::$_skipFactFinder;
147
}
148
-
149
/**
150
* resets all fallback counter values.
151
*
@@ -170,7 +170,7 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
170
171
$failedAttempts = $this->_loadFailedAttempts();
172
$failedAttempts = $this->_removeOldEntries($failedAttempts);
173
- $failedAttempts[] = intval(time() / 60);
174
$this->_saveFailedAttempts($failedAttempts);
175
176
self::$_failedAttemptRegistered = true;
@@ -279,7 +279,8 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
279
*/
280
public function getIsOnSearchPage()
281
{
282
- return Mage::app()->getRequest()->getModuleName() == 'catalogsearch' || Mage::app()->getRequest()->getModuleName() == 'xmlconnect';
283
}
284
285
112
$nextRetryTimestamp = intval(time() / 60) + $delay;
113
Mage::app()->saveCache($nextRetryTimestamp, $this->_getCacheId('nextRetryTimestamp'), array(self::CACHE_TAG));
114
}
115
+
116
protected function _disableFallback()
117
{
118
self::$_skipFactFinder = false;
145
146
return self::$_skipFactFinder;
147
}
148
+
149
/**
150
* resets all fallback counter values.
151
*
170
171
$failedAttempts = $this->_loadFailedAttempts();
172
$failedAttempts = $this->_removeOldEntries($failedAttempts);
173
+ $failedAttempts[] = intval(time() / 60);
174
$this->_saveFailedAttempts($failedAttempts);
175
176
self::$_failedAttemptRegistered = true;
279
*/
280
public function getIsOnSearchPage()
281
{
282
+ return Mage::app()->getRequest()->getModuleName() == 'catalogsearch' ||
283
+ (Mage::app()->getRequest()->getModuleName() == 'xmlconnect' && strpos(Mage::app()->getRequest()->getActionName(), 'search') !== false);
284
}
285
286
app/code/community/Flagbit/FactFinder/Model/Export/Product.php CHANGED
@@ -456,7 +456,7 @@ class Flagbit_FactFinder_Model_Export_Product extends Mage_CatalogSearch_Model_M
456
)
457
)
458
->where('main.store_id = ?', $storeId)
459
- ->where('e.path LIKE \'1/' . Mage::app()->getStore()->getRootCategoryId() .'/%\'')
460
->group('main.product_id');
461
462
$this->_productsToCategoryPath = $this->_getReadAdapter()->fetchPairs($select);
456
)
457
)
458
->where('main.store_id = ?', $storeId)
459
+ ->where('e.path LIKE \'1/' . Mage::app()->getStore($storeId)->getRootCategoryId() .'/%\'')
460
->group('main.product_id');
461
462
$this->_productsToCategoryPath = $this->_getReadAdapter()->fetchPairs($select);
app/code/community/Flagbit/FactFinder/Model/Facade.php CHANGED
@@ -111,6 +111,11 @@ class Flagbit_FactFinder_Model_Facade
111
return $this->_getAdapter("similarRecords", $channel);
112
}
113
114
public function configureSearchAdapter($params, $channel = null, $id = null)
115
{
116
$this->_configureAdapter($params, "search", $channel, $id);
@@ -156,6 +161,11 @@ class Flagbit_FactFinder_Model_Facade
156
$this->_configureAdapter($params, "similarRecords", $channel, $id);
157
}
158
159
protected function _configureAdapter($params, $type, $channel = null, $id = null)
160
{
161
$adapter = $this->_getAdapter($type, $channel, $id);
@@ -300,6 +310,11 @@ class Flagbit_FactFinder_Model_Facade
300
}
301
302
public function applyTracking($channel = null, $id = null)
303
{
304
return $this->_getFactFinderObject("Scic", "applyTracking", $channel, $id);
305
}
@@ -361,10 +376,25 @@ class Flagbit_FactFinder_Model_Facade
361
362
protected function _getFactFinderObject($adapterType, $objectGetter, $channel = null, $id = null)
363
{
364
try {
365
$this->_loadAllData();
366
$adapterGetter = "get".$adapterType."Adapter";
367
- return $this->$adapterGetter($channel, $id)->$objectGetter();
368
} catch (Exception $e) {
369
Mage::logException($e);
370
return null;
111
return $this->_getAdapter("similarRecords", $channel);
112
}
113
114
+ public function getTrackingAdapter($channel = null)
115
+ {
116
+ return $this->_getAdapter("tracking", $channel);
117
+ }
118
+
119
public function configureSearchAdapter($params, $channel = null, $id = null)
120
{
121
$this->_configureAdapter($params, "search", $channel, $id);
161
$this->_configureAdapter($params, "similarRecords", $channel, $id);
162
}
163
164
+ public function configureTrackingAdapter($params, $channel = null, $id = null)
165
+ {
166
+ $this->_configureAdapter($params, "tracking", $channel, $id);
167
+ }
168
+
169
protected function _configureAdapter($params, $type, $channel = null, $id = null)
170
{
171
$adapter = $this->_getAdapter($type, $channel, $id);
310
}
311
312
public function applyTracking($channel = null, $id = null)
313
+ {
314
+ return $this->_getFactFinderObject("Tracking", "applyTracking", $channel, $id);
315
+ }
316
+
317
+ public function applyScicTracking($channel = null, $id = null)
318
{
319
return $this->_getFactFinderObject("Scic", "applyTracking", $channel, $id);
320
}
376
377
protected function _getFactFinderObject($adapterType, $objectGetter, $channel = null, $id = null)
378
{
379
+ $cacheKey = 'FACTFINDER_'.implode('_',func_get_args()).'_' . md5(serialize($this->_getParamsParser()));
380
+
381
+ if(Mage::app()->useCache('factfinder_search') && $cache = Mage::app()->loadCache($cacheKey))
382
+ {
383
+ return unserialize($cache);
384
+ }
385
+
386
try {
387
$this->_loadAllData();
388
$adapterGetter = "get".$adapterType."Adapter";
389
+
390
+ $data = $this->$adapterGetter($channel, $id)->$objectGetter();
391
+
392
+ if(Mage::app()->useCache('factfinder_search'))
393
+ {
394
+ Mage::app()->saveCache(serialize($data), $cacheKey, array('FACTFINDER_SEARCH'), 600);
395
+ }
396
+
397
+ return $data;
398
} catch (Exception $e) {
399
Mage::logException($e);
400
return null;
app/code/community/Flagbit/FactFinder/Model/Handler/ProductDetailCampaign.php CHANGED
@@ -20,7 +20,7 @@ class Flagbit_FactFinder_Model_Handler_ProductDetailCampaign
20
protected function _getProductNumberParam()
21
{
22
if(is_array($this->_productIds))
23
- return $this->_productIds[0];
24
else
25
return $this->_productIds;
26
}
20
protected function _getProductNumberParam()
21
{
22
if(is_array($this->_productIds))
23
+ return current($this->_productIds);
24
else
25
return $this->_productIds;
26
}
app/code/community/Flagbit/FactFinder/Model/Handler/Search.php CHANGED
@@ -49,7 +49,7 @@ class Flagbit_FactFinder_Model_Handler_Search
49
$params['idsOnly'] = FF::getSingleton('configuration')->getIdsOnly() ? 'true' : 'false';
50
$params['query'] = $_query;
51
52
- $count = $requestParams['count'];
53
if ($count > 0) {
54
$params['productsPerPage'] = $count;
55
$params['page'] = ($requestParams['offset'] / $count) + 1;
@@ -92,6 +92,9 @@ class Flagbit_FactFinder_Model_Handler_Search
92
$requestParams['Category'] = $this->_getCurrentFactFinderCategoryPath();
93
}
94
95
case "catalogsearch":
96
default:
97
$_query = '*';
@@ -352,6 +355,12 @@ class Flagbit_FactFinder_Model_Handler_Search
352
$value .= '~~~'.$selectOptions[$option->getField()];
353
}
354
}
355
break;
356
}
357
return $value;
49
$params['idsOnly'] = FF::getSingleton('configuration')->getIdsOnly() ? 'true' : 'false';
50
$params['query'] = $_query;
51
52
+ $count = isset($requestParams['count']) ? $requestParams['count'] : 0;
53
if ($count > 0) {
54
$params['productsPerPage'] = $count;
55
$params['page'] = ($requestParams['offset'] / $count) + 1;
92
$requestParams['Category'] = $this->_getCurrentFactFinderCategoryPath();
93
}
94
95
+
96
+ $params['navigation'] = 'true';
97
+
98
case "catalogsearch":
99
default:
100
$_query = '*';
355
$value .= '~~~'.$selectOptions[$option->getField()];
356
}
357
}
358
+
359
+ // Workaround if only one option is selected
360
+ if($value == $option->getField().'|') {
361
+ $value = '';
362
+ }
363
+
364
break;
365
}
366
return $value;
app/code/community/Flagbit/FactFinder/Model/Handler/Tracking.php ADDED
@@ -0,0 +1,64 @@
1
+ <?php
2
+ /**
3
+ * Handles tracking data
4
+ *
5
+ * @category Mage
6
+ * @package Flagbit_FactFinder
7
+ * @copyright Copyright (c) 2013 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
8
+ * @author Nicolai Essig <nicolai.essig@flagbit.de>
9
+ * @version $Id: Tracking.php 20.08.13 11:35 $
10
+ *
11
+ **/
12
+ class Flagbit_FactFinder_Model_Handler_Tracking
13
+ extends Flagbit_FactFinder_Model_Handler_Abstract
14
+ {
15
+ /**
16
+ * @var array
17
+ */
18
+ protected $_trackingAdapter;
19
+
20
+ /**
21
+ * {@inheritdoc}
22
+ */
23
+ protected function configureFacade() {}
24
+
25
+ /**
26
+ * Get tracking adapter
27
+ *
28
+ * @return tracking adapter object
29
+ */
30
+ public function getTrackingAdapter()
31
+ {
32
+ if($this->_trackingAdapter === null)
33
+ {
34
+ if(Mage::helper('factfinder')->useOldTracking()) {
35
+ $this->_trackingAdapter = Mage::getModel('factfinder/handler_tracking_scic');
36
+ }
37
+ // If old tracking was not activated use the new tracking
38
+ if ($this->_trackingAdapter === null) {
39
+ $this->_trackingAdapter = $this->_getFacade()->getTrackingAdapter();
40
+ }
41
+ if ($this->_trackingAdapter === null)
42
+ $this->_trackingAdapter = array();
43
+ }
44
+ return $this->_trackingAdapter;
45
+ }
46
+
47
+ /**
48
+ * Fire tracking request
49
+ *
50
+ * @return mixed|null
51
+ */
52
+ public function applyTracking()
53
+ {
54
+ if(Mage::helper('factfinder')->useOldTracking()) {
55
+ $result = $this->_getFacade()->applyScicTracking();
56
+ } else {
57
+ $result = $this->_getFacade()->applyTracking();
58
+ }
59
+
60
+ Mage::getSingleton('core/session')->setFactFinderRefKey(null);
61
+
62
+ return $result;
63
+ }
64
+ }
app/code/community/Flagbit/FactFinder/Model/Handler/Tracking/Scic.php ADDED
@@ -0,0 +1,73 @@
1
+ <?php
2
+ /**
3
+ * Creates a mapping between new and old tracking methods
4
+ *
5
+ * @category Mage
6
+ * @package Flagbit_FactFinder
7
+ * @copyright Copyright (c) 2013 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
8
+ * @author Nicolai Essig <nicolai.essig@flagbit.de>
9
+ * @version $Id: Scic.php 26.08.13 15:05 $
10
+ *
11
+ **/
12
+ class Flagbit_FactFinder_Model_Handler_Tracking_Scic
13
+ extends Flagbit_FactFinder_Model_Handler_Abstract
14
+ {
15
+ protected function configureFacade() {}
16
+
17
+ /**
18
+ * Mapping method from new -> old tracking
19
+ *
20
+ * @param $event
21
+ * @param $inputParams
22
+ * @return FACTFinder_Default_ScicAdapter
23
+ */
24
+ public function setupEventTracking($event, $inputParams)
25
+ {
26
+ /* @var $scicAdapter FACTFinder_Default_ScicAdapter */
27
+ $scicAdapter = $this->_getFacade()->getScicAdapter();
28
+
29
+ switch ($event) {
30
+ case FACTFinder_Default_TrackingAdapter::EVENT_INSPECT:
31
+ $searchHelper = $searchHelper = Mage::helper('factfinder/search');
32
+ $scicAdapter->setupClickTracking(
33
+ $inputParams['id'],
34
+ $inputParams['sid'],
35
+ $searchHelper->getQuery()->getQueryText(),
36
+ 1, //pos
37
+ 1, //origPos
38
+ 1, //page
39
+ $inputParams['product']->getSimilarity(),
40
+ $inputParams['product']->getName(),
41
+ $searchHelper->getPageLimit(),
42
+ $searchHelper->getDefaultPerPageValue());
43
+ break;
44
+ case FACTFinder_Default_TrackingAdapter::EVENT_CART:
45
+ $scicAdapter->setupCartTracking(
46
+ $inputParams['id'],
47
+ $inputParams['sid'],
48
+ $inputParams['amount'],
49
+ $inputParams['price'],
50
+ $inputParams['uid']
51
+ );
52
+ break;
53
+ case FACTFinder_Default_TrackingAdapter::EVENT_BUY:
54
+ $scicAdapter->setupCheckoutTracking(
55
+ $inputParams['id'],
56
+ $inputParams['sid'],
57
+ $inputParams['amount'],
58
+ $inputParams['price'],
59
+ $inputParams['uid']
60
+ );
61
+ break;
62
+ case FACTFinder_Default_TrackingAdapter::EVENT_DISPLAY:
63
+ case FACTFinder_Default_TrackingAdapter::EVENT_FEEDBACK:
64
+ case FACTFinder_Default_TrackingAdapter::EVENT_AVAILABILITY_CHECK:
65
+ case FACTFinder_Default_TrackingAdapter::EVENT_CACHE_HIT:
66
+ case FACTFinder_Default_TrackingAdapter::EVENT_SESSION_START:
67
+ // Not implemented yet
68
+ break;
69
+ }
70
+
71
+ return $scicAdapter;
72
+ }
73
+ }
app/code/community/Flagbit/FactFinder/Model/Layer/Filter/Item.php CHANGED
@@ -8,8 +8,8 @@ class Flagbit_FactFinder_Model_Layer_Filter_Item extends Mage_Catalog_Model_Laye
8
* @return string
9
*/
10
public function getRemoveUrl()
11
- {
12
- if ($this->getFilter()->getRequestVar() == 'Category' && $this->getValue() != '') {
13
$query = array($this->getFilter()->getRequestVar()=>$this->getValue());
14
$params['_current'] = true;
15
$params['_use_rewrite'] = true;
8
* @return string
9
*/
10
public function getRemoveUrl()
11
+ {
12
+ if (strtolower($this->getFilter()->getRequestVar()) == 'category' || $this->getValue() != '') {
13
$query = array($this->getFilter()->getRequestVar()=>$this->getValue());
14
$params['_current'] = true;
15
$params['_use_rewrite'] = true;
app/code/community/Flagbit/FactFinder/Model/Mysql4/Search/Collection.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* @category Mage
6
* @package Flagbit_FactFinder
7
- * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
8
*/
9
10
/**
@@ -14,8 +14,9 @@
14
*
15
* @category Mage
16
* @package Flagbit_FactFinder
17
- * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
18
- * @author Joerg Weller <weller@flagbit.de>
19
* @version $Id$
20
*/
21
class Flagbit_FactFinder_Model_Mysql4_Search_Collection
@@ -50,6 +51,12 @@ class Flagbit_FactFinder_Model_Mysql4_Search_Collection
50
{
51
// get product IDs from Fact-Finder
52
$productIds = $this->_getSearchHandler()->getSearchResult();
53
54
if (!empty($productIds)) {
55
$idFieldName = Mage::helper('factfinder/search')->getIdFieldName();
4
*
5
* @category Mage
6
* @package Flagbit_FactFinder
7
+ * @copyright Copyright (c) 2013 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
8
*/
9
10
/**
14
*
15
* @category Mage
16
* @package Flagbit_FactFinder
17
+ * @copyright Copyright (c) 2013 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
18
+ * @author Joerg Weller <joerg.weller@flagbit.de>
19
+ * @author Nicolai Essig <nicolai.essig@flagbit.de>
20
* @version $Id$
21
*/
22
class Flagbit_FactFinder_Model_Mysql4_Search_Collection
51
{
52
// get product IDs from Fact-Finder
53
$productIds = $this->_getSearchHandler()->getSearchResult();
54
+
55
+ Mage::getSingleton('core/session')->setFactFinderRefKey(null);
56
+ if($refKey = Mage::getSingleton('factfinder/facade')->getSearchResult()->getRefKey())
57
+ {
58
+ Mage::getSingleton('core/session')->setFactFinderRefKey($refKey);
59
+ }
60
61
if (!empty($productIds)) {
62
$idFieldName = Mage::helper('factfinder/search')->getIdFieldName();
app/code/community/Flagbit/FactFinder/Model/Observer.php CHANGED
@@ -14,9 +14,10 @@
14
*
15
* @category Mage
16
* @package Flagbit_FactFinder
17
- * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
18
- * @author Michael Türk <tuerk@flagbit.de>
19
- * @version $Id: Processor.php 647 2011-03-21 10:32:14Z rudolf_batt $
20
*/
21
class Flagbit_FactFinder_Model_Observer
22
{
@@ -49,20 +50,68 @@ class Flagbit_FactFinder_Model_Observer
49
}
50
51
try {
52
- $facade = Mage::getModel('factfinder/facade');
53
- $facade->getScicAdapter()->setupCartTracking(
54
- $product->getData($idFieldName),
55
- md5(Mage::getSingleton('core/session')->getSessionId()),
56
- $qty,
57
- $product->getFinalPrice($qty),
58
- $customerId);
59
- $facade->applyTracking();
60
}
61
catch (Exception $e) {
62
Mage::helper('factfinder/debug')->log($e->getMessage());
63
}
64
}
65
66
67
/**
68
* Observer method
@@ -129,14 +178,22 @@ class Flagbit_FactFinder_Model_Observer
129
$facade->setStoreId($item->getStoreId());
130
$storeId = $item->getStoreId();
131
}
132
- $facade->getScicAdapter()->setupCheckoutTracking(
133
- $item->getProductId(),
134
- $item->getSid(),
135
- $item->getCount(),
136
- $item->getPrice(),
137
- $item->getUserid());
138
139
- $facade->applyTracking();
140
141
$item->delete($item);
142
}
@@ -220,12 +277,12 @@ class Flagbit_FactFinder_Model_Observer
220
$matches = array();
221
$label = preg_quote(Mage::helper('factfinder')->__('FACT-Finder Business User Cockpit'));
222
$pattern = '/(\<a[^\>]*href=\"([^\"]*)\"[^\>]*)\>\w*\<span\>\w*' . $label . '\w*\<\/span\>/msU';
223
- preg_match($pattern, $html, $matches);
224
-
225
- $url = Mage::getSingleton('factfinder/facade')->getManagementUrl();
226
- $replace = str_replace($matches[2], $url, $matches[1]) . ' target="_blank"';
227
-
228
- $transport->setHtml(str_replace($matches[1], $replace, $html));
229
}
230
231
/**
@@ -253,11 +310,7 @@ class Flagbit_FactFinder_Model_Observer
253
$update->addHandle('factfinder_suggest_version_gt68');
254
}
255
}
256
- if (Mage::helper('factfinder/search')->getIsEnabled(false, 'advisory')) {
257
- $layout = $observer->getLayout();
258
- $update = $layout->getUpdate();
259
- $update->addHandle('factfinder_advisory_enabled');
260
- }
261
$request = Mage::app()->getRequest();
262
//catalogsearch_result_index
263
if (Mage::helper('factfinder/search')->getIsEnabled(false, 'clicktracking')
@@ -270,30 +323,49 @@ class Flagbit_FactFinder_Model_Observer
270
}
271
}
272
273
/**
274
* Checks if the result set's size is one. If so the user is redirected to the product detail page. This is checked
275
- * right before the first block is rendered so headers can still be sent. The ordinary collection load event is
276
* triggered too late.
277
- *
278
- * @param Varien_Event_Observer $observer
279
*/
280
- public function redirectToProductIfSingleResult($observer)
281
{
282
if (!Mage::helper('factfinder/search')->getIsEnabled() || !Mage::helper('factfinder/search')->getIsOnSearchPage() || Mage::registry('redirectAlreadyChecked')) {
283
return;
284
}
285
-
286
Mage::register('redirectAlreadyChecked', 1);
287
if (Mage::getStoreConfig('factfinder/config/redirectOnSingleResult')) {
288
$block = Mage::app()->getLayout()->getBlock('search_result_list');
289
-
290
if (!$block instanceof Mage_Catalog_Block_Product_List) {
291
return;
292
}
293
-
294
$collection = $block->getLoadedProductCollection();
295
$collection->load();
296
-
297
if (count($collection) == 1) {
298
$product = $collection->getFirstItem();
299
@@ -305,53 +377,13 @@ class Flagbit_FactFinder_Model_Observer
305
exit;
306
}
307
}
308
-
309
- $response = Mage::app()->getResponse();
310
- $response->setHeader('Expires', gmdate("D, d M Y H:i:s", time() + 600), true);
311
- $response->setHeader('Cache-Control', 'public, max-age=600, must-revalidate', true);
312
- $response->setHeader('Pragma', null, true);
313
- }
314
-
315
- protected function sendClickTrackingForSingleProduct($product)
316
- {
317
- $searchHelper = Mage::helper('factfinder/search');
318
-
319
- if (!$searchHelper->getIsEnabled(false, 'clicktracking')) {
320
- return;
321
- }
322
-
323
- try {
324
- $idFieldName = $searchHelper->getIdFieldName();
325
-
326
- $facade = Mage::getModel('factfinder/facade');
327
- $facade->getScicAdapter()->setupClickTracking(
328
- $product->getData($idFieldName),
329
- md5(Mage::getSingleton('core/session')->getSessionId()),
330
- $searchHelper->getQuery()->getQueryText(),
331
- 1, //pos
332
- 1, //origPos
333
- 1, //page
334
- $product->getSimilarity,
335
- $product->getName(),
336
- $searchHelper->getPageLimit(),
337
- $searchHelper->getDefaultPerPageValue());
338
- $facade->applyTracking();
339
- }
340
- catch (Exception $e) {
341
- Mage::helper('factfinder/debug')->log($e->getMessage());
342
- }
343
- }
344
-
345
- public function initializeAfterSearchNavigation()
346
- {
347
- $asnBlock = Mage::registry(self::_asnBlockRegistryKey);
348
- if($asnBlock instanceof Flagbit_FactFinder_Block_Layer)
349
- {
350
- $asnBlock->initializeAfterSearchNavigation();
351
- }
352
}
353
354
- public function handleCampaignRedirect()
355
{
356
$redirectBlock = Mage::registry(self::_campaignRedirectRegistryKey);
357
if($redirectBlock instanceof Flagbit_FactFinder_Block_Layer)
14
*
15
* @category Mage
16
* @package Flagbit_FactFinder
17
+ * @copyright Copyright (c) 2013 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
18
+ * @author Michael Türk <michael.tuerk@flagbit.de>
19
+ * @author Nicolai Essig <nicolai.essig@flagbit.de>
20
+ * @version $Id: Observer.php 26.08.13 15:05 $
21
*/
22
class Flagbit_FactFinder_Model_Observer
23
{
50
}
51
52
try {
53
+ /* @var $tracking Flagbit_FactFinder_Model_Handler_Tracking */
54
+ $tracking = Mage::getModel('factfinder/handler_tracking');
55
+ $tracking->getTrackingAdapter()->setupEventTracking(
56
+ FACTFinder_Default_TrackingAdapter::EVENT_CART,
57
+ array(
58
+ 'id' => $product->getData($idFieldName),
59
+ 'sid' => md5(Mage::getSingleton('core/session')->getSessionId()),
60
+ 'amount' => $qty,
61
+ 'price' => $product->getFinalPrice($qty),
62
+ 'uid' => $customerId,
63
+ 'site' => Mage::app()->getStore()->getCode(),
64
+ 'sourceRefKey' => Mage::getSingleton('core/session')->getFactFinderRefKey()
65
+ )
66
+ );
67
+ $tracking->applyTracking();
68
}
69
catch (Exception $e) {
70
Mage::helper('factfinder/debug')->log($e->getMessage());
71
}
72
}
73
74
+ /**
75
+ * Tracking of single product click
76
+ *
77
+ * @param $product
78
+ */
79
+ protected function sendClickTrackingForSingleProduct($product)
80
+ {
81
+ $searchHelper = Mage::helper('factfinder/search');
82
+
83
+ if (!$searchHelper->getIsEnabled(false, 'clicktracking')) {
84
+ return;
85
+ }
86
+
87
+ try {
88
+ $idFieldName = $searchHelper->getIdFieldName();
89
+
90
+ $customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
91
+ if ($customerId) {
92
+ $customerId = md5('customer_' . $customerId);
93
+ }
94
+
95
+ /* @var $tracking Flagbit_FactFinder_Model_Handler_Tracking */
96
+ $tracking = Mage::getModel('factfinder/handler_tracking');
97
+ $tracking->getTrackingAdapter()->setupEventTracking(
98
+ FACTFinder_Default_TrackingAdapter::EVENT_INSPECT,
99
+ array(
100
+ 'id' => $product->getData($idFieldName),
101
+ 'sid' => md5(Mage::getSingleton('core/session')->getSessionId()),
102
+ 'price' => $product->getFinalPrice(),
103
+ 'uid' => $customerId,
104
+ 'site' => Mage::app()->getStore()->getCode(),
105
+ 'sourceRefKey' => Mage::getSingleton('core/session')->getFactFinderRefKey(),
106
+ 'product' => $product
107
+ )
108
+ );
109
+ $tracking->applyTracking();
110
+ }
111
+ catch (Exception $e) {
112
+ Mage::helper('factfinder/debug')->log($e->getMessage());
113
+ }
114
+ }
115
116
/**
117
* Observer method
178
$facade->setStoreId($item->getStoreId());
179
$storeId = $item->getStoreId();
180
}
181
182
+ /* @var $tracking Flagbit_FactFinder_Model_Handler_Tracking */
183
+ $tracking = Mage::getModel('factfinder/handler_tracking');
184
+ $tracking->getTrackingAdapter()->setupEventTracking(
185
+ FACTFinder_Default_TrackingAdapter::EVENT_BUY,
186
+ array(
187
+ 'id' => $item->getProductId(),
188
+ 'sid' => $item->getSid(),
189
+ 'amount' => $item->getCount(),
190
+ 'price' => $item->getPrice(),
191
+ 'uid' => md5('customer_' . $item->getUserid()),
192
+ 'site' => Mage::app()->getStore($storeId)->getCode(),
193
+ 'sourceRefKey' => ''
194
+ )
195
+ );
196
+ $tracking->applyTracking();
197
198
$item->delete($item);
199
}
277
$matches = array();
278
$label = preg_quote(Mage::helper('factfinder')->__('FACT-Finder Business User Cockpit'));
279
$pattern = '/(\<a[^\>]*href=\"([^\"]*)\"[^\>]*)\>\w*\<span\>\w*' . $label . '\w*\<\/span\>/msU';
280
+ if (preg_match($pattern, $html, $matches)) {
281
+ $url = Mage::getSingleton('factfinder/facade')->getManagementUrl();
282
+ $replace = str_replace($matches[2], $url, $matches[1]) . ' target="_blank"';
283
+
284
+ $transport->setHtml(str_replace($matches[1], $replace, $html));
285
+ }
286
}
287
288
/**
310
$update->addHandle('factfinder_suggest_version_gt68');
311
}
312
}
313
+
314
$request = Mage::app()->getRequest();
315
//catalogsearch_result_index
316
if (Mage::helper('factfinder/search')->getIsEnabled(false, 'clicktracking')
323
}
324
}
325
326
+ public function initializeAfterSearchNavigation()
327
+ {
328
+ $asnBlock = Mage::registry(self::_asnBlockRegistryKey);
329
+ if($asnBlock instanceof Flagbit_FactFinder_Block_Layer)
330
+ {
331
+ $asnBlock->initializeAfterSearchNavigation();
332
+ }
333
+ }
334
+
335
+ /**
336
+ * Handle redirects in this single method to control the execution order.
337
+ *
338
+ * @param Varien_Event_Observer $observer
339
+ */
340
+ public function handleRedirects(Varien_Event_Observer $observer)
341
+ {
342
+ $this->_handleCampaignRedirect();
343
+ $this->_redirectToProductIfSingleResult();
344
+ }
345
+
346
/**
347
* Checks if the result set's size is one. If so the user is redirected to the product detail page. This is checked
348
+ * right before the first block is rendered so headers can still be sent. The ordinary collection load event is
349
* triggered too late.
350
+ *
351
*/
352
+ protected function _redirectToProductIfSingleResult()
353
{
354
if (!Mage::helper('factfinder/search')->getIsEnabled() || !Mage::helper('factfinder/search')->getIsOnSearchPage() || Mage::registry('redirectAlreadyChecked')) {
355
return;
356
}
357
+
358
Mage::register('redirectAlreadyChecked', 1);
359
if (Mage::getStoreConfig('factfinder/config/redirectOnSingleResult')) {
360
$block = Mage::app()->getLayout()->getBlock('search_result_list');
361
+
362
if (!$block instanceof Mage_Catalog_Block_Product_List) {
363
return;
364
}
365
+
366
$collection = $block->getLoadedProductCollection();
367
$collection->load();
368
+
369
if (count($collection) == 1) {
370
$product = $collection->getFirstItem();
371
377
exit;
378
}
379
}
380
}
381
382
+ /**
383
+ * Handle campaign redirects
384
+ *
385
+ */
386
+ protected function _handleCampaignRedirect()
387
{
388
$redirectBlock = Mage::registry(self::_campaignRedirectRegistryKey);
389
if($redirectBlock instanceof Flagbit_FactFinder_Block_Layer)
app/code/community/Flagbit/FactFinder/Model/Processor.php CHANGED
@@ -138,6 +138,11 @@ class Flagbit_FactFinder_Model_Processor
138
return $this->_getFacade()->applyTracking();
139
break;
140
141
case 'factfinder_proxy_suggest':
142
$handler = new Flagbit_FactFinder_Model_Handler_Suggest(
143
$this->_getRequestParam('query'),
138
return $this->_getFacade()->applyTracking();
139
break;
140
141
+ case 'factfinder_proxy_tracking':
142
+ $this->_getFacade()->getTrackingAdapter()->setupTrackingFromRequest();
143
+ return $this->_getFacade()->applyTracking();
144
+ break;
145
+
146
case 'factfinder_proxy_suggest':
147
$handler = new Flagbit_FactFinder_Model_Handler_Suggest(
148
$this->_getRequestParam('query'),
app/code/community/Flagbit/FactFinder/Model/System/Config/Source/Ffversion.php CHANGED
@@ -28,6 +28,10 @@ class Flagbit_FactFinder_Model_System_Config_Source_Ffversion
28
public function toOptionArray()
29
{
30
return array(
31
array(
32
'value' => 68,
33
'label' => '6.8'
28
public function toOptionArray()
29
{
30
return array(
31
+ array(
32
+ 'value' => 69,
33
+ 'label' => '6.9'
34
+ ),
35
array(
36
'value' => 68,
37
'label' => '6.8'
app/code/community/Flagbit/FactFinder/controllers/ProxyController.php CHANGED
@@ -20,19 +20,25 @@
20
* @version $Id$
21
*/
22
class Flagbit_FactFinder_ProxyController extends Mage_Core_Controller_Front_Action {
23
-
24
/**
25
* scic Action
26
*/
27
public function scicAction()
28
{
29
- $this->getResponse()->setBody(
30
- Mage::getModel('factfinder/processor')->handleInAppRequest($this->getFullActionName())
31
- );
32
}
33
-
34
-
35
-
36
/**
37
* suggest Action
38
*/
20
* @version $Id$
21
*/
22
class Flagbit_FactFinder_ProxyController extends Mage_Core_Controller_Front_Action {
23
+
24
+ /**
25
+ * tracking Action
26
+ */
27
+ public function trackingAction()
28
+ {
29
+ $this->getResponse()->setBody(
30
+ Mage::getModel('factfinder/processor')->handleInAppRequest($this->getFullActionName())
31
+ );
32
+ }
33
+
34
/**
35
* scic Action
36
*/
37
public function scicAction()
38
{
39
+ $this->trackingAction();
40
}
41
+
42
/**
43
* suggest Action
44
*/
app/code/community/Flagbit/FactFinder/etc/config.xml CHANGED
@@ -22,7 +22,7 @@
22
<modules>
23
<Flagbit_FactFinder>
24
<active>true</active>
25
- <version>3.4.8</version>
26
</Flagbit_FactFinder>
27
</modules>
28
<global>
@@ -111,6 +111,15 @@
111
</observers>
112
</controller_action_predispatch_adminhtml_system_config_save>
113
</events>
114
</global>
115
<frontend>
116
<layout>
@@ -156,18 +165,14 @@
156
</controller_action_layout_load_before>
157
<controller_action_layout_generate_blocks_after>
158
<observers>
159
- <handleCampaignRedirect>
160
- <class>factfinder/observer</class>
161
- <method>handleCampaignRedirect</method>
162
- </handleCampaignRedirect>
163
<initializeAfterSearchNavigation>
164
<class>factfinder/observer</class>
165
<method>initializeAfterSearchNavigation</method>
166
</initializeAfterSearchNavigation>
167
- <redirectToProductIfSingleResult>
168
<class>factfinder/observer</class>
169
- <method>redirectToProductIfSingleResult</method>
170
- </redirectToProductIfSingleResult>
171
</observers>
172
</controller_action_layout_generate_blocks_after>
173
</events>
@@ -254,26 +259,26 @@
254
</search>
255
</catalog>
256
<factfinder>
257
- <version>3.4.8</version>
258
<revision>$Rev: 25896 lt;/revision>
259
- <debug>true</debug>
260
261
<!-- search settings: WARNING: dont change settings here, please use the Magento backoffice ...
262
if you still have to change something here, dont forget to clear the configuration cache -->
263
<search>
264
- <address>magento.fact-finder.de</address>
265
- <port>8080</port>
266
<protocol>http</protocol> <!-- possible values: http, https -->
267
268
- <ffversion>66</ffversion>
269
270
- <auth_user>client</auth_user>
271
<auth_password></auth_password>
272
<auth_type>advanced</auth_type> <!-- possible values: http (for FF <= 6.4); simple | advanced (for FF >= 6.5)-->
273
<auth_advancedPrefix>FACT-FINDER</auth_advancedPrefix>
274
<auth_advancedPostfix>FACT-FINDER</auth_advancedPostfix>
275
276
- <context>MagentoSearch65</context>
277
<channel></channel>
278
<language></language>
279
</search>
22
<modules>
23
<Flagbit_FactFinder>
24
<active>true</active>
25
+ <version>3.5.1</version>
26
</Flagbit_FactFinder>
27
</modules>
28
<global>
111
</observers>
112
</controller_action_predispatch_adminhtml_system_config_save>
113
</events>
114
+ <cache>
115
+ <types>
116
+ <factfinder_search translate="label,description" module="factfinder">
117
+ <label>FACT-Finder</label>
118
+ <description>Search Request Cache</description>
119
+ <tags>FACTFINDER_SEARCH</tags>
120
+ </factfinder_search>
121
+ </types>
122
+ </cache>
123
</global>
124
<frontend>
125
<layout>
165
</controller_action_layout_load_before>
166
<controller_action_layout_generate_blocks_after>
167
<observers>
168
<initializeAfterSearchNavigation>
169
<class>factfinder/observer</class>
170
<method>initializeAfterSearchNavigation</method>
171
</initializeAfterSearchNavigation>
172
+ <handleRedirects>
173
<class>factfinder/observer</class>
174
+ <method>handleRedirects</method>
175
+ </handleRedirects>
176
</observers>
177
</controller_action_layout_generate_blocks_after>
178
</events>
259
</search>
260
</catalog>
261
<factfinder>
262
+ <version>3.5.1</version>
263
<revision>$Rev: 25896 lt;/revision>
264
+ <debug>false</debug>
265
266
<!-- search settings: WARNING: dont change settings here, please use the Magento backoffice ...
267
if you still have to change something here, dont forget to clear the configuration cache -->
268
<search>
269
+ <address>example.com</address>
270
+ <port>80</port>
271
<protocol>http</protocol> <!-- possible values: http, https -->
272
273
+ <ffversion>68</ffversion>
274
275
+ <auth_user></auth_user>
276
<auth_password></auth_password>
277
<auth_type>advanced</auth_type> <!-- possible values: http (for FF <= 6.4); simple | advanced (for FF >= 6.5)-->
278
<auth_advancedPrefix>FACT-FINDER</auth_advancedPrefix>
279
<auth_advancedPostfix>FACT-FINDER</auth_advancedPostfix>
280
281
+ <context></context>
282
<channel></channel>
283
<language></language>
284
</search>
app/design/frontend/base/default/layout/factfinder.xml CHANGED
@@ -69,10 +69,10 @@
69
70
<factfinder_clicktracking_enabled>
71
<reference name="head">
72
- <action method="addJs"><script>factfinder/scic.js</script></action>
73
</reference>
74
<reference name="content">
75
- <block type="factfinder/scic" name="factfinder.scic" template="factfinder/scic.phtml"/>
76
</reference>
77
</factfinder_clicktracking_enabled>
78
</layout>
69
70
<factfinder_clicktracking_enabled>
71
<reference name="head">
72
+ <action method="addJs"><script>factfinder/tracking.js</script></action>
73
</reference>
74
<reference name="content">
75
+ <block type="factfinder/tracking" name="factfinder.tracking" template="factfinder/tracking.phtml"/>
76
</reference>
77
</factfinder_clicktracking_enabled>
78
</layout>
app/design/frontend/base/default/template/factfinder/form.advancedsuggest68.phtml CHANGED
@@ -49,8 +49,16 @@
49
return i18n[string];
50
}
51
52
- console.log(data);
53
-
54
var content = '<ul>';
55
content += '<li style="display: none" class="selected selectable-item"></li>';
56
var currentChannel = '';
49
return i18n[string];
50
}
51
52
+ // Try to get channel from search request, if no channel was found
53
+ for(var i = 0; i < data.length; i++) {
54
+ if(typeof(data[i].channel) == 'undefined' || data[i].channel == '') {
55
+ var params = data[i].searchParams.toQueryParams();
56
+ if(typeof(params.channel) != 'undefined') {
57
+ data[i].channel = params.channel;
58
+ }
59
+ }
60
+ }
61
+
62
var content = '<ul>';
63
content += '<li style="display: none" class="selected selectable-item"></li>';
64
var currentChannel = '';
app/design/frontend/base/default/template/factfinder/{scic.phtml → tracking.phtml} RENAMED
@@ -4,29 +4,30 @@
4
*
5
* @category Mage
6
* @package Flagbit_FactFinder
7
- * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
8
*/
9
10
/**
11
- * Add FACT-Finder SCIC
12
*
13
* @category Mage
14
* @package Flagbit_FactFinder
15
- * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
16
* @author Joerg Weller <weller@flagbit.de>
17
* @version $Id$
18
*/
19
?>
20
<script type="text/javascript">
21
- var factfinderSCIC = new FactfinderSCIC(
22
'.col-main',
23
$H(<?php echo $this->getJsonDataObject();?>),
24
$H(<?php echo $this->getJsonUrlToIdMappingObject();?>),
25
- '<?php echo $this->getUrl('factfinder/proxy/scic'); ?>',
26
false
27
);
28
29
Event.observe(document, 'dom:loaded', function(event) {
30
- factfinderSCIC.init();
31
});
32
</script>
4
*
5
* @category Mage
6
* @package Flagbit_FactFinder
7
+ * @copyright Copyright (c) 2013 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
8
*/
9
10
/**
11
+ * Add FACT-Finder Tracking
12
*
13
* @category Mage
14
* @package Flagbit_FactFinder
15
+ * @copyright Copyright (c) 2013 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
16
* @author Joerg Weller <weller@flagbit.de>
17
+ * @author Nicolai Essig <nicolai.essig@flagbit.de>
18
* @version $Id$
19
*/
20
?>
21
<script type="text/javascript">
22
+ var factfinderTracking = new FactfinderTracking(
23
'.col-main',
24
$H(<?php echo $this->getJsonDataObject();?>),
25
$H(<?php echo $this->getJsonUrlToIdMappingObject();?>),
26
+ '<?php echo (Mage::helper('factfinder')->useOldTracking() ? $this->getUrl('factfinder/proxy/scic') : $this->getUrl('factfinder/proxy/tracking')) ?>',
27
false
28
);
29
30
Event.observe(document, 'dom:loaded', function(event) {
31
+ factfinderTracking.init();
32
});
33
</script>
app/locale/de_DE/Flagbit_FactFinder.csv CHANGED
@@ -86,4 +86,5 @@
86
"User name", "Benutzername"
87
"User name for authentication", "Benutzername für Authentifizierung"
88
"Yes", "Ja"
89
- "Your server's clock does not agree with FACT-Finder's. Please make sure your clock is set correctly.", "Ihre Serverzeit stimmt nicht mit der von FACT-Finder überein. Bitte stellen Sie sicher, dass Ihre Serverzeit korrekt eingestellt ist."
86
"User name", "Benutzername"
87
"User name for authentication", "Benutzername für Authentifizierung"
88
"Yes", "Ja"
89
+ "Your server's clock does not agree with FACT-Finder's. Please make sure your clock is set correctly.", "Ihre Serverzeit stimmt nicht mit der von FACT-Finder überein. Bitte stellen Sie sicher, dass Ihre Serverzeit korrekt eingestellt ist."
90
+ "Search Request Cache","Suchanfragen Cache"
js/factfinder/{scic.js → tracking.js} RENAMED
@@ -1,4 +1,4 @@
1
- var FactfinderSCIC = Class.create({
2
url: null,
3
data: null,
4
classname: null,
@@ -51,8 +51,7 @@ var FactfinderSCIC = Class.create({
51
recordRequest: function(id, eventType) {
52
53
var data = this.data.get(id);
54
- data.event = eventType;
55
-
56
this.request = new Ajax.Request(this.url, {
57
asynchronous: this.asynchronous,
58
method: 'post',
1
+ var FactfinderTracking = Class.create({
2
url: null,
3
data: null,
4
classname: null,
51
recordRequest: function(id, eventType) {
52
53
var data = this.data.get(id);
54
+
55
this.request = new Ajax.Request(this.url, {
56
asynchronous: this.asynchronous,
57
method: 'post',
lib/FACTFinder/Abstract/Adapter.php CHANGED
@@ -58,15 +58,11 @@ abstract class FACTFinder_Abstract_Adapter
58
}
59
60
/**
61
- * returns the data lazily. if it isn't available yet, it will be requested from the dataprovider.
62
* decorates the dataprovider::getData method so a inheriting class does not have to use the dataprovider
63
*/
64
protected function getData()
65
{
66
- if(!isset($this->data)) {
67
- $this->data = $this->getDataProvider()->getData();
68
- }
69
- return $this->data;
70
}
71
72
protected function reloadData()
58
}
59
60
/**
61
* decorates the dataprovider::getData method so a inheriting class does not have to use the dataprovider
62
*/
63
protected function getData()
64
{
65
+ return $this->getDataProvider()->getData();
66
}
67
68
protected function reloadData()
lib/FACTFinder/AsnSliderFilter.php CHANGED
@@ -101,6 +101,14 @@ class FACTFinder_AsnSliderFilter
101
return $this->baseUrl;
102
}
103
104
/**
105
* returns true if the selected range is not the same as the absolute range
106
*
101
return $this->baseUrl;
102
}
103
104
+ /**
105
+ * Allows to overwrite the base url.
106
+ * @param $url string new url
107
+ */
108
+ public function setBaseUrl($url) {
109
+ $this->baseUrl = $url;
110
+ }
111
+
112
/**
113
* returns true if the selected range is not the same as the absolute range
114
*
lib/FACTFinder/Default/CompareAdapter.php CHANGED
@@ -1,18 +1,6 @@
1
<?php
2
- /**
3
- * FACT-Finder PHP Framework
4
- *
5
- * @category Library
6
- * @package FACTFinder\Xml67
7
- * @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
8
- */
9
-
10
/**
11
* product comparison adapter using the xml interface
12
- *
13
- * @author Rudolf Batt <rb@omikron.net>
14
- * @version $Id: CompareAdapter.php 25893 2010-06-29 08:19:43Z rb $
15
- * @package FACTFinder\Xml68
16
*/
17
class FACTFinder_Default_CompareAdapter extends FACTFinder_Abstract_Adapter
18
{protected $productIds = array();
1
<?php
2
/**
3
* product comparison adapter using the xml interface
4
*/
5
class FACTFinder_Default_CompareAdapter extends FACTFinder_Abstract_Adapter
6
{protected $productIds = array();
lib/FACTFinder/Default/RecommendationAdapter.php CHANGED
@@ -69,7 +69,7 @@ class FACTFinder_Default_RecommendationAdapter extends FACTFinder_Abstract_Adapt
69
70
public function setIdsOnly($idsOnly) {
71
// Reset the recommendations, if more detail is wanted than before
72
- if($this->idsOnly && !$idsOnly) $recommendationUpToDate = false;
73
$this->idsOnly = $idsOnly;
74
$this->getDataProvider()->setParam('idsOnly', $idsOnly ? 'true' : 'false');
75
}
@@ -90,7 +90,7 @@ class FACTFinder_Default_RecommendationAdapter extends FACTFinder_Abstract_Adapt
90
$this->productIds = array($requestParams['id']);
91
}
92
if (empty($this->productIds)) {
93
- trigger_error('recommendations can not be loaded without id. could not load id from request', E_USER_WARNING);
94
return array();
95
}
96
}
69
70
public function setIdsOnly($idsOnly) {
71
// Reset the recommendations, if more detail is wanted than before
72
+ if($this->idsOnly && !$idsOnly) $this->recommendationUpToDate = false;
73
$this->idsOnly = $idsOnly;
74
$this->getDataProvider()->setParam('idsOnly', $idsOnly ? 'true' : 'false');
75
}
90
$this->productIds = array($requestParams['id']);
91
}
92
if (empty($this->productIds)) {
93
+ trigger_error('Recommendations cannot be loaded without id. Could not load id from request.', E_USER_WARNING);
94
return array();
95
}
96
}
lib/FACTFinder/Default/SimilarRecordsAdapter.php CHANGED
@@ -70,7 +70,7 @@ class FACTFinder_Default_SimilarRecordsAdapter extends FACTFinder_Abstract_Adapt
70
/**
71
* returns similar attributes for previously specified id. if no id is set, try to fetch parameter 'id'.
72
* if no id is available, there will be a warning raised and returning an empty array
73
-
74
* @return array $similarAttributes of strings (field names as keys)
75
*/
76
public function getSimilarAttributes() {
70
/**
71
* returns similar attributes for previously specified id. if no id is set, try to fetch parameter 'id'.
72
* if no id is available, there will be a warning raised and returning an empty array
73
+ *
74
* @return array $similarAttributes of strings (field names as keys)
75
*/
76
public function getSimilarAttributes() {
lib/FACTFinder/Default/TagCloudAdapter.php CHANGED
@@ -30,6 +30,19 @@ class FACTFinder_Default_TagCloudAdapter extends FACTFinder_Abstract_Adapter
30
return $this->tagCloud;
31
}
32
33
/**
34
* @return array $tagCloud list of FACTFinder_Tag objects
35
*/
30
return $this->tagCloud;
31
}
32
33
+ /**
34
+ * with this method a different wordcount can be set. default from FF is 30.
35
+ *
36
+ * @param int word count
37
+ */
38
+ public function setWordCount($wordCount) {
39
+ // set maximum results for tagcloud
40
+ if( !empty( $wordCount ) && is_numeric( $wordCount ) )
41
+ {
42
+ $this->getDataProvider()->setParam('wordCount', $wordCount);
43
+ }
44
+ }
45
+
46
/**
47
* @return array $tagCloud list of FACTFinder_Tag objects
48
*/
lib/FACTFinder/Default/TrackingAdapter.php ADDED
@@ -0,0 +1,103 @@
1
+ <?php
2
+ /**
3
+ * Tracking adapter using the new tracking API introduced with FF 6.9.
4
+ */
5
+ class FACTFinder_Default_TrackingAdapter extends FACTFinder_Abstract_Adapter
6
+ {
7
+ // A result (product, banner, ASN element, ...) referenced by the key has been displayed.
8
+ const EVENT_DISPLAY = 'display';
9
+ // Visitor has given feedback about a ResultNode. Reference Key is optional.
10
+ const EVENT_FEEDBACK = 'feedback';
11
+ // The user clicked on a product / detail view.
12
+ const EVENT_INSPECT = 'inspect';
13
+ // The user checked the availability of a product.
14
+ const EVENT_AVAILABILITY_CHECK = 'availabilityCheck';
15
+ // The user added an item to the cart.
16
+ const EVENT_CART = 'cart';
17
+ // The user bought or booked a product or service.
18
+ const EVENT_BUY = 'buy';
19
+ // A request of the user could be answered from the shop cache.
20
+ const EVENT_CACHE_HIT = 'cacheHit';
21
+ // A new session has been created for a user.
22
+ const EVENT_SESSION_START = 'sessionStart';
23
+
24
+ /**
25
+ * let the data provider save the tracking params
26
+ *
27
+ * @return boolean $success
28
+ */
29
+ public function applyTracking()
30
+ {
31
+ $this->log->debug("Tracking not available before FF 6.9!");
32
+ return false;
33
+ }
34
+
35
+ public function prepareDefaultParams($inputParams, $event) {
36
+ $eventsNoSourceRefKeyRequired = array(
37
+ self::EVENT_INSPECT,
38
+ self::EVENT_CART,
39
+ self::EVENT_BUY,
40
+ self::EVENT_SESSION_START
41
+ );
42
+
43
+ $sid = $inputParams['sid'];
44
+ if (strlen($sid) == 0)
45
+ $sid = session_id();
46
+
47
+ $sourceRefKey = $inputParams['sourceRefKey'];
48
+ if (!in_array($event, $eventsNoSourceRefKeyRequired, true) && strlen($sourceRefKey) == 0)
49
+ throw new UnexpectedValueException("No sourceRefKey in parameters");
50
+
51
+ $params = array('sourceRefKey' => $sourceRefKey, 'sid' => $sid);
52
+
53
+ $optParams = array('uid', 'cookieId', 'price', 'amount', 'positive', 'message', 'site', 'id', 'mid');
54
+ foreach ($optParams AS $optParam) {
55
+ if (isset($inputParams[$optParam]) && strlen($inputParams[$optParam]) > 0)
56
+ $params[$optParam] = $inputParams[$optParam];
57
+ }
58
+
59
+ return $params;
60
+ }
61
+
62
+ public function doTrackingFromRequest()
63
+ {
64
+ $this->setupTrackingFromRequest();
65
+ return $this->applyTracking();
66
+ }
67
+
68
+ public function setupTrackingFromRequest()
69
+ {
70
+ $params = $this->getParamsParser()->getServerRequestParams();
71
+ $this->getDataProvider()->setParams($params);
72
+ }
73
+
74
+ public function trackEvent($event, $inputParams)
75
+ {
76
+ $this->setupEventTracking($event, $inputParams);
77
+ return $this->applyTracking();
78
+ }
79
+
80
+ public function setupEventTracking($event, $inputParams)
81
+ {
82
+ $params = $this->prepareDefaultParams($inputParams, $event);
83
+
84
+ $events = array(
85
+ self::EVENT_DISPLAY,
86
+ self::EVENT_FEEDBACK,
87
+ self::EVENT_INSPECT,
88
+ self::EVENT_AVAILABILITY_CHECK,
89
+ self::EVENT_CART,
90
+ self::EVENT_BUY,
91
+ self::EVENT_CACHE_HIT,
92
+ self::EVENT_SESSION_START
93
+ );
94
+
95
+ if (!in_array($event, $events, true)) {
96
+ throw new UnexpectedValueException("Event $event not known.");
97
+ }
98
+
99
+ $params['event'] = $event;
100
+
101
+ $this->getDataProvider()->setParams($params);
102
+ }
103
+ }
lib/FACTFinder/Http/DummyProvider.php CHANGED
@@ -1,32 +1,26 @@
1
<?php
2
/**
3
- * FACT-Finder PHP Framework
4
- *
5
- * @category Library
6
- * @package FACTFinder\Http
7
- * @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
8
- */
9
-
10
- /**
11
- * this data provider loads the data from local static xml files
12
* it is only intended to be used for testing
13
- *
14
- * @author Rudolf Batt <rb@omikron.net>, Martin Buettner <martin.buettner@omikron.net>
15
- * @version $Id: DummyProvider.php 44086 2012-02-29 17:19:43Z martin.buettner $
16
- * @package FACTFinder\Http
17
*/
18
class FACTFinder_Http_DummyProvider extends FACTFinder_Abstract_DataProvider
19
{
20
protected $data;
21
protected $previousFileName;
22
-
23
- protected $fileLocation;
24
25
public function setFileLocation($loc)
26
{
27
$this->fileLocation = substr($loc, -1) == DS ? $loc : $loc.DS;
28
}
29
30
/**
31
* we just offer this function, for compatibility with the DataProvider API
32
*
@@ -107,7 +101,7 @@ class FACTFinder_Http_DummyProvider extends FACTFinder_Abstract_DataProvider
107
108
ksort($params, SORT_STRING);
109
$fileName .= http_build_query($params, '', '_');
110
- $fileName .= ".xml";
111
112
// The following line removes all []-indices from array parameters, because tomcat doesn't need them
113
$fileName = preg_replace("/%5B[A-Za-z0-9]*%5D/", "", $fileName);
1
<?php
2
/**
3
+ * this data provider loads the data from local static files
4
* it is only intended to be used for testing
5
*/
6
class FACTFinder_Http_DummyProvider extends FACTFinder_Abstract_DataProvider
7
{
8
protected $data;
9
protected $previousFileName;
10
+
11
+ protected $fileLocation;
12
+ protected $fileExtension = ".xml";
13
14
public function setFileLocation($loc)
15
{
16
$this->fileLocation = substr($loc, -1) == DS ? $loc : $loc.DS;
17
}
18
19
+ public function setFileExtension($ext)
20
+ {
21
+ $this->fileExtension = $ext[0] == "." ? $ext : ".$ext";
22
+ }
23
+
24
/**
25
* we just offer this function, for compatibility with the DataProvider API
26
*
101
102
ksort($params, SORT_STRING);
103
$fileName .= http_build_query($params, '', '_');
104
+ $fileName .= $this->fileExtension;
105
106
// The following line removes all []-indices from array parameters, because tomcat doesn't need them
107
$fileName = preg_replace("/%5B[A-Za-z0-9]*%5D/", "", $fileName);
lib/FACTFinder/Http/TrackingAdapter.php ADDED
@@ -0,0 +1,31 @@
1
+ <?php
2
+ /**
3
+ * Tracking adapter using the new tracking API introduced with FF 6.9.
4
+ */
5
+ class FACTFinder_Http_TrackingAdapter extends FACTFinder_Default_TrackingAdapter
6
+ {
7
+ /**
8
+ * Set up the tracking adapter for 6.9.
9
+ */
10
+ protected function init()
11
+ {
12
+ $this->log->info("Initializing new Tracking adapter.");
13
+ $this->getDataProvider()->setType('Tracking.ff');
14
+ $this->getDataProvider()->setCurlOptions(array(
15
+ CURLOPT_CONNECTTIMEOUT => $this->getDataProvider()->getConfig()->getScicConnectTimeout(),
16
+ CURLOPT_TIMEOUT => $this->getDataProvider()->getConfig()->getScicTimeout()
17
+ ));
18
+ }
19
+
20
+ /**
21
+ * Trigger the actual tracking request.
22
+ *
23
+ * @return boolean $success
24
+ */
25
+ public function applyTracking()
26
+ {
27
+ // Is this even correct for the new interface?
28
+ $success = trim($this->getData());
29
+ return $success == 'The event was successfully tracked';
30
+ }
31
+ }
lib/FACTFinder/Item.php CHANGED
@@ -52,4 +52,12 @@ class FACTFinder_Item
52
public function isSelected() {
53
return $this->isSelected;
54
}
55
}
52
public function isSelected() {
53
return $this->isSelected;
54
}
55
+
56
+ /**
57
+ * Allows to override the URL of the item
58
+ * @param $url string new URL to set
59
+ */
60
+ public function setUrl($url) {
61
+ $this->url = $url;
62
+ }
63
}
lib/FACTFinder/Json66/CompareAdapter.php ADDED
@@ -0,0 +1,71 @@
1
+ <?php
2
+ class FACTFinder_Json66_CompareAdapter extends FACTFinder_Default_CompareAdapter
3
+ {
4
+ /**
5
+ * @return void
6
+ **/
7
+ public function init() {
8
+ $this->log->info("Initializing new compare adapter.");
9
+ $this->getDataProvider()->setParam('format', 'json');
10
+ $this->getDataProvider()->setType('Compare.ff');
11
+ }
12
+
13
+ /**
14
+ * try to parse data as json
15
+ *
16
+ * @throws Exception of data is no valid JSON
17
+ * @return stdClass
18
+ */
19
+ protected function getData()
20
+ {
21
+ $jsonData = json_decode(parent::getData(), true);
22
+ if ($jsonData === null)
23
+ throw new InvalidArgumentException("json_decode() raised error ".json_last_error());
24
+ return $jsonData;
25
+ }
26
+
27
+ /**
28
+ * @return array $comparableAttributes of strings (field names as keys, hasDifferences as values)
29
+ **/
30
+ protected function createComparableAttributes() {
31
+ $comparableAttributes = array();
32
+ $jsonData = $this->getData();
33
+ foreach($jsonData['attributes'] as $attributeData){
34
+ $name = $attributeData['attributeName'];
35
+ $comparableAttributes[$name] = $attributeData['different'];
36
+ }
37
+ return $comparableAttributes;
38
+ }
39
+
40
+ /**
41
+ * @return array $comparedRecords list of FACTFinder_Record items
42
+ **/
43
+ protected function createComparedRecords() {
44
+ $comparedRecords = array();
45
+ $jsonData = $this->getData();
46
+ if (!empty($jsonData['records'])) {
47
+ $encodingHandler = $this->getEncodingHandler();
48
+
49
+ if ($this->idsOnly && !$this->attributesUpToDate) {
50
+ $this->createComparableAttributes();
51
+ $this->attributesUpToDate = true;
52
+ }
53
+
54
+ $positionCounter = 1;
55
+ foreach ($jsonData['records'] AS $recordData){
56
+ // get current position
57
+ $position = $positionCounter;
58
+ $positionCounter++;
59
+
60
+ $comparedRecords[] = FF::getInstance('record',
61
+ $recordData['id'],
62
+ 100,
63
+ $position,
64
+ $position,
65
+ $this->getEncodingHandler()->encodeServerContentForPage($recordData['record'])
66
+ );
67
+ }
68
+ }
69
+ return $comparedRecords;
70
+ }
71
+ }
lib/FACTFinder/Json66/ImportAdapter.php ADDED
@@ -0,0 +1,74 @@
1
+ <?php
2
+ /**
3
+ * import adapter using the json interface
4
+ **/
5
+ class FACTFinder_Json66_ImportAdapter extends FACTFinder_Default_ImportAdapter
6
+ {
7
+ /**
8
+ * @return void
9
+ **/
10
+ public function init()
11
+ {
12
+ $this->log->info("Initializing new import adapter.");
13
+ $this->getDataProvider()->setParam('format', 'json');
14
+ }
15
+
16
+ /**
17
+ * try to parse data as json
18
+ *
19
+ * @throws Exception of data is no valid JSON
20