Flagbit_Factfinder - Version 3.3.6

Version Notes

bugfix: dont fail if products campaigns cant be loaded.
bugfix: dont use product campaigns, if campaigns are disabled.
task: show ff search form only if suggest is enabled
task: apply cluster level into attribute objects
task: flush output buffer for each bulk on product export

Download this release

Release Info

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


Version 3.3.6

Files changed (137) hide show
  1. app/code/community/Flagbit/FactFinder/Block/Adminhtml/Cockpit.php +33 -0
  2. app/code/community/Flagbit/FactFinder/Block/Adminhtml/Form/Field/Attribute.php +54 -0
  3. app/code/community/Flagbit/FactFinder/Block/Adminhtml/Form/Field/Attributes.php +85 -0
  4. app/code/community/Flagbit/FactFinder/Block/Campaign/Advisory.php +23 -0
  5. app/code/community/Flagbit/FactFinder/Block/Campaign/Cart/Advisory.php +56 -0
  6. app/code/community/Flagbit/FactFinder/Block/Campaign/Cart/Feedback.php +53 -0
  7. app/code/community/Flagbit/FactFinder/Block/Campaign/Feedback.php +62 -0
  8. app/code/community/Flagbit/FactFinder/Block/Campaign/Product/Advisory.php +42 -0
  9. app/code/community/Flagbit/FactFinder/Block/Campaign/Product/Feedback.php +42 -0
  10. app/code/community/Flagbit/FactFinder/Block/Cart/Crosssell.php +93 -0
  11. app/code/community/Flagbit/FactFinder/Block/Filter/Slider.php +36 -0
  12. app/code/community/Flagbit/FactFinder/Block/Layer.php +127 -0
  13. app/code/community/Flagbit/FactFinder/Block/Layer/Abstract.php +33 -0
  14. app/code/community/Flagbit/FactFinder/Block/Product/List/Crosssell.php +63 -0
  15. app/code/community/Flagbit/FactFinder/Block/Product/List/Upsell.php +115 -0
  16. app/code/community/Flagbit/FactFinder/Block/Scic.php +89 -0
  17. app/code/community/Flagbit/FactFinder/Block/TagCloud.php +44 -0
  18. app/code/community/Flagbit/FactFinder/Block/XmlConnect/Catalog/Product/List.php +124 -0
  19. app/code/community/Flagbit/FactFinder/Block/XmlConnect/Catalog/Search.php +123 -0
  20. app/code/community/Flagbit/FactFinder/Block/XmlConnect/Catalog/Search/Suggest.php +56 -0
  21. app/code/community/Flagbit/FactFinder/Helper/Backend.php +228 -0
  22. app/code/community/Flagbit/FactFinder/Helper/Data.php +36 -0
  23. app/code/community/Flagbit/FactFinder/Helper/Debug.php +125 -0
  24. app/code/community/Flagbit/FactFinder/Helper/Search.php +232 -0
  25. app/code/community/Flagbit/FactFinder/Model/Adapter.php +817 -0
  26. app/code/community/Flagbit/FactFinder/Model/Export/Price.php +91 -0
  27. app/code/community/Flagbit/FactFinder/Model/Export/Product.php +535 -0
  28. app/code/community/Flagbit/FactFinder/Model/Export/Stock.php +91 -0
  29. app/code/community/Flagbit/FactFinder/Model/Layer.php +83 -0
  30. app/code/community/Flagbit/FactFinder/Model/Layer/Abstract.php +7 -0
  31. app/code/community/Flagbit/FactFinder/Model/Layer/Filter/Attribute/Abstract.php +118 -0
  32. app/code/community/Flagbit/FactFinder/Model/Layer/Filter/Attribute/Catalog.php +25 -0
  33. app/code/community/Flagbit/FactFinder/Model/Layer/Filter/Attribute/Catalogsearch.php +35 -0
  34. app/code/community/Flagbit/FactFinder/Model/Layer/Filter/Item.php +23 -0
  35. app/code/community/Flagbit/FactFinder/Model/Mysql4/Campaign/Pushedproducts/Collection.php +148 -0
  36. app/code/community/Flagbit/FactFinder/Model/Mysql4/Product/Attribute/Collection.php +144 -0
  37. app/code/community/Flagbit/FactFinder/Model/Mysql4/Product/Recommendation/Collection.php +59 -0
  38. app/code/community/Flagbit/FactFinder/Model/Mysql4/Scic/Queue.php +31 -0
  39. app/code/community/Flagbit/FactFinder/Model/Mysql4/Scic/Queue/Collection.php +28 -0
  40. app/code/community/Flagbit/FactFinder/Model/Mysql4/Search/Collection.php +130 -0
  41. app/code/community/Flagbit/FactFinder/Model/Mysql4/Search/Engine.php +53 -0
  42. app/code/community/Flagbit/FactFinder/Model/Observer.php +281 -0
  43. app/code/community/Flagbit/FactFinder/Model/Processor.php +260 -0
  44. app/code/community/Flagbit/FactFinder/Model/Scic/Queue.php +27 -0
  45. app/code/community/Flagbit/FactFinder/Model/System/Config/Backend/Attributes.php +52 -0
  46. app/code/community/Flagbit/FactFinder/Model/System/Config/Backend/Enabled.php +57 -0
  47. app/code/community/Flagbit/FactFinder/Model/System/Config/Source/Authtype.php +45 -0
  48. app/code/community/Flagbit/FactFinder/Model/System/Config/Source/Identifier.php +41 -0
  49. app/code/community/Flagbit/FactFinder/controllers/Adminhtml/Factfinder/CockpitController.php +53 -0
  50. app/code/community/Flagbit/FactFinder/controllers/ExportController.php +89 -0
  51. app/code/community/Flagbit/FactFinder/controllers/ProxyController.php +46 -0
  52. app/code/community/Flagbit/FactFinder/documentation/Installation_FACT-Finder_Magento_de.pdf +0 -0
  53. app/code/community/Flagbit/FactFinder/documentation/Installation_FACT-Finder_Magento_en.pdf +0 -0
  54. app/code/community/Flagbit/FactFinder/etc/adminhtml.xml +49 -0
  55. app/code/community/Flagbit/FactFinder/etc/config.xml +292 -0
  56. app/code/community/Flagbit/FactFinder/etc/system.xml +323 -0
  57. app/code/community/Flagbit/FactFinder/sql/factfinder_setup/mysql4-install-3.2.0.php +38 -0
  58. app/code/community/Flagbit/FactFinder/sql/factfinder_setup/mysql4-upgrade-3.2.0-3.2.1.php +30 -0
  59. app/code/community/Flagbit/FactFinder/sql/factfinder_setup/mysql4-upgrade-3.2.1-3.3.0.php +34 -0
  60. app/design/adminhtml/default/default/layout/factfinder.xml +28 -0
  61. app/design/adminhtml/default/default/template/factfinder/cockpit.phtml +22 -0
  62. app/design/frontend/base/default/layout/factfinder.xml +70 -0
  63. app/design/frontend/base/default/template/factfinder/campaign/advisory.phtml +12 -0
  64. app/design/frontend/base/default/template/factfinder/campaign/cart/advisory.phtml +12 -0
  65. app/design/frontend/base/default/template/factfinder/campaign/cart/feedback.phtml +6 -0
  66. app/design/frontend/base/default/template/factfinder/campaign/feedback.phtml +14 -0
  67. app/design/frontend/base/default/template/factfinder/filter/slider.phtml +46 -0
  68. app/design/frontend/base/default/template/factfinder/form.mini.phtml +38 -0
  69. app/design/frontend/base/default/template/factfinder/logo.phtml +22 -0
  70. app/design/frontend/base/default/template/factfinder/scic.phtml +31 -0
  71. app/etc/factfinder.xml +29 -0
  72. app/etc/modules/Flagbit_FactFinder.xml +9 -0
  73. app/locale/de_DE/Flagbit_FactFinder.csv +54 -0
  74. js/factfinder/jXHR.js +84 -0
  75. js/factfinder/scic.js +59 -0
  76. js/factfinder/suggest.js +185 -0
  77. lib/FACTFinder/Abstract/Adapter.php +118 -0
  78. lib/FACTFinder/Abstract/CompareAdapter.php +89 -0
  79. lib/FACTFinder/Abstract/Configuration.php +153 -0
  80. lib/FACTFinder/Abstract/DataProvider.php +112 -0
  81. lib/FACTFinder/Abstract/ProductCampaignAdapter.php +100 -0
  82. lib/FACTFinder/Abstract/RecommendationAdapter.php +87 -0
  83. lib/FACTFinder/Abstract/ScicAdapter.php +152 -0
  84. lib/FACTFinder/Abstract/SearchAdapter.php +252 -0
  85. lib/FACTFinder/Abstract/SimilarRecordsAdapter.php +121 -0
  86. lib/FACTFinder/Abstract/SuggestAdapter.php +33 -0
  87. lib/FACTFinder/Abstract/TagCloudAdapter.php +30 -0
  88. lib/FACTFinder/AdvisorAnswer.php +69 -0
  89. lib/FACTFinder/AdvisorQuestion.php +59 -0
  90. lib/FACTFinder/Asn.php +30 -0
  91. lib/FACTFinder/AsnFilterItem.php +65 -0
  92. lib/FACTFinder/AsnGroup.php +128 -0
  93. lib/FACTFinder/AsnSliderFilter.php +124 -0
  94. lib/FACTFinder/BreadCrumbItem.php +68 -0
  95. lib/FACTFinder/Campaign.php +198 -0
  96. lib/FACTFinder/CampaignIterator.php +182 -0
  97. lib/FACTFinder/Configuration.php +362 -0
  98. lib/FACTFinder/EncodingHandler.php +209 -0
  99. lib/FACTFinder/Http/DataProvider.php +291 -0
  100. lib/FACTFinder/Http/DummyProvider.php +130 -0
  101. lib/FACTFinder/Http/ParallelDataProvider.php +159 -0
  102. lib/FACTFinder/Http/ScicAdapter.php +29 -0
  103. lib/FACTFinder/Http/SuggestAdapter.php +35 -0
  104. lib/FACTFinder/Item.php +48 -0
  105. lib/FACTFinder/Loader.php +185 -0
  106. lib/FACTFinder/Logger/BlackHole.php +7 -0
  107. lib/FACTFinder/Logger/LoggerInterface.php +6 -0
  108. lib/FACTFinder/Paging.php +170 -0
  109. lib/FACTFinder/Parameters.php +106 -0
  110. lib/FACTFinder/ParametersParser.php +372 -0
  111. lib/FACTFinder/ProductsPerPageOptions.php +79 -0
  112. lib/FACTFinder/Record.php +251 -0
  113. lib/FACTFinder/Result.php +34 -0
  114. lib/FACTFinder/SingleWordSearchItem.php +39 -0
  115. lib/FACTFinder/SuggestQuery.php +71 -0
  116. lib/FACTFinder/TagQuery.php +41 -0
  117. lib/FACTFinder/Util.php +48 -0
  118. lib/FACTFinder/Xml64/SearchAdapter.php +111 -0
  119. lib/FACTFinder/Xml65/RecommendationAdapter.php +83 -0
  120. lib/FACTFinder/Xml65/SearchAdapter.php +493 -0
  121. lib/FACTFinder/Xml65/SuggestAdapter.php +59 -0
  122. lib/FACTFinder/Xml65/TagCloudAdapter.php +61 -0
  123. lib/FACTFinder/Xml66/CompareAdapter.php +101 -0
  124. lib/FACTFinder/Xml66/RecommendationAdapter.php +15 -0
  125. lib/FACTFinder/Xml66/SearchAdapter.php +115 -0
  126. lib/FACTFinder/Xml66/SimilarRecordsAdapter.php +106 -0
  127. lib/FACTFinder/Xml66/SuggestAdapter.php +15 -0
  128. lib/FACTFinder/Xml66/TagCloudAdapter.php +15 -0
  129. lib/FACTFinder/Xml67/CompareAdapter.php +12 -0
  130. lib/FACTFinder/Xml67/ProductCampaignAdapter.php +161 -0
  131. lib/FACTFinder/Xml67/RecommendationAdapter.php +33 -0
  132. lib/FACTFinder/Xml67/SearchAdapter.php +128 -0
  133. lib/FACTFinder/Xml67/SimilarRecordsAdapter.php +12 -0
  134. lib/FACTFinder/Xml67/SuggestAdapter.php +12 -0
  135. lib/FACTFinder/Xml67/TagCloudAdapter.php +12 -0
  136. lib/FACTFinderCustom/Configuration.php +297 -0
  137. package.xml +22 -0
app/code/community/Flagbit/FactFinder/Block/Adminhtml/Cockpit.php ADDED
@@ -0,0 +1,33 @@
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
+ * Black class
12
+ *
13
+ * This Block class provides the FACT-Finder Business User Cockpit Authentication URL
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_Adminhtml_Cockpit extends Mage_Adminhtml_Block_Template {
22
+
23
+ /**
24
+ * get FACT-Finder Business User Cockpit Authentication URL
25
+ *
26
+ * @return string
27
+ */
28
+ public function getAuthenticationUrl()
29
+ {
30
+ return Mage::getSingleton('factfinder/adapter')->getAuthenticationUrl();
31
+ }
32
+
33
+ }
app/code/community/Flagbit/FactFinder/Block/Adminhtml/Form/Field/Attribute.php ADDED
@@ -0,0 +1,54 @@
1
+ <?php
2
+
3
+ class Flagbit_FactFinder_Block_Adminhtml_Form_Field_Attribute extends Mage_Core_Block_Html_Select
4
+ {
5
+ /**
6
+ * Storeviews cache
7
+ *
8
+ * @var array
9
+ */
10
+ private $_attributes;
11
+
12
+ /**
13
+ * Retrieve allowed Storeviews
14
+ *
15
+ * @param int $storeId return name by storeview id
16
+ * @return array|string
17
+ */
18
+ protected function _getAttributes($storeId = null)
19
+ {
20
+ if (is_null($this->_attributes)) {
21
+ $this->_attributes = array();
22
+ $collection = Mage::getModel('eav/entity_attribute')->getCollection();
23
+ $collection->setEntityTypeFilter(Mage::getSingleton('eav/config')->getEntityType('catalog_product'));
24
+ foreach ($collection as $item) {
25
+ /* @var $item Mage_Core_Model_Store */
26
+ $this->_attributes[$item->getAttributeCode()] = $item->getFrontendLabel().' ('.$item->getAttributeCode().')';
27
+ }
28
+ }
29
+ if (!is_null($storeId)) {
30
+ return isset($this->_attributes[$storeId]) ? $this->_attributes[$storeId] : null;
31
+ }
32
+ return $this->_attributes;
33
+ }
34
+
35
+ public function setInputName($value)
36
+ {
37
+ return $this->setName($value);
38
+ }
39
+
40
+ /**
41
+ * Render block HTML
42
+ *
43
+ * @return string
44
+ */
45
+ public function _toHtml()
46
+ {
47
+ if (!$this->getOptions()) {
48
+ foreach ($this->_getAttributes() as $id => $label) {
49
+ $this->addOption($id, addslashes($label));
50
+ }
51
+ }
52
+ return parent::_toHtml();
53
+ }
54
+ }
app/code/community/Flagbit/FactFinder/Block/Adminhtml/Form/Field/Attributes.php ADDED
@@ -0,0 +1,85 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_CatalogInventory
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml catalog inventory "Minimum Qty Allowed in Shopping Cart" field
29
+ *
30
+ * @category Mage
31
+ * @package Mage_CatalogInventory
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Flagbit_FactFinder_Block_Adminhtml_Form_Field_Attributes extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
35
+ {
36
+ /**
37
+ * @var Flagbit_ContentFromUrl_Block_Adminhtml_Form_Field_Storeview
38
+ */
39
+ protected $_attributeRenderer;
40
+
41
+ /**
42
+ * Retrieve group column renderer
43
+ *
44
+ * @return Flagbit_ContentFromUrl_Block_Adminhtml_Form_Field_Storeview
45
+ */
46
+ protected function _getAttributeRenderer()
47
+ {
48
+ if (!$this->_attributeRenderer) {
49
+ $this->_attributeRenderer = $this->getLayout()->createBlock(
50
+ 'factfinder/adminhtml_form_field_attribute', '',
51
+ array('is_render_to_js_template' => true)
52
+ );
53
+ $this->_attributeRenderer->setClass('attribute_select');
54
+ $this->_attributeRenderer->setExtraParams('style="width:200px"');
55
+ }
56
+ return $this->_attributeRenderer;
57
+ }
58
+
59
+ /**
60
+ * Prepare to render
61
+ */
62
+ protected function _prepareToRender()
63
+ {
64
+ $this->addColumn('attribute', array(
65
+ 'label' => Mage::helper('factfinder')->__('Attribute'),
66
+ 'renderer' => $this->_getAttributeRenderer(),
67
+ ));
68
+
69
+ $this->_addAfter = false;
70
+ $this->_addButtonLabel = Mage::helper('factfinder')->__('Add Attribute');
71
+ }
72
+
73
+ /**
74
+ * Prepare existing row data object
75
+ *
76
+ * @param Varien_Object
77
+ */
78
+ protected function _prepareArrayRow(Varien_Object $row)
79
+ {
80
+ $row->setData(
81
+ 'option_extra_attr_' . $this->_getAttributeRenderer()->calcOptionHash($row->getData('attribute')),
82
+ 'selected="selected"'
83
+ );
84
+ }
85
+ }
app/code/community/Flagbit/FactFinder/Block/Campaign/Advisory.php ADDED
@@ -0,0 +1,23 @@
1
+ <?php
2
+
3
+ class Flagbit_FactFinder_Block_Campaign_Advisory extends Mage_Core_Block_Template
4
+ {
5
+ /**
6
+ * get Campaign Text
7
+ *
8
+ * @return string
9
+ */
10
+ public function getActiveQuestions()
11
+ {
12
+ $questions = array();
13
+
14
+ if(Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign')){
15
+ $_campaigns = Mage::getSingleton('factfinder/adapter')->getCampaigns();
16
+ if($_campaigns && $_campaigns->hasActiveQuestions()){
17
+ $questions = $_campaigns->getActiveQuestions();
18
+ }
19
+ }
20
+
21
+ return $questions;
22
+ }
23
+ }
app/code/community/Flagbit/FactFinder/Block/Campaign/Cart/Advisory.php ADDED
@@ -0,0 +1,56 @@
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
+ * Provides advisory hints to the product view page
12
+ *
13
+ * @category Mage
14
+ * @package Flagbit_FactFinder
15
+ * @copyright Copyright (c) 2012 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
16
+ * @author Mike Becker <mike.becker@flagbit.de>
17
+ * @version $Id$
18
+ */
19
+ class Flagbit_FactFinder_Block_Campaign_Cart_Advisory extends Mage_Core_Block_Template
20
+ {
21
+ /**
22
+ * get campaign questions and answers
23
+ *
24
+ * @return array $questions
25
+ */
26
+ public function getActiveQuestions()
27
+ {
28
+ Mage::getSingleton('core/session', array('name'=>'frontend'));
29
+
30
+ if (!Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign')) {
31
+ return array();
32
+ }
33
+
34
+ // only display campaign right after a new product was added to cart
35
+ if (!Mage::getSingleton('checkout/session')->getLastAddedProductId()) {
36
+ return array();
37
+ }
38
+
39
+ $questions = array();
40
+
41
+ $_product = Mage::getModel('catalog/product')->load(Mage::getSingleton('checkout/session')->getLastAddedProductId());
42
+ if (!$_product->getData(Mage::helper('factfinder/search')->getIdFieldName())) {
43
+ return array();
44
+ }
45
+
46
+ $_campaigns = Mage::helper('factfinder/search')->getProductCampaigns(array(
47
+ $_product->getData(Mage::helper('factfinder/search')->getIdFieldName())
48
+ ));
49
+
50
+ if($_campaigns && $_campaigns->hasActiveQuestions()){
51
+ $questions = $_campaigns->getActiveQuestions();
52
+ }
53
+
54
+ return $questions;
55
+ }
56
+ }
app/code/community/Flagbit/FactFinder/Block/Campaign/Cart/Feedback.php ADDED
@@ -0,0 +1,53 @@
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
+ * Provides advisory hints to the product view page
12
+ *
13
+ * @category Mage
14
+ * @package Flagbit_FactFinder
15
+ * @copyright Copyright (c) 2012 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
16
+ * @author Mike Becker <mike.becker@flagbit.de>
17
+ * @version $Id$
18
+ */
19
+ class Flagbit_FactFinder_Block_Campaign_Cart_Feedback extends Mage_Core_Block_Template
20
+ {
21
+ /**
22
+ * get campaign questions and answers
23
+ *
24
+ * @return array $feedback
25
+ */
26
+ public function getActiveFeedback()
27
+ {
28
+ Mage::getSingleton('core/session', array('name'=>'frontend'));
29
+
30
+ // only display campaign if they are activated and right after a new product was added to cart
31
+ if (!Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign') || !Mage::getSingleton('checkout/session')->getLastAddedProductId()) {
32
+ return array();
33
+ }
34
+
35
+ $feedback = array();
36
+
37
+ $_product = Mage::getModel('catalog/product')->load(Mage::getSingleton('checkout/session')->getLastAddedProductId());
38
+ if (!$_product->getData(Mage::helper('factfinder/search')->getIdFieldName())) {
39
+ return array();
40
+ }
41
+
42
+ $_campaigns = Mage::helper('factfinder/search')->getProductCampaigns(array(
43
+ $_product->getData(Mage::helper('factfinder/search')->getIdFieldName())
44
+ ));
45
+
46
+ if($_campaigns && $_campaigns->hasFeedback()){
47
+ $feedback = $_campaigns;
48
+ }
49
+
50
+ return $feedback;
51
+
52
+ }
53
+ }
app/code/community/Flagbit/FactFinder/Block/Campaign/Feedback.php ADDED
@@ -0,0 +1,62 @@
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: Scic.php 645 2011-03-17 14:54:20Z weller $
20
+ */
21
+ class Flagbit_FactFinder_Block_Campaign_Feedback extends Mage_Core_Block_Template
22
+ {
23
+ /**
24
+ * Pushed Products Collection
25
+ *
26
+ * @var Flagbit_FactFinder_Model_Mysql4_Campaign_Pushedproducts_Collection
27
+ */
28
+ protected $_pushedProductsCollection = null;
29
+
30
+ /**
31
+ * get Campaign Text
32
+ *
33
+ * @return string
34
+ */
35
+ public function getText()
36
+ {
37
+ $text = '';
38
+
39
+ if(Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign')){
40
+ $_campaigns = Mage::getSingleton('factfinder/adapter')->getCampaigns();
41
+ if($_campaigns && $_campaigns->hasFeedback() && $this->getTextNumber()){
42
+ $text = $_campaigns->getFeedback($this->getTextNumber() - 1);
43
+ }
44
+ }
45
+
46
+ return $text;
47
+ }
48
+
49
+ /**
50
+ * Pushed Products Collection
51
+ *
52
+ * @return Flagbit_FactFinder_Model_Mysql4_Campaign_Pushedproducts_Collection
53
+ */
54
+ public function getPushedProductsCollection()
55
+ {
56
+ if($this->_pushedProductsCollection === null){
57
+ $this->_pushedProductsCollection = Mage::getResourceModel('factfinder/campaign_pushedproducts_collection');
58
+ }
59
+
60
+ return $this->_pushedProductsCollection;
61
+ }
62
+ }
app/code/community/Flagbit/FactFinder/Block/Campaign/Product/Advisory.php ADDED
@@ -0,0 +1,42 @@
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
+ * Provides advisory hints to the product view page
12
+ *
13
+ * @category Mage
14
+ * @package Flagbit_FactFinder
15
+ * @copyright Copyright (c) 2012 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
16
+ * @author Mike Becker <mike.becker@flagbit.de>
17
+ * @version $Id$
18
+ */
19
+ class Flagbit_FactFinder_Block_Campaign_Product_Advisory extends Mage_Core_Block_Template
20
+ {
21
+ /**
22
+ * get campaign questions and answers
23
+ *
24
+ * @return array $questions
25
+ */
26
+ public function getActiveQuestions()
27
+ {
28
+ $questions = array();
29
+
30
+ if (Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign') && Mage::registry('current_product')) {
31
+ $_campaigns = Mage::helper('factfinder/search')->getProductCampaigns(array(
32
+ Mage::registry('current_product')->getData(Mage::helper('factfinder/search')->getIdFieldName()),
33
+ ));
34
+
35
+ if($_campaigns && $_campaigns->hasActiveQuestions()){
36
+ $questions = $_campaigns->getActiveQuestions();
37
+ }
38
+ }
39
+
40
+ return $questions;
41
+ }
42
+ }
app/code/community/Flagbit/FactFinder/Block/Campaign/Product/Feedback.php ADDED
@@ -0,0 +1,42 @@
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
+ * Provides advisory hints to the product view page
12
+ *
13
+ * @category Mage
14
+ * @package Flagbit_FactFinder
15
+ * @copyright Copyright (c) 2012 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
16
+ * @author Mike Becker <mike.becker@flagbit.de>
17
+ * @version $Id$
18
+ */
19
+ class Flagbit_FactFinder_Block_Campaign_Product_Feedback extends Mage_Core_Block_Template
20
+ {
21
+ /**
22
+ * get campaign feedback
23
+ *
24
+ * @return array $feedback
25
+ */
26
+ public function getActiveFeedback()
27
+ {
28
+ $feedback = array();
29
+
30
+ if (Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign') && Mage::registry('current_product')) {
31
+ $_campaigns = Mage::helper('factfinder/search')->getProductCampaigns(array(
32
+ Mage::registry('current_product')->getData(Mage::helper('factfinder/search')->getIdFieldName()),
33
+ ));
34
+
35
+ if($_campaigns && $_campaigns->hasFeedback()){
36
+ $feedback = $_campaigns;
37
+ }
38
+ }
39
+
40
+ return $feedback;
41
+ }
42
+ }
app/code/community/Flagbit/FactFinder/Block/Cart/Crosssell.php ADDED
@@ -0,0 +1,93 @@
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
+ * Overwritten block.
12
+ *
13
+ * Replaces the crosssell block within cart view. Gets data from FACT-Finder instead of product link collection.
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_Block_Cart_Crosssell extends Mage_Checkout_Block_Cart_Crosssell
22
+ {
23
+ /**
24
+ * Overwritten function. Gets information from FACT-Finder Collection instead of product link collection.
25
+ */
26
+ public function getItems()
27
+ {
28
+ if (!Mage::getStoreConfigFlag('factfinder/activation/crosssell')) {
29
+ return parent::getItems();
30
+ }
31
+
32
+ $items = $this->getData('items');
33
+ if (is_null($items)) {
34
+ try {
35
+ $items = array();
36
+ $ninProductIds = $this->_getCartProductIds();
37
+ if ($ninProductIds) {
38
+ $lastAdded = (int) $this->_getLastAddedProductId();
39
+ if ($lastAdded) {
40
+ $searchHelper = Mage::helper('factfinder/search');
41
+ $idFieldName = $searchHelper->getIdFieldName();
42
+
43
+ $recommendationAdapter = Mage::getModel('factfinder/adapter')->getRecommendationAdapter();
44
+ $attributeValue = Mage::getModel('catalog/product')->getResource()->getAttributeRawValue($lastAdded, $idFieldName, Mage::app()->getStore()->getId());
45
+
46
+ $collection = $this->_getCollection()
47
+ ->setRecommendations($recommendationAdapter->getRecommendations($attributeValue));
48
+ if (!empty($ninProductIds)) {
49
+ $collection->addExcludeProductFilter($ninProductIds);
50
+ }
51
+
52
+ foreach ($collection as $item) {
53
+ $items[] = $item;
54
+ }
55
+ }
56
+
57
+ }
58
+ }
59
+ catch (Exception $e) {
60
+ Mage::logException($e);
61
+ $items = array();
62
+ }
63
+
64
+ $this->setData('items', $items);
65
+ }
66
+ return $items;
67
+ }
68
+
69
+ /**
70
+ * Get crosssell products collection. Get it from product recommendation collection for communication with FACT-Finder.
71
+ *
72
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Link_Product_Collection
73
+ */
74
+ protected function _getCollection()
75
+ {
76
+ if (!Mage::getStoreConfigFlag('factfinder/activation/crosssell')) {
77
+ return parent::_getCollection();
78
+ }
79
+
80
+ $collection = Mage::getResourceModel('factfinder/product_recommendation_collection')
81
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
82
+ ->setStoreId(Mage::app()->getStore()->getId())
83
+ ->addStoreFilter()
84
+ ->setPageSize($this->_maxItemCount);
85
+ $this->_addProductAttributesAndPrices($collection);
86
+
87
+ Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
88
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
89
+ Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
90
+
91
+ return $collection;
92
+ }
93
+ }
app/code/community/Flagbit/FactFinder/Block/Filter/Slider.php ADDED
@@ -0,0 +1,36 @@
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
+ * Add Slider Javascript to HTML Head
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_Filter_Slider extends Mage_Core_Block_Abstract {
22
+
23
+ /**
24
+ * get Slider Javascript
25
+ *
26
+ * @return string
27
+ */
28
+ protected function _toHtml()
29
+ {
30
+ if(Mage::helper('factfinder/search')->getIsEnabled()){
31
+ return '<script type="text/javascript" language="javascript" src="http://static.express.fact-finder.com/onetouchslider-1.0/de.factfinder.asn.slider.OneTouchSlider.nocache.js"></script>'."\n".
32
+ '<script type="text/javascript" language="javascript"> oneTouchSliderOnLoad = function(){ document.fire("ffslider:init");}</script>'."\n";
33
+
34
+ }
35
+ }
36
+ }
app/code/community/Flagbit/FactFinder/Block/Layer.php ADDED
@@ -0,0 +1,127 @@
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_Layer extends Flagbit_FactFinder_Block_Layer_Abstract
22
+ {
23
+
24
+ /**
25
+ * Prepare child blocks
26
+ *
27
+ * @return Mage_Catalog_Block_Layer_View
28
+ */
29
+ protected function _prepareLayout()
30
+ {
31
+ if(Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign')){
32
+ // handle redirects
33
+ $redirect = Mage::getSingleton('factfinder/adapter')->getRedirect();
34
+ if($redirect){
35
+ Mage::app()->getResponse()->setRedirect($redirect);
36
+ }
37
+ }
38
+
39
+ if(!Mage::helper('factfinder/search')->getIsEnabled(false, 'asn')){
40
+ return parent::_prepareLayout();
41
+ }
42
+
43
+ // set default sort Order
44
+ if(Mage::getSingleton('catalog/session')->getSortOrder()){
45
+ Mage::getSingleton('catalog/session')->setSortOrder('relevance');
46
+ }
47
+
48
+ $stateBlock = $this->getLayout()->createBlock('catalog/layer_state')
49
+ ->setLayer($this->getLayer());
50
+
51
+ $this->setChild('layer_state', $stateBlock);
52
+
53
+ $filterableAttributes = $this->_getFilterableAttributes();
54
+ foreach ($filterableAttributes as $attribute) {
55
+ $filterBlockName = $this->_getAttributeFilterBlockName();
56
+
57
+ $filterBlock = $this->getLayout()->createBlock($filterBlockName)
58
+ ->setLayer($this->getLayer())
59
+ ->setAttributeModel($attribute)
60
+ ->init();
61
+
62
+ switch($attribute->getType()){
63
+
64
+ case 'slider':
65
+ if(!($this->getLayout()->getBlock('ffslider') instanceof Flagbit_FactFinder_Block_Filter_Slider)){
66
+ $this->getLayout()->getBlock('head')->setChild('ffslider', $this->getLayout()->createBlock('factfinder/filter_slider'));
67
+ }
68
+ $filterBlock->setTemplate('factfinder/filter/slider.phtml');
69
+ $filterBlock->setData((current($attribute->getItems())));
70
+ $filterBlock->setUnit($attribute->getUnit());
71
+ break;
72
+ }
73
+
74
+ $this->setChild($attribute->getAttributeCode().'_filter', $filterBlock);
75
+ }
76
+
77
+ $this->getLayer()->apply();
78
+ return Mage_Core_Block_Template::_prepareLayout();
79
+ }
80
+
81
+ /**
82
+ * Get category filter block
83
+ *
84
+ * @return Mage_Catalog_Block_Layer_Filter_Category
85
+ */
86
+ protected function _getCategoryFilter()
87
+ {
88
+ if(!Mage::helper('factfinder/search')->getIsEnabled(false, 'asn')){
89
+ return parent::_getCategoryFilter();
90
+ }
91
+ return false;
92
+ }
93
+
94
+ /**
95
+ * Retrieve Price Filter block
96
+ *
97
+ * @return Mage_Catalog_Block_Layer_Filter_Price
98
+ */
99
+ protected function _getPriceFilter()
100
+ {
101
+ if(!Mage::helper('factfinder/search')->getIsEnabled(false, 'asn')){
102
+ return parent::_getPriceFilter();
103
+ }
104
+
105
+ return false;
106
+ }
107
+
108
+ /**
109
+ * Check availability display layer block
110
+ *
111
+ * @return bool
112
+ */
113
+ public function canShowBlock()
114
+ {
115
+ if (!Mage::helper('factfinder/search')->getIsEnabled(false)) {
116
+ return parent::canShowBlock();
117
+ }
118
+ if(!Mage::helper('factfinder/search')->getIsEnabled(false, 'asn')){
119
+ return false;
120
+ }
121
+ if ($this->getLayer()->getFilterableAttributes()->count()
122
+ && $this->getLayer()->getProductCollection()->getSize()) {
123
+ return true;
124
+ }
125
+ return false;
126
+ }
127
+ }
app/code/community/Flagbit/FactFinder/Block/Layer/Abstract.php ADDED
@@ -0,0 +1,33 @@
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
+ * dynamicaly extends the core class whether Enterprise Search is enabled or not
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
+
22
+ if(Mage::helper('factfinder/search')->getIsOnSearchPage()){
23
+ if(Mage::helper('factfinder')->isModuleActive('Enterprise_Search')){
24
+ class Flagbit_FactFinder_Block_Layer_Abstract extends Enterprise_Search_Block_Catalogsearch_Layer {}
25
+ }else{
26
+ class Flagbit_FactFinder_Block_Layer_Abstract extends Mage_CatalogSearch_Block_Layer {}
27
+ }
28
+ }else{
29
+ class Flagbit_FactFinder_Block_Layer_Abstract extends Mage_Catalog_Block_Layer_View {}
30
+ }
31
+
32
+
33
+
app/code/community/Flagbit/FactFinder/Block/Product/List/Crosssell.php ADDED
@@ -0,0 +1,63 @@
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
+ * Overwritten block.
12
+ *
13
+ * Replaces the crosssell block. Gets data from FACT-Finder instead of product link collection.
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_Block_Product_List_Crosssell extends Mage_Catalog_Block_Product_List_Crosssell
22
+ {
23
+ /**
24
+ * Method overwritten. Data is not read from product link collection but from FACT-Finder interface instead.
25
+ */
26
+ protected function _prepareData()
27
+ {
28
+
29
+ if (!Mage::getStoreConfigFlag('factfinder/activation/crosssell')) {
30
+ return parent::_prepareData();
31
+ }
32
+ try {
33
+ $product = Mage::registry('product');
34
+ /* @var $product Mage_Catalog_Model_Product */
35
+
36
+ $searchHelper = Mage::helper('factfinder/search');
37
+ $idFieldName = $searchHelper->getIdFieldName();
38
+
39
+ $this->_itemCollection = Mage::getResourceModel('factfinder/product_recommendation_collection')
40
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
41
+ ->addStoreFilter();
42
+
43
+ $recommendationAdapter = Mage::getModel('factfinder/adapter')->getRecommendationAdapter();
44
+ $recommendationAdapter->setProductId($product->getData($idFieldName));
45
+ $recommendations = $recommendationAdapter->getRecommendations();
46
+ $this->_itemCollection->setRecommendations($recommendations);
47
+
48
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
49
+
50
+ $this->_itemCollection->load();
51
+
52
+ foreach ($this->_itemCollection as $product) {
53
+ $product->setDoNotUseCategoryId(true);
54
+ }
55
+ }
56
+ catch (Exception $e) {
57
+ Mage::logException($e);
58
+ $this->_itemCollection = new Varien_Data_Collection();
59
+ }
60
+
61
+ return $this;
62
+ }
63
+ }
app/code/community/Flagbit/FactFinder/Block/Product/List/Upsell.php ADDED
@@ -0,0 +1,115 @@
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 for upselling
12
+ *
13
+ * Rewritten block - data is now caught by FACT-Finder, passed to normal collection, works quite as if it was the
14
+ * default behavior.
15
+ *
16
+ * @category Mage
17
+ * @package Flagbit_FactFinder
18
+ * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
19
+ * @author Michael Türk <türk@flagbit.de>
20
+ * @version $Id: Search.php 678 2011-08-01 13:02:50Z rudolf_batt $
21
+ */
22
+ class Flagbit_FactFinder_Block_Product_List_Upsell extends Mage_Catalog_Block_Product_List_Upsell
23
+ {
24
+ /**
25
+ * Method overwritten. Data is not read from product link collection but from FACT-Finder interface instead.
26
+ */
27
+ protected function _prepareData()
28
+ {
29
+ if (!Mage::getStoreConfigFlag('factfinder/activation/upsell') && !(Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign'))) {
30
+ return parent::_prepareData();
31
+ }
32
+
33
+ try {
34
+ $product = Mage::registry('product');
35
+ /* @var $product Mage_Catalog_Model_Product */
36
+
37
+ $searchHelper = Mage::helper('factfinder/search');
38
+ $idFieldName = $searchHelper->getIdFieldName();
39
+
40
+ $recommendationAdapter = Mage::getModel('factfinder/adapter')->getRecommendationAdapter();
41
+ $recommendationAdapter->setProductId($product->getData($idFieldName));
42
+ $recommendations = $recommendationAdapter->getRecommendations();
43
+
44
+ // combine recommendations and pushed products
45
+ $mergedUpsell = array_merge($this->getPushedProducts(), (array) $recommendations);
46
+ // build new FACTFinder_Result with combined data
47
+ $recommendations = FF::getInstance('result', $mergedUpsell, count($mergedUpsell));
48
+
49
+ if ($recommendations == null) {
50
+ throw new Exception('No recommendations given - check connection to FACT-Finder and FACT-Finder configuration');
51
+ }
52
+ elseif ($recommendations->getFoundRecordsCount() == 0) {
53
+ $this->_itemCollection = new Varien_Data_Collection();
54
+ return $this;
55
+ }
56
+
57
+ $this->_itemCollection = Mage::getResourceModel('factfinder/product_recommendation_collection')->addStoreFilter();
58
+
59
+ if ($this->getItemLimit('upsell') > 0) {
60
+ $this->_itemCollection->setPageSize($this->getItemLimit('upsell'));
61
+ }
62
+ $this->_itemCollection->setRecommendations($recommendations);
63
+
64
+ Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
65
+ Mage::getSingleton('checkout/session')->getQuoteId()
66
+ );
67
+ $this->_addProductAttributesAndPrices($this->_itemCollection);
68
+
69
+ // // Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_itemCollection);
70
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
71
+ $this->_itemCollection->load();
72
+
73
+ /**
74
+ * Updating collection with desired items
75
+ */
76
+ Mage::dispatchEvent('catalog_product_upsell', array(
77
+ 'product' => $product,
78
+ 'collection' => $this->_itemCollection,
79
+ 'limit' => $this->getItemLimit()
80
+ ));
81
+
82
+ foreach ($this->_itemCollection as $product) {
83
+ $product->setDoNotUseCategoryId(true);
84
+ }
85
+ }
86
+ catch (Exception $e) {
87
+ Mage::logException($e);
88
+ $this->_itemCollection = new Varien_Data_Collection();
89
+ }
90
+
91
+ return $this;
92
+ }
93
+
94
+
95
+ /**
96
+ * get pushed products to combine with recommendations
97
+ *
98
+ * @return array
99
+ */
100
+ protected function getPushedProducts()
101
+ {
102
+ $pushedProducts = array();
103
+
104
+ $_campaigns = Mage::helper('factfinder/search')->getProductCampaigns(array(
105
+ Mage::registry('current_product')->getData(Mage::helper('factfinder/search')->getIdFieldName()),
106
+ ));
107
+
108
+ if($_campaigns && $_campaigns->hasPushedProducts()){
109
+ $pushedProducts = $_campaigns->getPushedProducts();
110
+ }
111
+
112
+ return $pushedProducts;
113
+ }
114
+
115
+ }
app/code/community/Flagbit/FactFinder/Block/Scic.php ADDED
@@ -0,0 +1,89 @@
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/TagCloud.php ADDED
@@ -0,0 +1,44 @@
1
+ <?php
2
+ class Flagbit_FactFinder_Block_TagCloud extends Mage_CatalogSearch_Block_Term
3
+ {
4
+ protected function _loadTerms()
5
+ {
6
+ if (!Mage::helper('factfinder/search')->getIsEnabled(false, 'tagcloud')) {
7
+ return parent::_loadTerms();
8
+ }
9
+
10
+ if (empty($this->_terms)) {
11
+ $terms = Mage::getSingleton('factfinder/adapter')->getTagCloud();
12
+
13
+ if (count($terms) == 0) {
14
+ return $this;
15
+ }
16
+
17
+ $this->_maxPopularity = 0;
18
+ $this->_minPopularity = 1;
19
+
20
+ for ($i = 0; $i < count($terms); $i++) {
21
+ $term = $terms[$i];
22
+
23
+ $termArray = array();
24
+ $termArray['name'] = $term->getValue();
25
+ $termArray['url'] = $term->getUrl();
26
+ $termArray['popularity'] = $term->getWeight();
27
+ $termArray['ratio'] = $term->getWeight();
28
+
29
+ if ($term->getWeight() > $this->_maxPopularity) {
30
+ $this->_maxPopularity = $term->getWeight();
31
+ }
32
+ if ($term->getWeight() < $this->_minPopularity) {
33
+ $this->_minPopularity = $term->getWeight();
34
+ }
35
+
36
+ $terms[$i] = new Varien_Object($termArray);
37
+ }
38
+
39
+ $this->_terms = $terms;
40
+ }
41
+
42
+ return $this;
43
+ }
44
+ }
app/code/community/Flagbit/FactFinder/Block/XmlConnect/Catalog/Product/List.php ADDED
@@ -0,0 +1,124 @@
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 apply Filter
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_XmlConnect_Catalog_Product_List extends Mage_XmlConnect_Block_Catalog_Product_List {
22
+
23
+ /**
24
+ * Retrieve product collection with all prepared data and limitations
25
+ *
26
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
27
+ */
28
+ protected function _getProductCollection()
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
+ *
53
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
54
+ */
55
+ protected function __getSearchProductCollection()
56
+ {
57
+ if (is_null($this->_productCollection)) {
58
+ $filters = array();
59
+ $request = $this->getRequest();
60
+ $requestParams = $request->getParams();
61
+ $layer = $this->getLayer();
62
+ if (!$layer) {
63
+ return null;
64
+ }
65
+ $category = $this->getCategory();
66
+ if ($category && is_object($category) && $category->getId()) {
67
+ $layer->setCurrentCategory($category);
68
+ }
69
+
70
+ if (!$this->getNeedBlockApplyingFilters()) {
71
+ $attributes = $layer->getFilterableAttributes();
72
+ /**
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
+
89
+ /**
90
+ * Products
91
+ */
92
+ $layer = $this->getLayer();
93
+ $collection = $layer->getProductCollection();
94
+
95
+ /**
96
+ * Add rating and review summary, image attribute, apply sort params
97
+ */
98
+ $this->_prepareCollection($collection);
99
+
100
+ /**
101
+ * Apply offset and count
102
+ */
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
+
123
+
124
+
app/code/community/Flagbit/FactFinder/Block/XmlConnect/Catalog/Search.php ADDED
@@ -0,0 +1,123 @@
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 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/)
18
+ * @author Joerg Weller <weller@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)
27
+ * and sort fields
28
+ *
29
+ * @return string
30
+ */
31
+ protected function _toHtml()
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
+
40
+ $helper = Mage::helper('catalogsearch');
41
+ if (method_exists($helper, 'getEngine')) {
42
+ $engine = Mage::helper('catalogsearch')->getEngine();
43
+ $isLayeredNavigationAllowed = ($engine instanceof Varien_Object) ? $engine->isLeyeredNavigationAllowed() : true;
44
+ }
45
+ else {
46
+ $isLayeredNavigationAllowed = true;
47
+ }
48
+
49
+ $request = $this->getRequest();
50
+ $requestParams = $request->getParams();
51
+ $hasMoreProductItems = 0;
52
+
53
+ /**
54
+ * Products
55
+ */
56
+ $productListBlock = $this->getChild('product_list');
57
+ $productListBlock->setNeedBlockApplyingFilters(false);
58
+ if ($productListBlock) {
59
+ $layer = Mage::getSingleton('catalogsearch/layer');
60
+ $productsXmlObj = $productListBlock->setLayer($layer)
61
+ ->setNeedBlockApplyingFilters(!$isLayeredNavigationAllowed)
62
+ ->getProductsXmlObject();
63
+ $searchXmlObject->appendChild($productsXmlObj);
64
+ $hasMoreProductItems = (int)$productListBlock->getHasProductItems();
65
+ }
66
+
67
+ $searchXmlObject->addAttribute('has_more_items', $hasMoreProductItems);
68
+
69
+ /**
70
+ * Filters
71
+ */
72
+ $showFiltersAndOrders = true;
73
+ $reguest = $this->getRequest();
74
+ foreach ($reguest->getParams() as $key => $value) {
75
+ if (0 === strpos($key, parent::REQUEST_SORT_ORDER_PARAM_REFIX) ||
76
+ 0 === strpos($key, parent::REQUEST_FILTER_PARAM_REFIX)) {
77
+ $showFiltersAndOrders = false;
78
+ break;
79
+ }
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
+ }
108
+ }
109
+ $searchXmlObject->appendChild($filtersXmlObject);
110
+ }
111
+
112
+ /**
113
+ * Sort fields
114
+ */
115
+ if ($showFiltersAndOrders) {
116
+ $searchXmlObject->appendChild($this->getProductSortFeildsXmlObject());
117
+ }
118
+
119
+ return $searchXmlObject->asNiceXml();
120
+ }
121
+
122
+
123
+ }
app/code/community/Flagbit/FactFinder/Block/XmlConnect/Catalog/Search/Suggest.php ADDED
@@ -0,0 +1,56 @@
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 enables FAC-Finder sugguest
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_XmlConnect_Catalog_Search_Suggest extends Mage_XmlConnect_Block_Catalog_Search_Suggest
22
+ {
23
+ const SUGGEST_ITEM_SEPARATOR = '::sep::';
24
+
25
+ /**
26
+ * Search suggestions xml renderer
27
+ *
28
+ * @return string
29
+ */
30
+ protected function _toHtml()
31
+ {
32
+ $suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<suggestions></suggestions>');
33
+ if (!$this->getRequest()->getParam('q', false)) {
34
+ return $suggestXmlObj->asNiceXml();
35
+ }
36
+
37
+ $suggestData = Mage::getSingleton('factfinder/adapter')->getSuggestResult($this->getRequest()->getParam('q'));
38
+
39
+ if (!($count = count($suggestData))) {
40
+ return $suggestXmlObj->asNiceXml();
41
+ }
42
+
43
+ $items = '';
44
+ foreach ($suggestData as $index => $item) {
45
+ $items .= $suggestXmlObj->xmlentities(strip_tags($item['query']))
46
+ . self::SUGGEST_ITEM_SEPARATOR
47
+ . (int)$item['hitCount']
48
+ . self::SUGGEST_ITEM_SEPARATOR;
49
+ }
50
+
51
+ $suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<suggestions>' . $items . '</suggestions>');
52
+
53
+ return $suggestXmlObj->asNiceXml();
54
+ }
55
+
56
+ }
app/code/community/Flagbit/FactFinder/Helper/Backend.php ADDED
@@ -0,0 +1,228 @@
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
+ * Helper class
12
+ *
13
+ * Helper for backend configurations.
14
+ *
15
+ * @category Mage
16
+ * @package Flagbit_FactFinder
17
+ * @copyright Copyright (c) 2011 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
18
+ * @author Michael Türk <tuerk@flagbit.de>
19
+ * @version $Id: Enabled.php 647 2011-03-21 10:32:14Z rudolf_batt $
20
+ */
21
+ class Flagbit_FactFinder_Helper_Backend extends Mage_Core_Helper_Abstract
22
+ {
23
+
24
+ /**
25
+ * Check configuration data by contacting FACT-Finder servers.
26
+ *
27
+ * @param unknown_type $configData
28
+ */
29
+ public function checkConfigData($configData) {
30
+ $dataArray = $this->_getCompleteFieldsetData($configData);
31
+ $data = new Varien_Object($dataArray);
32
+ $errors = array();
33
+
34
+ if (stripos($data->getAddress(), 'http://') === 0 || strpos($data->getAddress(), '/') !== false) {
35
+ $errors[] = Mage::helper('factfinder')->__('servername should only contain the IP address or the domain - no "http://" or any slashes!');
36
+ }
37
+
38
+ if ($data->getPort() == '') {
39
+ $port = 80;
40
+ }
41
+ elseif (!is_numeric($data->getPort())) {
42
+ $errors[] = Mage::helper('factfinder')->__('the value for "port" must be numeric!');
43
+ }
44
+ elseif(intval($data->getPort()) < 80) { //is there any http port lower 80?
45
+ $errors[] = Mage::helper('factfinder')->__('the value for "port" must be a number greater or equals 80!');
46
+ }
47
+
48
+ if ($data->getAuthPassword() != '' && $data->getAuthUser() == '') {
49
+ $errors[] = Mage::helper('factfinder')->__('there must be a username, if a password should be used');
50
+ }
51
+
52
+ $conflicts = Mage::helper('factfinder/debug')->getRewriteConflicts();
53
+ if(count($conflicts)){
54
+ foreach($conflicts as $moduleClass => $externalClass){
55
+ $errors[] = Mage::helper('factfinder')->__('There is a Class Rewrite Conflict: "%s" already overwritten by "%s"', $moduleClass, $externalClass);
56
+ }
57
+ }
58
+
59
+ if (count($errors) == 0) {
60
+ $adapter = Mage::getSingleton('factfinder/adapter');
61
+ if(!$adapter->checkStatus($dataArray)){
62
+ $errors[] = Mage::helper('factfinder')->__('WARNING: was not able to connect to FACT-Finder.');
63
+ }
64
+ }
65
+
66
+ return $errors;
67
+ }
68
+
69
+
70
+
71
+ /**
72
+ * Read data from array given, or if no value given, try to read data from website or global configuration
73
+ *
74
+ * @param array $configData
75
+ */
76
+ protected function _getCompleteFieldsetData($configData)
77
+ {
78
+ $data = array();
79
+ $websiteCode = Mage::app()->getRequest()->getParam('website');
80
+ $storeCode = Mage::app()->getRequest()->getParam('store');
81
+
82
+ foreach ($configData as $key => $keyData) {
83
+ if (!isset($keyData['value'])) {
84
+
85
+ $path = 'factfinder/search/' . $key;
86
+
87
+ if ($storeCode) {
88
+ $value = Mage::app()->getWebsite($websiteCode)->getConfig($path);
89
+ }
90
+ else {
91
+ $value = (string) Mage::getConfig()->getNode('default/' . $path);
92
+ }
93
+ }
94
+ else {
95
+ $value = $keyData['value'];
96
+ }
97
+
98
+ $data[$key] = $value;
99
+ }
100
+
101
+ return $data;
102
+ }
103
+
104
+ /**
105
+ * Generate a storable representation of a value
106
+ *
107
+ * @param mixed $value
108
+ * @return string
109
+ */
110
+ protected function _serializeValue($value)
111
+ {
112
+ if (is_array($value)) {
113
+ $data = array();
114
+ foreach ($value as $rule => $setup) {
115
+ if($rule == '__empty') {
116
+ continue;
117
+ }
118
+ if (!array_key_exists($rule, $data)) {
119
+ $data[$rule] = $setup;
120
+ }
121
+ }
122
+ return serialize($data);
123
+ } else {
124
+ return '';
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Create a value from a storable representation
130
+ *
131
+ * @param mixed $value
132
+ * @return array
133
+ */
134
+ protected function _unserializeValue($value)
135
+ {
136
+ if (is_string($value) && !empty($value)) {
137
+ return unserialize($value);
138
+ } else {
139
+ return array();
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Check whether value is in form retrieved by _encodeArrayFieldValue()
145
+ *
146
+ * @param mixed
147
+ * @return bool
148
+ */
149
+ protected function _isEncodedArrayFieldValue($value)
150
+ {
151
+ if (!is_array($value)) {
152
+ return false;
153
+ }
154
+ unset($value['__empty']);
155
+ foreach ($value as $_id => $row) {
156
+ if (!is_array($row) || !array_key_exists('attribute', $row)) {
157
+ return false;
158
+ }
159
+ }
160
+ return true;
161
+ }
162
+
163
+ /**
164
+ * Encode value to be used in Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
165
+ *
166
+ * @param array
167
+ * @return array
168
+ */
169
+ protected function _encodeArrayFieldValue(array $value)
170
+ {
171
+ $result = array();
172
+ foreach ($value as $set => $value) {
173
+ $_id = Mage::helper('core')->uniqHash('_');
174
+ $result[$_id] = $value;
175
+ }
176
+ return $result;
177
+ }
178
+
179
+ /**
180
+ * Decode value from used in Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
181
+ *
182
+ * @param array
183
+ * @return array
184
+ */
185
+ protected function _decodeArrayFieldValue(array $value)
186
+ {
187
+ $result = array();
188
+ unset($value['__empty']);
189
+ foreach ($value as $_id => $row) {
190
+ if (!is_array($row) || !array_key_exists('attribute', $row)) {
191
+ continue;
192
+ }
193
+ $result[trim($row['attribute'])] = $row;
194
+ }
195
+ return $result;
196
+ }
197
+
198
+ /**
199
+ * Make value readable by Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
200
+ *
201
+ * @param mixed $value
202
+ * @return array
203
+ */
204
+ public function makeArrayFieldValue($value)
205
+ {
206
+ $value = $this->_unserializeValue($value);
207
+ if (!$this->_isEncodedArrayFieldValue($value)) {
208
+ $value = $this->_encodeArrayFieldValue($value);
209
+ }
210
+ return $value;
211
+ }
212
+
213
+ /**
214
+ * Make value ready for store
215
+ *
216
+ * @param mixed $value
217
+ * @return string
218
+ */
219
+ public function makeStorableArrayFieldValue($value)
220
+ {
221
+ if ($this->_isEncodedArrayFieldValue($value)) {
222
+ $value = $this->_decodeArrayFieldValue($value);
223
+ }
224
+ $value = $this->_serializeValue($value);
225
+ return $value;
226
+ }
227
+
228
+ }
app/code/community/Flagbit/FactFinder/Helper/Data.php ADDED
@@ -0,0 +1,36 @@
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
+ * Helper class
12
+ *
13
+ * This helper class provides Translation Methods throw Magento Helper Abstract
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_Helper_Data extends Mage_Core_Helper_Abstract {
22
+
23
+ /**
24
+ * returns Module Status by Module Code
25
+ *
26
+ * @param string $code Module Code
27
+ * @return boolean
28
+ */
29
+ public function isModuleActive($code)
30
+ {
31
+ $module = Mage::getConfig()->getNode("modules/$code");
32
+ $model = Mage::getConfig()->getNode("global/models/$code");
33
+ return $module && $module->is('active') || $model;
34
+ }
35
+
36
+ }
app/code/community/Flagbit/FactFinder/Helper/Debug.php ADDED
@@ -0,0 +1,125 @@
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
+ * Helper class
12
+ *
13
+ * This helper class provides some Methods which allows us
14
+ * to debug Modul specific configurations Problems.
15
+ *
16
+ * @category Mage
17
+ * @package Flagbit_FactFinder
18
+ * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
19
+ * @author Joerg Weller <weller@flagbit.de>
20
+ * @version $Id$
21
+ */
22
+ class Flagbit_FactFinder_Helper_Debug extends Mage_Core_Helper_Abstract
23
+ implements FACTFinder_Logger_LoggerInterface
24
+ {
25
+ /**
26
+ * Module Configuration File
27
+ *
28
+ * @var string
29
+ */
30
+ const MODULE_CONFIG_FILE = 'config.xml';
31
+
32
+ /**
33
+ * Module Log File
34
+ *
35
+ * @var string
36
+ */
37
+ const LOG_FILE_NAME = 'factfinder.log';
38
+
39
+ /**
40
+ * XML Config Path to Product Identifier Setting
41
+ *
42
+ * @var string
43
+ */
44
+ const XML_CONFIG_PATH_DEBUG_MODE = 'factfinder/config/debug';
45
+
46
+ /**
47
+ * Debug Log to file var/log/factfinder.log
48
+ *
49
+ * @param $message
50
+ * @param $level
51
+ * @param $file
52
+ * @param $forceLog
53
+ */
54
+ public function log($message)
55
+ {
56
+ if (!Mage::getConfig()) {
57
+ return;
58
+ }
59
+ try{
60
+ if(Mage::getStoreConfig(self::XML_CONFIG_PATH_DEBUG_MODE)) {
61
+ return Mage::log($message, null, self::LOG_FILE_NAME, true);
62
+ }
63
+ }catch (Exception $e){}
64
+
65
+ return $this;
66
+ }
67
+
68
+ public function error($error)
69
+ {
70
+ return $this->log('ERROR: ' . $error);
71
+ }
72
+
73
+ public function info($message)
74
+ {
75
+ return $this->log('INFO: ' . $message);
76
+ }
77
+
78
+ /**
79
+ * get Class Rewrite Conflicts for the current Modul
80
+ *
81
+ * return array
82
+ */
83
+ public function getRewriteConflicts()
84
+ {
85
+ $rewriteConflicts = array();
86
+ $xml = simplexml_load_file(Mage::getConfig()->getModuleDir('etc', $this->_getModuleName()).DS.self::MODULE_CONFIG_FILE);
87
+ if ($xml instanceof SimpleXMLElement) {
88
+ $rewriteNodes = $xml->xpath('//rewrite');
89
+
90
+ foreach ($rewriteNodes as $n) {
91
+ $nParent = $n->xpath('..');
92
+ $module = (string) $nParent[0]->getName();
93
+ $nParent2 = $nParent[0]->xpath('..');
94
+ $component = (string) $nParent2[0]->getName();
95
+ $pathNodes = $n->children();
96
+
97
+ foreach ($pathNodes as $pathNode) {
98
+
99
+ $path = (string) $pathNode->getName();
100
+ $completePath = $module.'/'.$path;
101
+
102
+ $rewriteClassName = (string) $pathNode;
103
+
104
+ $instance = Mage::getConfig()->getGroupedClassName(
105
+ substr($component, 0, -1),
106
+ $completePath
107
+ );
108
+ if($instance != $rewriteClassName){
109
+
110
+ try{
111
+ $reflector = new $instance();
112
+ if($reflector instanceof $rewriteClassName){
113
+ continue;
114
+ }
115
+ }catch (Exception $e){}
116
+
117
+ $rewriteConflicts[$rewriteClassName] = $instance;
118
+ }
119
+ }
120
+ }
121
+ }
122
+ return $rewriteConflicts;
123
+ }
124
+
125
+ }
app/code/community/Flagbit/FactFinder/Helper/Search.php ADDED
@@ -0,0 +1,232 @@