Version Notes
new features:
* added support for FACT-Finder 6.8
* new Suggest template system
* including two new alternative suggest templates
* Suggest image size is configurable in backend
* Alternative slider template that uses script.aculo.us instead of Omikron's OneTouchSlider
* Secondary Channels (searching one or more additional database(s) - for example "content", "community" etc.)
* Use of parallel requests between Magento and FACT-Finder
* Parallel data exports are now prevented; this is relevant for large shops whose exports might take hours (and could be requested more frequently)
* Optional fallback to Magento in case of FACT-Finder server problems
* Added support for shopping cart campaigns
* extended error reporting at the installation process, for a better usability at the integration process
* FACT-Finder Configuration displays export link
* FACT-Finder version is configurable
bugfixes since last release:
* Explicit export attributes work now even if they are not searchable or filterable
* Click tracking for product details works now with automatic redirect for single result searches
* Click tracking for product details works now even if detail page is loaded very quickly
* HTML tags in export data will not result in unseparated words any more
Release Info
Developer | Magento Core Team |
Extension | Flagbit_Factfinder |
Version | 3.4.0 |
Comparing to | |
See all releases |
Code changes from version 3.3.12 to 3.4.0
- app/code/community/Flagbit/FactFinder/Block/Adminhtml/Cockpit.php +2 -2
- app/code/community/Flagbit/FactFinder/Block/Adminhtml/Exportlink.php +23 -7
- app/code/community/Flagbit/FactFinder/Block/Campaign/Advisory.php +8 -1
- app/code/community/Flagbit/FactFinder/Block/Campaign/Cart/Advisory.php +26 -21
- app/code/community/Flagbit/FactFinder/Block/Campaign/Cart/Feedback.php +18 -6
- app/code/community/Flagbit/FactFinder/Block/Campaign/Feedback.php +8 -1
- app/code/community/Flagbit/FactFinder/Block/Campaign/Product/Advisory.php +20 -8
- app/code/community/Flagbit/FactFinder/Block/Campaign/Product/Feedback.php +12 -3
- app/code/community/Flagbit/FactFinder/Block/Cart/Crosssell.php +23 -26
- app/code/community/Flagbit/FactFinder/Block/Layer.php +34 -13
- app/code/community/Flagbit/FactFinder/Block/Product/List/Crosssell.php +12 -3
- app/code/community/Flagbit/FactFinder/Block/Product/List/Upsell.php +23 -37
- app/code/community/Flagbit/FactFinder/Block/Secondaryresult.php +8 -3
- app/code/community/Flagbit/FactFinder/Block/TagCloud.php +35 -27
- app/code/community/Flagbit/FactFinder/Block/XmlConnect/Catalog/Search/Suggest.php +5 -3
- app/code/community/Flagbit/FactFinder/Helper/Backend.php +7 -7
- app/code/community/Flagbit/FactFinder/Helper/Search.php +164 -24
- app/code/community/Flagbit/FactFinder/Model/Adapter.php +0 -936
- app/code/community/Flagbit/FactFinder/Model/Export/Product.php +4 -4
- app/code/community/Flagbit/FactFinder/Model/Facade.php +377 -0
- app/code/community/Flagbit/FactFinder/Model/Handler/Abstract.php +45 -0
- app/code/community/Flagbit/FactFinder/Model/Handler/CheckStatus.php +141 -0
- app/code/community/Flagbit/FactFinder/Model/Handler/ProductCampaign.php +75 -0
- app/code/community/Flagbit/FactFinder/Model/Handler/ProductDetailCampaign.php +27 -0
- app/code/community/Flagbit/FactFinder/Model/Handler/Recommendations.php +51 -0
- app/code/community/Flagbit/FactFinder/Model/Handler/Search.php +424 -0
- app/code/community/Flagbit/FactFinder/Model/Handler/SecondarySearch.php +46 -0
- app/code/community/Flagbit/FactFinder/Model/Handler/ShoppingCartCampaign.php +27 -0
- app/code/community/Flagbit/FactFinder/Model/Handler/Suggest.php +106 -0
- app/code/community/Flagbit/FactFinder/Model/Handler/TagCloud.php +71 -0
- app/code/community/Flagbit/FactFinder/Model/Mysql4/Campaign/Pushedproducts/Collection.php +3 -3
- app/code/community/Flagbit/FactFinder/Model/Mysql4/Product/Attribute/Collection.php +6 -6
- app/code/community/Flagbit/FactFinder/Model/Mysql4/Search/Collection.php +11 -12
- app/code/community/Flagbit/FactFinder/Model/Observer.php +54 -12
- app/code/community/Flagbit/FactFinder/Model/Processor.php +22 -17
- app/code/community/Flagbit/FactFinder/Model/System/Config/Source/Ffversion.php +4 -0
- app/code/community/Flagbit/FactFinder/controllers/ExportController.php +52 -5
- app/code/community/Flagbit/FactFinder/controllers/ProxyController.php +1 -1
- app/code/community/Flagbit/FactFinder/etc/config.xml +14 -1
- app/code/community/Flagbit/FactFinder/etc/system.xml +46 -7
- app/design/adminhtml/default/default/template/factfinder/cockpit.phtml +22 -0
- app/design/frontend/base/default/layout/factfinder.xml +17 -8
- app/design/frontend/base/default/template/factfinder/campaign/product/advisory.phtml +0 -12
- app/design/frontend/base/default/template/factfinder/campaign/product/feedback.phtml +0 -6
- app/design/frontend/base/default/template/factfinder/filter/scriptaculousSlider.phtml +103 -0
- app/design/frontend/base/default/template/factfinder/form.advancedsuggest.phtml +95 -0
- app/design/frontend/base/default/template/factfinder/form.advancedsuggest68.phtml +103 -0
- app/design/frontend/base/default/template/factfinder/form.mini.phtml +23 -7
- app/design/frontend/base/default/template/factfinder/scic.phtml +2 -1
- app/locale/de_DE/Flagbit_FactFinder.csv +47 -17
- js/factfinder/scic.js +6 -2
- js/factfinder/suggest.js +63 -25
- lib/FACTFinder/Abstract/Adapter.php +10 -0
- lib/FACTFinder/Abstract/Configuration.php +65 -1
- lib/FACTFinder/Abstract/DataProvider.php +5 -2
- lib/FACTFinder/Abstract/RecommendationAdapter.php +19 -2
- lib/FACTFinder/Abstract/ScicAdapter.php +56 -29
- lib/FACTFinder/AsnGroup.php +14 -0
- lib/FACTFinder/Configuration.php +79 -0
- lib/FACTFinder/Http/DataProvider.php +182 -181
- lib/FACTFinder/Http/ParallelDataProvider.php +130 -33
- lib/FACTFinder/Http/ScicAdapter.php +7 -2
- lib/FACTFinder/Http/StatusHelper.php +153 -0
- lib/FACTFinder/Http/SuggestAdapter.php +2 -2
- lib/FACTFinder/Http/UrlBuilder.php +234 -0
- lib/FACTFinder/ProductsPerPageOptions.php +31 -11
- lib/FACTFinder/Xml65/ImportAdapter.php +2 -2
- lib/FACTFinder/Xml65/SearchAdapter.php +22 -2
- lib/FACTFinder/Xml65/SuggestAdapter.php +1 -1
- lib/FACTFinder/Xml65/TagCloudAdapter.php +1 -0
- lib/FACTFinder/Xml67/SearchAdapter.php +1 -1
- lib/FACTFinder/Xml68/CompareAdapter.php +19 -0
- lib/FACTFinder/Xml68/ImportAdapter.php +19 -0
- lib/FACTFinder/Xml68/ProductCampaignAdapter.php +20 -0
- lib/FACTFinder/Xml68/RecommendationAdapter.php +19 -0
- lib/FACTFinder/Xml68/SearchAdapter.php +19 -0
- lib/FACTFinder/Xml68/SimilarRecordsAdapter.php +19 -0
- lib/FACTFinder/Xml68/SuggestAdapter.php +20 -0
- lib/FACTFinder/Xml68/TagCloudAdapter.php +19 -0
- lib/FACTFinderCustom/Configuration.php +147 -9
- lib/SAI/Curl.php +100 -0
- lib/SAI/Curl/Handle.php +8 -0
- lib/SAI/CurlInterface.php +25 -0
- lib/SAI/CurlStub.php +382 -0
- package.xml +26 -7
- skin/frontend/base/default/css/factfinder.css +25 -0
@@ -25,9 +25,9 @@ class Flagbit_FactFinder_Block_Adminhtml_Cockpit extends Mage_Adminhtml_Block_Te
|
|
25 |
*
|
26 |
* @return string
|
27 |
*/
|
28 |
-
public function
|
29 |
{
|
30 |
-
return Mage::getSingleton('factfinder/
|
31 |
}
|
32 |
|
33 |
}
|
25 |
*
|
26 |
* @return string
|
27 |
*/
|
28 |
+
public function getManagementUrl()
|
29 |
{
|
30 |
+
return Mage::getSingleton('factfinder/facade')->getManagementUrl();
|
31 |
}
|
32 |
|
33 |
}
|
@@ -36,13 +36,29 @@ class Flagbit_FactFinder_Block_Adminhtml_Exportlink extends Mage_Adminhtml_Block
|
|
36 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
37 |
{
|
38 |
$this->setElement($element);
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
return $html;
|
47 |
}
|
48 |
}
|
36 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
37 |
{
|
38 |
$this->setElement($element);
|
39 |
+
$shopdomain = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
40 |
+
$activeStore = '';
|
41 |
+
$store = $this->getRequest()->getParam('store');
|
42 |
+
if(Mage::getStoreConfig('web/url/use_store'))
|
43 |
+
{
|
44 |
+
if ($store)
|
45 |
+
{
|
46 |
+
$activeStore = $store.'/';
|
47 |
+
}
|
48 |
+
else
|
49 |
+
{
|
50 |
+
$websites = Mage::app()->getWebsites();
|
51 |
+
$activeStore = $websites[1]->getDefaultStore()->getCode().'/';
|
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 = '';
|
59 |
+
$linktext = Mage::helper('factfinder')->__('Download export');
|
60 |
+
|
61 |
+
$html = '<a href="'.$shopdomain.$activeStore.'factfinder/export/product?key='.md5($password).$storeParam.'" target="_blank">'.$linktext.'</a>';
|
62 |
return $html;
|
63 |
}
|
64 |
}
|
@@ -2,6 +2,13 @@
|
|
2 |
|
3 |
class Flagbit_FactFinder_Block_Campaign_Advisory extends Mage_Core_Block_Template
|
4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
/**
|
6 |
* get Campaign Text
|
7 |
*
|
@@ -12,7 +19,7 @@ class Flagbit_FactFinder_Block_Campaign_Advisory extends Mage_Core_Block_Templat
|
|
12 |
$questions = array();
|
13 |
|
14 |
if(Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign')){
|
15 |
-
$_campaigns =
|
16 |
if($_campaigns && $_campaigns->hasActiveQuestions()){
|
17 |
$questions = $_campaigns->getActiveQuestions();
|
18 |
}
|
2 |
|
3 |
class Flagbit_FactFinder_Block_Campaign_Advisory extends Mage_Core_Block_Template
|
4 |
{
|
5 |
+
protected $_searchHandler;
|
6 |
+
|
7 |
+
protected function _prepareLayout()
|
8 |
+
{
|
9 |
+
$this->_searchHandler = Mage::getSingleton('factfinder/handler_search');
|
10 |
+
}
|
11 |
+
|
12 |
/**
|
13 |
* get Campaign Text
|
14 |
*
|
19 |
$questions = array();
|
20 |
|
21 |
if(Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign')){
|
22 |
+
$_campaigns = $this->_searchHandler->getCampaigns();
|
23 |
if($_campaigns && $_campaigns->hasActiveQuestions()){
|
24 |
$questions = $_campaigns->getActiveQuestions();
|
25 |
}
|
@@ -18,6 +18,21 @@
|
|
18 |
*/
|
19 |
class Flagbit_FactFinder_Block_Campaign_Cart_Advisory extends Mage_Core_Block_Template
|
20 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* get campaign questions and answers
|
23 |
*
|
@@ -27,30 +42,20 @@ class Flagbit_FactFinder_Block_Campaign_Cart_Advisory extends Mage_Core_Block_Te
|
|
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 |
-
|
42 |
-
|
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 |
}
|
18 |
*/
|
19 |
class Flagbit_FactFinder_Block_Campaign_Cart_Advisory extends Mage_Core_Block_Template
|
20 |
{
|
21 |
+
protected $_product;
|
22 |
+
protected $_productCampaignHandler;
|
23 |
+
|
24 |
+
protected function _prepareLayout()
|
25 |
+
{
|
26 |
+
$this->_product = Mage::getModel('catalog/product')->load(Mage::getSingleton('checkout/session')->getLastAddedProductId());
|
27 |
+
|
28 |
+
$productIds = array(
|
29 |
+
$this->_product->getData(Mage::helper('factfinder/search')->getIdFieldName())
|
30 |
+
);
|
31 |
+
|
32 |
+
$this->_productCampaignHandler = Mage::getSingleton('factfinder/handler_shoppingCartCampaign', array($productIds, true));
|
33 |
+
return parent::_prepareLayout();
|
34 |
+
}
|
35 |
+
|
36 |
/**
|
37 |
* get campaign questions and answers
|
38 |
*
|
42 |
{
|
43 |
Mage::getSingleton('core/session', array('name'=>'frontend'));
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
$questions = array();
|
46 |
+
|
47 |
+
if ($this->canCampaignBeDisplayed()) {
|
48 |
+
$questions = $this->_productCampaignHandler->getActiveAdvisorQuestions();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
|
51 |
return $questions;
|
52 |
}
|
53 |
+
|
54 |
+
protected function canCampaignBeDisplayed()
|
55 |
+
{
|
56 |
+
return
|
57 |
+
Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign') &&
|
58 |
+
Mage::getSingleton('checkout/session')->getLastAddedProductId() &&
|
59 |
+
$this->_product->getData(Mage::helper('factfinder/search')->getIdFieldName());
|
60 |
+
}
|
61 |
}
|
@@ -18,6 +18,21 @@
|
|
18 |
*/
|
19 |
class Flagbit_FactFinder_Block_Campaign_Cart_Feedback extends Mage_Core_Block_Template
|
20 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* get campaign questions and answers
|
23 |
*
|
@@ -33,15 +48,12 @@ class Flagbit_FactFinder_Block_Campaign_Cart_Feedback extends Mage_Core_Block_Te
|
|
33 |
}
|
34 |
|
35 |
$feedback = array();
|
36 |
-
|
37 |
-
|
38 |
-
if (!$_product->getData(Mage::helper('factfinder/search')->getIdFieldName())) {
|
39 |
return array();
|
40 |
}
|
41 |
|
42 |
-
$_campaigns =
|
43 |
-
$_product->getData(Mage::helper('factfinder/search')->getIdFieldName())
|
44 |
-
));
|
45 |
|
46 |
if($_campaigns && $_campaigns->hasFeedback()){
|
47 |
$feedback = $_campaigns;
|
18 |
*/
|
19 |
class Flagbit_FactFinder_Block_Campaign_Cart_Feedback extends Mage_Core_Block_Template
|
20 |
{
|
21 |
+
protected $_product;
|
22 |
+
protected $_productCampaignHandler;
|
23 |
+
|
24 |
+
protected function _prepareLayout()
|
25 |
+
{
|
26 |
+
$this->_product = Mage::getModel('catalog/product')->load(Mage::getSingleton('checkout/session')->getLastAddedProductId());
|
27 |
+
|
28 |
+
$productIds = array(
|
29 |
+
$this->_product->getData(Mage::helper('factfinder/search')->getIdFieldName())
|
30 |
+
);
|
31 |
+
|
32 |
+
$this->_productCampaignHandler = Mage::getSingleton('factfinder/handler_shoppingCartCampaign', array($productIds, true));
|
33 |
+
return parent::_prepareLayout();
|
34 |
+
}
|
35 |
+
|
36 |
/**
|
37 |
* get campaign questions and answers
|
38 |
*
|
48 |
}
|
49 |
|
50 |
$feedback = array();
|
51 |
+
|
52 |
+
if (!$this->_product->getData(Mage::helper('factfinder/search')->getIdFieldName())) {
|
|
|
53 |
return array();
|
54 |
}
|
55 |
|
56 |
+
$_campaigns = $this->_productCampaignHandler->getCampaigns();
|
|
|
|
|
57 |
|
58 |
if($_campaigns && $_campaigns->hasFeedback()){
|
59 |
$feedback = $_campaigns;
|
@@ -27,6 +27,13 @@ class Flagbit_FactFinder_Block_Campaign_Feedback extends Mage_Core_Block_Templat
|
|
27 |
*/
|
28 |
protected $_pushedProductsCollection = null;
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
/**
|
31 |
* get Campaign Text
|
32 |
*
|
@@ -37,7 +44,7 @@ class Flagbit_FactFinder_Block_Campaign_Feedback extends Mage_Core_Block_Templat
|
|
37 |
$text = '';
|
38 |
|
39 |
if(Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign')){
|
40 |
-
$_campaigns =
|
41 |
if($_campaigns && $_campaigns->hasFeedback() && $this->getTextNumber()){
|
42 |
$text = $_campaigns->getFeedback($this->getTextNumber() - 1);
|
43 |
}
|
27 |
*/
|
28 |
protected $_pushedProductsCollection = null;
|
29 |
|
30 |
+
protected $_searchHandler;
|
31 |
+
|
32 |
+
protected function _prepareLayout()
|
33 |
+
{
|
34 |
+
$this->_searchHandler = Mage::getSingleton('factfinder/handler_search');
|
35 |
+
}
|
36 |
+
|
37 |
/**
|
38 |
* get Campaign Text
|
39 |
*
|
44 |
$text = '';
|
45 |
|
46 |
if(Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign')){
|
47 |
+
$_campaigns = $this->_searchHandler->getCampaigns();
|
48 |
if($_campaigns && $_campaigns->hasFeedback() && $this->getTextNumber()){
|
49 |
$text = $_campaigns->getFeedback($this->getTextNumber() - 1);
|
50 |
}
|
@@ -18,6 +18,17 @@
|
|
18 |
*/
|
19 |
class Flagbit_FactFinder_Block_Campaign_Product_Advisory extends Mage_Core_Block_Template
|
20 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* get campaign questions and answers
|
23 |
*
|
@@ -27,16 +38,17 @@ class Flagbit_FactFinder_Block_Campaign_Product_Advisory extends Mage_Core_Block
|
|
27 |
{
|
28 |
$questions = array();
|
29 |
|
30 |
-
if
|
31 |
-
$
|
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 |
}
|
18 |
*/
|
19 |
class Flagbit_FactFinder_Block_Campaign_Product_Advisory extends Mage_Core_Block_Template
|
20 |
{
|
21 |
+
protected $_productCampaignHandler;
|
22 |
+
|
23 |
+
protected function _prepareLayout()
|
24 |
+
{
|
25 |
+
$productIds = array(
|
26 |
+
Mage::registry('current_product')->getData(Mage::helper('factfinder/search')->getIdFieldName())
|
27 |
+
);
|
28 |
+
$this->_productCampaignHandler = Mage::getSingleton('factfinder/handler_productDetailCampaign', $productIds);
|
29 |
+
return parent::_prepareLayout();
|
30 |
+
}
|
31 |
+
|
32 |
/**
|
33 |
* get campaign questions and answers
|
34 |
*
|
38 |
{
|
39 |
$questions = array();
|
40 |
|
41 |
+
if ($this->canCampaignBeDisplay()) {
|
42 |
+
$questions = $this->_productCampaignHandler->getActiveAdvisorQuestions();
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
44 |
|
45 |
return $questions;
|
46 |
}
|
47 |
+
|
48 |
+
protected function canCampaignBeDisplay()
|
49 |
+
{
|
50 |
+
return
|
51 |
+
Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign') &&
|
52 |
+
Mage::registry('current_product');
|
53 |
+
}
|
54 |
}
|
@@ -18,6 +18,17 @@
|
|
18 |
*/
|
19 |
class Flagbit_FactFinder_Block_Campaign_Product_Feedback extends Mage_Core_Block_Template
|
20 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* get campaign feedback
|
23 |
*
|
@@ -28,9 +39,7 @@ class Flagbit_FactFinder_Block_Campaign_Product_Feedback extends Mage_Core_Block
|
|
28 |
$feedback = array();
|
29 |
|
30 |
if (Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign') && Mage::registry('current_product')) {
|
31 |
-
$_campaigns =
|
32 |
-
Mage::registry('current_product')->getData(Mage::helper('factfinder/search')->getIdFieldName()),
|
33 |
-
));
|
34 |
|
35 |
if($_campaigns && $_campaigns->hasFeedback()){
|
36 |
$feedback = $_campaigns;
|
18 |
*/
|
19 |
class Flagbit_FactFinder_Block_Campaign_Product_Feedback extends Mage_Core_Block_Template
|
20 |
{
|
21 |
+
protected $_productCampaignHandler;
|
22 |
+
|
23 |
+
protected function _prepareLayout()
|
24 |
+
{
|
25 |
+
$productIds = array(
|
26 |
+
Mage::registry('current_product')->getData(Mage::helper('factfinder/search')->getIdFieldName())
|
27 |
+
);
|
28 |
+
$this->_productCampaignHandler = Mage::getSingleton('factfinder/handler_productDetailCampaign', $productIds);
|
29 |
+
return parent::_prepareLayout();
|
30 |
+
}
|
31 |
+
|
32 |
/**
|
33 |
* get campaign feedback
|
34 |
*
|
39 |
$feedback = array();
|
40 |
|
41 |
if (Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign') && Mage::registry('current_product')) {
|
42 |
+
$_campaigns = $this->_productCampaignHandler->getCampaigns();
|
|
|
|
|
43 |
|
44 |
if($_campaigns && $_campaigns->hasFeedback()){
|
45 |
$feedback = $_campaigns;
|
@@ -20,6 +20,15 @@
|
|
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 |
*/
|
@@ -31,35 +40,23 @@ class Flagbit_FactFinder_Block_Cart_Crosssell extends Mage_Checkout_Block_Cart_C
|
|
31 |
|
32 |
$items = $this->getData('items');
|
33 |
if (is_null($items)) {
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
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 |
}
|
20 |
*/
|
21 |
class Flagbit_FactFinder_Block_Cart_Crosssell extends Mage_Checkout_Block_Cart_Crosssell
|
22 |
{
|
23 |
+
protected $_recommendationsHandler;
|
24 |
+
|
25 |
+
protected function _prepareLayout()
|
26 |
+
{
|
27 |
+
$productIds = $this->_getCartProductIds();
|
28 |
+
$this->_recommendationsHandler = Mage::getSingleton('factfinder/handler_recommendations', $productIds);
|
29 |
+
return parent::_prepareLayout();
|
30 |
+
}
|
31 |
+
|
32 |
/**
|
33 |
* Overwritten function. Gets information from FACT-Finder Collection instead of product link collection.
|
34 |
*/
|
40 |
|
41 |
$items = $this->getData('items');
|
42 |
if (is_null($items)) {
|
43 |
+
$items = array();
|
44 |
+
$ninProductIds = $this->_getCartProductIds();
|
45 |
+
if ($ninProductIds) {
|
46 |
+
$collection = $this->_getCollection()
|
47 |
+
->setRecommendations($this->_recommendationsHandler->getRecommendations());
|
48 |
+
if (!empty($ninProductIds)) {
|
49 |
+
// Before FF 6.7 only one product id will be considered.
|
50 |
+
// In that case (only) it could happen that another product in the cart is among the
|
51 |
+
// recommendations.
|
52 |
+
// TODO: This filter does not seem to work.
|
53 |
+
$collection->addExcludeProductFilter($ninProductIds);
|
54 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
+
foreach ($collection as $item) {
|
57 |
+
$items[] = $item;
|
58 |
}
|
59 |
}
|
|
|
|
|
|
|
|
|
60 |
|
61 |
$this->setData('items', $items);
|
62 |
}
|
@@ -20,6 +20,9 @@
|
|
20 |
*/
|
21 |
class Flagbit_FactFinder_Block_Layer extends Flagbit_FactFinder_Block_Layer_Abstract
|
22 |
{
|
|
|
|
|
|
|
23 |
|
24 |
/**
|
25 |
* Prepare child blocks
|
@@ -27,24 +30,43 @@ class Flagbit_FactFinder_Block_Layer extends Flagbit_FactFinder_Block_Layer_Abst
|
|
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 =
|
34 |
if($redirect){
|
35 |
Mage::app()->getResponse()->setRedirect($redirect);
|
36 |
}
|
37 |
}
|
|
|
38 |
|
39 |
-
|
40 |
-
|
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 |
|
@@ -55,12 +77,12 @@ class Flagbit_FactFinder_Block_Layer extends Flagbit_FactFinder_Block_Layer_Abst
|
|
55 |
$filterBlockName = $this->_getAttributeFilterBlockName();
|
56 |
|
57 |
$filterBlock = $this->getLayout()->createBlock($filterBlockName)
|
58 |
-
|
59 |
-
|
60 |
-
|
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'));
|
@@ -70,13 +92,12 @@ class Flagbit_FactFinder_Block_Layer extends Flagbit_FactFinder_Block_Layer_Abst
|
|
70 |
$filterBlock->setUnit($attribute->getUnit());
|
71 |
break;
|
72 |
}
|
73 |
-
|
74 |
$this->setChild($attribute->getAttributeCode().'_filter', $filterBlock);
|
75 |
}
|
76 |
-
|
77 |
$this->getLayer()->apply();
|
78 |
-
|
79 |
-
}
|
80 |
|
81 |
/**
|
82 |
* Get category filter block
|
20 |
*/
|
21 |
class Flagbit_FactFinder_Block_Layer extends Flagbit_FactFinder_Block_Layer_Abstract
|
22 |
{
|
23 |
+
protected $_searchHandler;
|
24 |
+
|
25 |
+
protected $_usesAsn = false;
|
26 |
|
27 |
/**
|
28 |
* Prepare child blocks
|
30 |
* @return Mage_Catalog_Block_Layer_View
|
31 |
*/
|
32 |
protected function _prepareLayout()
|
33 |
+
{
|
34 |
+
$this->_searchHandler = Mage::getSingleton('factfinder/handler_search');
|
35 |
+
|
36 |
+
$this->_usesAsn = Mage::helper('factfinder/search')->getIsEnabled(false, 'asn');
|
37 |
+
|
38 |
+
if(!$this->_usesAsn){
|
39 |
+
return parent::_prepareLayout();
|
40 |
+
}
|
41 |
+
|
42 |
+
// Make this block globally known so that initializeAfterSearchNavigation can be called on this instance
|
43 |
+
// when the controller_action_layout_generate_blocks_after event is fired
|
44 |
+
Mage::register(Flagbit_FactFinder_Model_Observer::_asnBlockRegistryKey, $this);
|
45 |
+
|
46 |
+
return Mage_Core_Block_Template::_prepareLayout();
|
47 |
+
}
|
48 |
+
|
49 |
+
public function handleCampaignRedirect()
|
50 |
{
|
51 |
if(Mage::helper('factfinder/search')->getIsEnabled(false, 'campaign')){
|
52 |
// handle redirects
|
53 |
+
$redirect = $this->_searchHandler->getRedirect();
|
54 |
if($redirect){
|
55 |
Mage::app()->getResponse()->setRedirect($redirect);
|
56 |
}
|
57 |
}
|
58 |
+
}
|
59 |
|
60 |
+
public function initializeAfterSearchNavigation()
|
61 |
+
{
|
62 |
+
if(!$this->_usesAsn)
|
63 |
+
return;
|
64 |
|
65 |
// set default sort Order
|
66 |
if(Mage::getSingleton('catalog/session')->getSortOrder()){
|
67 |
Mage::getSingleton('catalog/session')->setSortOrder('relevance');
|
68 |
}
|
69 |
+
|
70 |
$stateBlock = $this->getLayout()->createBlock('catalog/layer_state')
|
71 |
->setLayer($this->getLayer());
|
72 |
|
77 |
$filterBlockName = $this->_getAttributeFilterBlockName();
|
78 |
|
79 |
$filterBlock = $this->getLayout()->createBlock($filterBlockName)
|
80 |
+
->setLayer($this->getLayer())
|
81 |
+
->setAttributeModel($attribute)
|
82 |
+
->init();
|
83 |
|
84 |
switch($attribute->getType()){
|
85 |
+
|
86 |
case 'slider':
|
87 |
if(!($this->getLayout()->getBlock('ffslider') instanceof Flagbit_FactFinder_Block_Filter_Slider)){
|
88 |
$this->getLayout()->getBlock('head')->setChild('ffslider', $this->getLayout()->createBlock('factfinder/filter_slider'));
|
92 |
$filterBlock->setUnit($attribute->getUnit());
|
93 |
break;
|
94 |
}
|
95 |
+
|
96 |
$this->setChild($attribute->getAttributeCode().'_filter', $filterBlock);
|
97 |
}
|
98 |
+
|
99 |
$this->getLayer()->apply();
|
100 |
+
}
|
|
|
101 |
|
102 |
/**
|
103 |
* Get category filter block
|
@@ -20,6 +20,16 @@
|
|
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 |
*/
|
@@ -40,9 +50,8 @@ class Flagbit_FactFinder_Block_Product_List_Crosssell extends Mage_Catalog_Block
|
|
40 |
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
41 |
->addStoreFilter();
|
42 |
|
43 |
-
$
|
44 |
-
|
45 |
-
$recommendations = $recommendationAdapter->getRecommendations();
|
46 |
$this->_itemCollection->setRecommendations($recommendations);
|
47 |
|
48 |
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
|
20 |
*/
|
21 |
class Flagbit_FactFinder_Block_Product_List_Crosssell extends Mage_Catalog_Block_Product_List_Crosssell
|
22 |
{
|
23 |
+
protected $_recommendationsHandler;
|
24 |
+
|
25 |
+
protected function _prepareLayout()
|
26 |
+
{
|
27 |
+
$productIds = array(
|
28 |
+
Mage::registry('product')->getData(Mage::helper('factfinder/search')->getIdFieldName())
|
29 |
+
);
|
30 |
+
$this->_recommendationsHandler = Mage::getSingleton('factfinder/handler_recommendations', $productIds);
|
31 |
+
return parent::_prepareLayout();
|
32 |
+
}
|
33 |
/**
|
34 |
* Method overwritten. Data is not read from product link collection but from FACT-Finder interface instead.
|
35 |
*/
|
50 |
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
51 |
->addStoreFilter();
|
52 |
|
53 |
+
$recommendations = $this->_recommendationsHandler->getRecommendations();
|
54 |
+
|
|
|
55 |
$this->_itemCollection->setRecommendations($recommendations);
|
56 |
|
57 |
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
|
@@ -21,6 +21,19 @@
|
|
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 |
*/
|
@@ -33,7 +46,7 @@ class Flagbit_FactFinder_Block_Product_List_Upsell extends Mage_Catalog_Block_Pr
|
|
33 |
|
34 |
$recommendations = array();
|
35 |
if (Mage::getStoreConfigFlag('factfinder/activation/upsell')) {
|
36 |
-
$recommendations = $this->getRecommendations();
|
37 |
}
|
38 |
|
39 |
// if there are no recommendations or pushed products, use default magento upselling
|
@@ -99,49 +112,22 @@ class Flagbit_FactFinder_Block_Product_List_Upsell extends Mage_Catalog_Block_Pr
|
|
99 |
}
|
100 |
}
|
101 |
|
102 |
-
/**
|
103 |
-
* get products from the ff recommendation engine
|
104 |
-
*
|
105 |
-
* @return array (ArrayIterator)
|
106 |
-
*/
|
107 |
-
protected function getRecommendations()
|
108 |
-
{
|
109 |
-
$recommendations = array();
|
110 |
-
try {
|
111 |
-
$product = Mage::registry('product');
|
112 |
-
/* @var $product Mage_Catalog_Model_Product */
|
113 |
-
|
114 |
-
$searchHelper = Mage::helper('factfinder/search');
|
115 |
-
$idFieldName = $searchHelper->getIdFieldName();
|
116 |
-
|
117 |
-
$recommendationAdapter = Mage::getModel('factfinder/adapter')->getRecommendationAdapter();
|
118 |
-
$recommendationAdapter->setProductId($product->getData($idFieldName));
|
119 |
-
$recommendations = $recommendationAdapter->getRecommendations();
|
120 |
-
}
|
121 |
-
catch (Exception $e) {
|
122 |
-
Mage::logException($e);
|
123 |
-
}
|
124 |
-
return $recommendations;
|
125 |
-
}
|
126 |
-
|
127 |
/**
|
128 |
* get pushed products to combine with recommendations
|
129 |
*
|
130 |
* @return array
|
131 |
*/
|
132 |
-
protected function getPushedProducts()
|
133 |
{
|
134 |
$pushedProducts = array();
|
135 |
-
|
136 |
-
$_campaigns = Mage::helper('factfinder/search')->getProductCampaigns(array(
|
137 |
-
Mage::registry('current_product')->getData(Mage::helper('factfinder/search')->getIdFieldName()),
|
138 |
-
));
|
139 |
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
146 |
|
147 |
}
|
21 |
*/
|
22 |
class Flagbit_FactFinder_Block_Product_List_Upsell extends Mage_Catalog_Block_Product_List_Upsell
|
23 |
{
|
24 |
+
protected $_productCampaignHandler;
|
25 |
+
protected $_recommendationsHandler;
|
26 |
+
|
27 |
+
protected function _prepareLayout()
|
28 |
+
{
|
29 |
+
$productIds = array(
|
30 |
+
Mage::registry('current_product')->getData(Mage::helper('factfinder/search')->getIdFieldName())
|
31 |
+
);
|
32 |
+
$this->_productCampaignHandler = Mage::getSingleton('factfinder/handler_productDetailCampaign', $productIds);
|
33 |
+
$this->_recommendationsHandler = Mage::getSingleton('factfinder/handler_recommendations', $productIds);
|
34 |
+
return parent::_prepareLayout();
|
35 |
+
}
|
36 |
+
|
37 |
/**
|
38 |
* Method overwritten. Data is not read from product link collection but from FACT-Finder interface instead.
|
39 |
*/
|
46 |
|
47 |
$recommendations = array();
|
48 |
if (Mage::getStoreConfigFlag('factfinder/activation/upsell')) {
|
49 |
+
$recommendations = $this->_recommendationsHandler->getRecommendations();
|
50 |
}
|
51 |
|
52 |
// if there are no recommendations or pushed products, use default magento upselling
|
112 |
}
|
113 |
}
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
/**
|
116 |
* get pushed products to combine with recommendations
|
117 |
*
|
118 |
* @return array
|
119 |
*/
|
120 |
+
protected function getPushedProducts()
|
121 |
{
|
122 |
$pushedProducts = array();
|
|
|
|
|
|
|
|
|
123 |
|
124 |
+
$_campaigns = $this->_productCampaignHandler->getCampaigns();
|
125 |
+
|
126 |
+
if($_campaigns && $_campaigns->hasPushedProducts()){
|
127 |
+
$pushedProducts = $_campaigns->getPushedProducts();
|
128 |
+
}
|
129 |
+
|
130 |
+
return $pushedProducts;
|
131 |
+
}
|
132 |
|
133 |
}
|
@@ -1,11 +1,16 @@
|
|
1 |
<?php
|
2 |
class Flagbit_FactFinder_Block_Secondaryresult extends Mage_Core_Block_Template
|
3 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
protected function getSecondaryResult($channel)
|
5 |
{
|
6 |
-
|
7 |
-
|
8 |
-
$result = $adapter->getSecondarySearchResult($channel);
|
9 |
|
10 |
return $result;
|
11 |
}
|
1 |
<?php
|
2 |
class Flagbit_FactFinder_Block_Secondaryresult extends Mage_Core_Block_Template
|
3 |
{
|
4 |
+
protected $_searchHandler;
|
5 |
+
|
6 |
+
protected function _prepareLayout()
|
7 |
+
{
|
8 |
+
$this->_searchHandler = Mage::getSingleton('factfinder/handler_secondarySearch');
|
9 |
+
}
|
10 |
+
|
11 |
protected function getSecondaryResult($channel)
|
12 |
{
|
13 |
+
$result = $this->_searchHandler->getSecondarySearchResult($channel);
|
|
|
|
|
14 |
|
15 |
return $result;
|
16 |
}
|
@@ -1,6 +1,20 @@
|
|
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')) {
|
@@ -8,37 +22,31 @@ class Flagbit_FactFinder_Block_TagCloud extends Mage_CatalogSearch_Block_Term
|
|
8 |
}
|
9 |
|
10 |
if (empty($this->_terms)) {
|
11 |
-
$
|
12 |
|
13 |
-
if (count($
|
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 |
}
|
1 |
<?php
|
2 |
class Flagbit_FactFinder_Block_TagCloud extends Mage_CatalogSearch_Block_Term
|
3 |
{
|
4 |
+
/**
|
5 |
+
* @var Flagbit_FactFinder_Model_Handler_TagCloud
|
6 |
+
*/
|
7 |
+
protected $_tagCloudHandler;
|
8 |
+
|
9 |
+
protected function _prepareLayout()
|
10 |
+
{
|
11 |
+
$this->_tagCloudHandler = Mage::getSingleton('factfinder/handler_tagCloud');
|
12 |
+
return parent::_prepareLayout();
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @return Flagbit_FactFinder_Block_TagCloud|Mage_CatalogSearch_Block_Term
|
17 |
+
*/
|
18 |
protected function _loadTerms()
|
19 |
{
|
20 |
if (!Mage::helper('factfinder/search')->getIsEnabled(false, 'tagcloud')) {
|
22 |
}
|
23 |
|
24 |
if (empty($this->_terms)) {
|
25 |
+
$this->_terms = $this->_tagCloudHandler->getTerms();
|
26 |
|
27 |
+
if (count($this->_terms) == 0)
|
28 |
return $this;
|
29 |
+
|
30 |
+
$this->determineMinMaxPopularity();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
return $this;
|
34 |
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Determines minimum and maximum popularity among terms
|
38 |
+
*/
|
39 |
+
protected function determineMinMaxPopularity()
|
40 |
+
{
|
41 |
+
$this->_maxPopularity = 0;
|
42 |
+
$this->_minPopularity = 1;
|
43 |
+
|
44 |
+
foreach ($this->_terms as $term) {
|
45 |
+
if ($term->getPopularity() > $this->_maxPopularity)
|
46 |
+
$this->_maxPopularity = $term->getPopularity();
|
47 |
+
|
48 |
+
if ($term->getPopularity() < $this->_minPopularity)
|
49 |
+
$this->_minPopularity = $term->getPopularity();
|
50 |
+
}
|
51 |
+
}
|
52 |
}
|
@@ -33,9 +33,11 @@ class Flagbit_FactFinder_Block_XmlConnect_Catalog_Search_Suggest extends Mage_Xm
|
|
33 |
if (!$this->getRequest()->getParam('q', false)) {
|
34 |
return $suggestXmlObj->asNiceXml();
|
35 |
}
|
36 |
-
|
37 |
-
$
|
38 |
-
|
|
|
|
|
39 |
if (!($count = count($suggestData))) {
|
40 |
return $suggestXmlObj->asNiceXml();
|
41 |
}
|
33 |
if (!$this->getRequest()->getParam('q', false)) {
|
34 |
return $suggestXmlObj->asNiceXml();
|
35 |
}
|
36 |
+
|
37 |
+
$handler = Mage::getSingleton('factfinder/handler_suggest', array($this->getRequest()->getParam('q')));
|
38 |
+
|
39 |
+
$suggestData = $handler->getSuggestionsAsArray();
|
40 |
+
|
41 |
if (!($count = count($suggestData))) {
|
42 |
return $suggestXmlObj->asNiceXml();
|
43 |
}
|
@@ -32,21 +32,21 @@ class Flagbit_FactFinder_Helper_Backend extends Mage_Core_Helper_Abstract
|
|
32 |
$errors = array();
|
33 |
|
34 |
if (stripos($data->getAddress(), 'http://') === 0 || strpos($data->getAddress(), '/') !== false) {
|
35 |
-
$errors[] = Mage::helper('factfinder')->__('
|
36 |
}
|
37 |
|
38 |
if ($data->getPort() == '') {
|
39 |
$port = 80;
|
40 |
}
|
41 |
elseif (!is_numeric($data->getPort())) {
|
42 |
-
$errors[] = Mage::helper('factfinder')->__('
|
43 |
}
|
44 |
elseif(intval($data->getPort()) < 80) { //is there any http port lower 80?
|
45 |
-
$errors[] = Mage::helper('factfinder')->__('
|
46 |
}
|
47 |
|
48 |
if ($data->getAuthPassword() != '' && $data->getAuthUser() == '') {
|
49 |
-
$errors[] = Mage::helper('factfinder')->__('
|
50 |
}
|
51 |
|
52 |
$conflicts = Mage::helper('factfinder/debug')->getRewriteConflicts();
|
@@ -57,9 +57,9 @@ class Flagbit_FactFinder_Helper_Backend extends Mage_Core_Helper_Abstract
|
|
57 |
}
|
58 |
|
59 |
if (count($errors) == 0) {
|
60 |
-
$
|
61 |
-
if(!$
|
62 |
-
$errors
|
63 |
}
|
64 |
}
|
65 |
|
32 |
$errors = array();
|
33 |
|
34 |
if (stripos($data->getAddress(), 'http://') === 0 || strpos($data->getAddress(), '/') !== false) {
|
35 |
+
$errors[] = Mage::helper('factfinder')->__('The server name should contain only 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 an integer!');
|
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 an integer greater or equals 80!');
|
46 |
}
|
47 |
|
48 |
if ($data->getAuthPassword() != '' && $data->getAuthUser() == '') {
|
49 |
+
$errors[] = Mage::helper('factfinder')->__('A user name must be provided if a password is to be used.');
|
50 |
}
|
51 |
|
52 |
$conflicts = Mage::helper('factfinder/debug')->getRewriteConflicts();
|
57 |
}
|
58 |
|
59 |
if (count($errors) == 0) {
|
60 |
+
$checkStatusHandler = Mage::getSingleton('factfinder/handler_checkStatus', $dataArray);
|
61 |
+
if(!$checkStatusHandler->checkStatus($data->getFfversion())){
|
62 |
+
$errors = $checkStatusHandler->getErrorMessages();
|
63 |
}
|
64 |
}
|
65 |
|
@@ -34,7 +34,17 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
|
|
34 |
* @var string
|
35 |
*/
|
36 |
const XML_CONFIG_PATH_USE_PROXY = 'factfinder/config/proxy';
|
|
|
|
|
|
|
|
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
/**
|
39 |
* if FACT-Finder enabled?
|
40 |
*
|
@@ -44,7 +54,8 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
|
|
44 |
{
|
45 |
if (!Mage::getStoreConfigFlag('factfinder/search/enabled')
|
46 |
|| Mage::getStoreConfigFlag('advanced/modules_disable_output/Flagbit_FactFinder')
|
47 |
-
|| ($searchPageCheck == true && !$this->getIsOnSearchPage() && !Mage::getStoreConfigFlag('factfinder/activation/navigation
|
|
|
48 |
return false;
|
49 |
}
|
50 |
|
@@ -77,6 +88,154 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
|
|
77 |
|
78 |
return $result;
|
79 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
/**
|
82 |
* get Module Status depending on Module
|
@@ -137,14 +296,16 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
|
|
137 |
*/
|
138 |
public function getSuggestUrl()
|
139 |
{
|
140 |
-
|
141 |
if (Mage::getStoreConfig(self::XML_CONFIG_PATH_USE_PROXY)) {
|
142 |
$params = array();
|
143 |
if (Mage::app()->getStore()->isCurrentlySecure()) {
|
144 |
$params['_secure'] = true;
|
145 |
}
|
146 |
$url = $this->_getUrl('factfinder/proxy/suggest', $params);
|
147 |
-
}
|
|
|
|
|
148 |
return $url;
|
149 |
}
|
150 |
|
@@ -212,25 +373,4 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
|
|
212 |
{
|
213 |
return Mage::helper('catalogsearch')->getQueryText();
|
214 |
}
|
215 |
-
|
216 |
-
|
217 |
-
/**
|
218 |
-
* return product campaings
|
219 |
-
*
|
220 |
-
* @param array $productIds
|
221 |
-
* @return FACTFinder_CampaignIterator
|
222 |
-
*/
|
223 |
-
public function getProductCampaigns($productIds)
|
224 |
-
{
|
225 |
-
try {
|
226 |
-
// get productcampaign adapter and set product id or sku array
|
227 |
-
$productCampaignAdapter = Mage::getModel('factfinder/adapter')->getProductCampaignAdapter();
|
228 |
-
$productCampaignAdapter->setProductIds($productIds);
|
229 |
-
$productCampaignAdapter->makeProductCampaign();
|
230 |
-
|
231 |
-
return $productCampaignAdapter->getCampaigns();
|
232 |
-
} catch(Exception $e) {
|
233 |
-
return array();
|
234 |
-
}
|
235 |
-
}
|
236 |
}
|
34 |
* @var string
|
35 |
*/
|
36 |
const XML_CONFIG_PATH_USE_PROXY = 'factfinder/config/proxy';
|
37 |
+
|
38 |
+
const CACHE_TAG = 'FACTFINDER';
|
39 |
+
const CACHE_ID = "FallbackCache";
|
40 |
+
const REQUEST_ID_PREFIX = 'FACTFINDER_';
|
41 |
|
42 |
+
protected static $_skipFactFinder = null;
|
43 |
+
|
44 |
+
protected static $_isFallbackActive = null;
|
45 |
+
|
46 |
+
protected static $_failedAttemptRegistered = false;
|
47 |
+
|
48 |
/**
|
49 |
* if FACT-Finder enabled?
|
50 |
*
|
54 |
{
|
55 |
if (!Mage::getStoreConfigFlag('factfinder/search/enabled')
|
56 |
|| Mage::getStoreConfigFlag('advanced/modules_disable_output/Flagbit_FactFinder')
|
57 |
+
|| ($searchPageCheck == true && !$this->getIsOnSearchPage() && !Mage::getStoreConfigFlag('factfinder/activation/navigation'))
|
58 |
+
|| $this->_skipFactFinder()) {
|
59 |
return false;
|
60 |
}
|
61 |
|
88 |
|
89 |
return $result;
|
90 |
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Determines whether the fallback should be used
|
94 |
+
*
|
95 |
+
* @return bool
|
96 |
+
**/
|
97 |
+
protected function _isFallbackActive()
|
98 |
+
{
|
99 |
+
if(self::$_isFallbackActive === null)
|
100 |
+
{
|
101 |
+
self::$_isFallbackActive = Mage::getStoreConfig('factfinder/fallback/use_fallback');
|
102 |
+
}
|
103 |
+
|
104 |
+
return self::$_isFallbackActive;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Determines whether FACT-Finder should be skipped completely, because it has failed to respond too often
|
109 |
+
* The check is made lazily so that it will return the same result for every call during one request to Magento.
|
110 |
+
*
|
111 |
+
* @return bool
|
112 |
+
**/
|
113 |
+
protected function _skipFactFinder()
|
114 |
+
{
|
115 |
+
if(self::$_skipFactFinder === null)
|
116 |
+
{
|
117 |
+
if(!$this->_isFallbackActive())
|
118 |
+
{
|
119 |
+
self::$_skipFactFinder = false;
|
120 |
+
}
|
121 |
+
else
|
122 |
+
{
|
123 |
+
$failedAttempts = $this->_loadFailedAttempts();
|
124 |
+
$failedAttempts = $this->_removeOldEntries($failedAttempts);
|
125 |
+
$this->saveFailedAttempts($failedAttempts);
|
126 |
+
|
127 |
+
self::$_skipFactFinder = (count($failedAttempts) >= 3);
|
128 |
+
|
129 |
+
if(self::$_skipFactFinder)
|
130 |
+
{
|
131 |
+
Mage::helper('factfinder/debug')->log('Failed to connect to FACT-Finder 3 times. Falling back to Magento\'s search.');
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
return self::$_skipFactFinder;
|
137 |
+
}
|
138 |
+
|
139 |
+
protected function _getCacheId()
|
140 |
+
{
|
141 |
+
return self::REQUEST_ID_PREFIX . self::CACHE_ID;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Registers that FACT-Finder has failed to respond.
|
146 |
+
* The attempt will be represented as an integer corresponding to attempt's timestamp in minutes.
|
147 |
+
* Only one failed attempt per lifetime of this object will be registered.
|
148 |
+
**/
|
149 |
+
public function registerFailedAttempt()
|
150 |
+
{
|
151 |
+
if(self::$_failedAttemptRegistered)
|
152 |
+
return;
|
153 |
+
|
154 |
+
$failedAttempts = $this->_loadFailedAttempts();
|
155 |
+
$failedAttempts[] = intval(time() / 60);
|
156 |
+
$this->saveFailedAttempts($failedAttempts);
|
157 |
+
|
158 |
+
self::$_failedAttemptRegistered = true;
|
159 |
+
|
160 |
+
Mage::helper('factfinder/debug')->log('Registered failed attempt to connect to FACT-Finder. '.count($failedAttempts).' failed attempts registered.');
|
161 |
+
if(count($failedAttempts) >= 3)
|
162 |
+
{
|
163 |
+
$delay = Mage::getStoreConfig('factfinder/fallback/wait_time');
|
164 |
+
|
165 |
+
$title = 'FACT-Finder unreachable! Falling back to Magento\'s search for '.$delay.' minutes.';
|
166 |
+
$message = 'FACT-Finder did not respond for the third time. Magento will now use its own search for '.$delay.' minutes before trying to reach FACT-Finder again. If the problem persists, please check your FACT-Finder server and the settings in Magento\'s FACT-Finder configuration.';
|
167 |
+
|
168 |
+
$versionInfo = Mage::getVersionInfo();
|
169 |
+
|
170 |
+
if ($versionInfo['major'] > 1 ||
|
171 |
+
$versionInfo['major'] >= 1 &&
|
172 |
+
$versionInfo['minor'] >= 7)
|
173 |
+
{
|
174 |
+
Mage::getModel('adminnotification/inbox')->addMajor($title, $message);
|
175 |
+
}
|
176 |
+
else
|
177 |
+
{
|
178 |
+
$severity = Mage_AdminNotification_Model_Inbox::SEVERITY_MAJOR;
|
179 |
+
|
180 |
+
$date = date('Y-m-d H:i:s');
|
181 |
+
Mage::getModel('adminnotification/inbox')->parse(array(
|
182 |
+
array(
|
183 |
+
'severity' => $severity,
|
184 |
+
'date_added' => $date,
|
185 |
+
'title' => $title,
|
186 |
+
'description' => $message,
|
187 |
+
'url' => '',
|
188 |
+
'internal' => true
|
189 |
+
)
|
190 |
+
));
|
191 |
+
}
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Loads previously registered failed attempts from cache, if they exist.
|
197 |
+
* Returns an empty array, otherwise.
|
198 |
+
*
|
199 |
+
* @return array of int
|
200 |
+
**/
|
201 |
+
protected function _loadFailedAttempts()
|
202 |
+
{
|
203 |
+
$cachedContent = Mage::app()->loadCache($this->_getCacheId());
|
204 |
+
$failedAttempts = array();
|
205 |
+
if($cachedContent)
|
206 |
+
$failedAttempts = unserialize($cachedContent);
|
207 |
+
|
208 |
+
return $failedAttempts;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Save failed attempts to cache.
|
213 |
+
*
|
214 |
+
* @param array of int failed attempts
|
215 |
+
**/
|
216 |
+
public function saveFailedAttempts($failedAttempts)
|
217 |
+
{
|
218 |
+
Mage::app()->saveCache(serialize($failedAttempts), $this->_getCacheId(), array(self::CACHE_TAG));
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Removes entries from a list of minute-timestamps which are older than a given delay set within the configuration
|
223 |
+
*
|
224 |
+
* @param array of int entries
|
225 |
+
**/
|
226 |
+
protected function _removeOldEntries($entries)
|
227 |
+
{
|
228 |
+
$delay = Mage::getStoreConfig('factfinder/fallback/wait_time');
|
229 |
+
$newEntries = array();
|
230 |
+
|
231 |
+
foreach($entries as $entry)
|
232 |
+
{
|
233 |
+
if(intval(time() / 60) - $entry < $delay)
|
234 |
+
$newEntries[] = $entry;
|
235 |
+
}
|
236 |
+
|
237 |
+
return $newEntries;
|
238 |
+
}
|
239 |
|
240 |
/**
|
241 |
* get Module Status depending on Module
|
296 |
*/
|
297 |
public function getSuggestUrl()
|
298 |
{
|
299 |
+
|
300 |
if (Mage::getStoreConfig(self::XML_CONFIG_PATH_USE_PROXY)) {
|
301 |
$params = array();
|
302 |
if (Mage::app()->getStore()->isCurrentlySecure()) {
|
303 |
$params['_secure'] = true;
|
304 |
}
|
305 |
$url = $this->_getUrl('factfinder/proxy/suggest', $params);
|
306 |
+
} else {
|
307 |
+
$url = Mage::getSingleton('factfinder/facade')->getSuggestUrl();
|
308 |
+
}
|
309 |
return $url;
|
310 |
}
|
311 |
|
373 |
{
|
374 |
return Mage::helper('catalogsearch')->getQueryText();
|
375 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
}
|
@@ -1,936 +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 |
-
require_once BP.DS.'lib'.DS.'FACTFinder'.DS.'Loader.php';
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Model class
|
14 |
-
*
|
15 |
-
* Adapter between FACT-Finder API Framework and Magento
|
16 |
-
*
|
17 |
-
* @category Mage
|
18 |
-
* @package Flagbit_FactFinder
|
19 |
-
* @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
|
20 |
-
* @author Joerg Weller <weller@flagbit.de>
|
21 |
-
* @version $Id: Adapter.php 906 2011-09-30 14:10:05Z tuerk $
|
22 |
-
*/
|
23 |
-
class Flagbit_FactFinder_Model_Adapter
|
24 |
-
{
|
25 |
-
|
26 |
-
/**
|
27 |
-
* FACT-Finder Searchadapter
|
28 |
-
* @var FACTFinder_Abstract_SearchAdapter
|
29 |
-
*/
|
30 |
-
protected $_searchAdapter = null;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* FACT-Finder Suggestadapter
|
34 |
-
* @var FACTFinder_Abstract_SuggestAdapter
|
35 |
-
*/
|
36 |
-
protected $_suggestAdapter = null;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* FACT-Finder Config
|
40 |
-
* @var FACTFinder_Abstract_Configuration
|
41 |
-
*/
|
42 |
-
protected $_config = null;
|
43 |
-
|
44 |
-
/**
|
45 |
-
* FACT-Finder Parameter Parser
|
46 |
-
* @var FACTFinder_ParametersParser
|
47 |
-
*/
|
48 |
-
protected $_paramsParser = null;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* FACT-Finder Data Provider
|
52 |
-
* @var FACTFinder_Abstract_DataProvider
|
53 |
-
*/
|
54 |
-
protected $_dataProvider = null;
|
55 |
-
|
56 |
-
/**
|
57 |
-
* FACT-Finder Scic Adapter
|
58 |
-
* @var FACTFinder_Abstract_ScicAdapter
|
59 |
-
*/
|
60 |
-
protected $_scicAdapter = null;
|
61 |
-
|
62 |
-
/**
|
63 |
-
* FACT-Finder Recommendation Adapter
|
64 |
-
* @var FACTFinder_Abstract_RecommendationAdapter
|
65 |
-
*/
|
66 |
-
protected $_recommendationAdapter = null;
|
67 |
-
|
68 |
-
/**
|
69 |
-
* FACT-Finder Product Campaign Adapter
|
70 |
-
* @var FACTFinder_Abstract_ProductCampaignAdapter
|
71 |
-
*/
|
72 |
-
protected $_productCampaignAdapter = null;
|
73 |
-
|
74 |
-
/**
|
75 |
-
* FACT-Finder TagCloudadapter
|
76 |
-
* @var FACTFinder_Abstract_TagCloudAdapter
|
77 |
-
*/
|
78 |
-
protected $_tagCloudAdapter = null;
|
79 |
-
|
80 |
-
/**
|
81 |
-
* FACT-Finder After Search Navigation
|
82 |
-
* @var array
|
83 |
-
*/
|
84 |
-
protected $_afterSearchNavigation = null;
|
85 |
-
|
86 |
-
/**
|
87 |
-
* FACT-Finder product IDs of primary search result
|
88 |
-
* @var array
|
89 |
-
*/
|
90 |
-
protected $_searchResultProductIds = null;
|
91 |
-
|
92 |
-
/**
|
93 |
-
* FACT-Finder secondary search results
|
94 |
-
* @var array
|
95 |
-
*/
|
96 |
-
protected $_secondarySearchResults = null;
|
97 |
-
|
98 |
-
|
99 |
-
/**
|
100 |
-
* current FACT-Finder Category Path
|
101 |
-
* @var array
|
102 |
-
*/
|
103 |
-
protected $_currentFactfinderCategoryPath = null;
|
104 |
-
|
105 |
-
/**
|
106 |
-
* logger object to log all module interna
|
107 |
-
* @var FACTFinder_Abstract_Logger
|
108 |
-
*/
|
109 |
-
protected $_logger = null;
|
110 |
-
|
111 |
-
public function __construct($arg = null)
|
112 |
-
{
|
113 |
-
if ($arg != null && $arg instanceof FACTFinder_Abstract_Logger) {
|
114 |
-
FF::setLogger($arg);
|
115 |
-
$this->_logger = $arg;
|
116 |
-
} else {
|
117 |
-
$logger = Mage::helper('factfinder/debug');
|
118 |
-
FF::setLogger($logger);
|
119 |
-
$this->_logger = $logger;
|
120 |
-
}
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* get FactFinder SearchAdapter
|
125 |
-
*
|
126 |
-
* @return FACTFinder_Abstract_SearchAdapter
|
127 |
-
*/
|
128 |
-
protected function _getSearchAdapter($collectParams = true)
|
129 |
-
{
|
130 |
-
if ($this->_searchAdapter == null) {
|
131 |
-
$config = $this->_getConfiguration();
|
132 |
-
$encodingHandler = FF::getSingleton('encodingHandler', $config);
|
133 |
-
$dataProvider = $this->_getDataProvider();
|
134 |
-
$this->_searchAdapter = FF::getSingleton(
|
135 |
-
'xml'.Mage::getStoreConfig('factfinder/search/ffversion').'/searchAdapter',
|
136 |
-
$dataProvider,
|
137 |
-
$this->_getParamsParser(),
|
138 |
-
$encodingHandler
|
139 |
-
);
|
140 |
-
|
141 |
-
if($collectParams == true){
|
142 |
-
$this->_collectParams();
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
return $this->_searchAdapter;
|
147 |
-
}
|
148 |
-
|
149 |
-
protected function _collectParams()
|
150 |
-
{
|
151 |
-
// search Helper
|
152 |
-
$helper = Mage::helper('factfinder/search');
|
153 |
-
$_request = Mage::app()->getRequest();
|
154 |
-
$params = $this->_getParamsParser()->getRequestParams();
|
155 |
-
|
156 |
-
if (strpos(Mage::getStoreConfig('factfinder/config/internal_ip'), Mage::helper('core/http')->getRemoteAddr()) !== false) {
|
157 |
-
$this->_setParam('log', 'internal');
|
158 |
-
}
|
159 |
-
|
160 |
-
switch($_request->getModuleName()){
|
161 |
-
|
162 |
-
case "xmlconnect":
|
163 |
-
$_query = $helper->getQueryText();
|
164 |
-
$this->_setParam('idsOnly', 'true')
|
165 |
-
->_setParam('query', $_query);
|
166 |
-
|
167 |
-
$count = $params['count'];
|
168 |
-
if ($count > 0) {
|
169 |
-
$this->_setParam('productsPerPage', $count)
|
170 |
-
->_setParam('page', ($params['offset'] / $count) + 1);
|
171 |
-
}
|
172 |
-
|
173 |
-
// add Sorting Param
|
174 |
-
foreach($params as $key => $value){
|
175 |
-
if(substr($key, 0, 6) == 'order_'){
|
176 |
-
$key = substr($key, 6);
|
177 |
-
if(!in_array($key, array('position', 'relevance'))){
|
178 |
-
$this->_setParam('sort'.$key, $value);
|
179 |
-
}
|
180 |
-
}
|
181 |
-
}
|
182 |
-
|
183 |
-
// add Filter Params
|
184 |
-
foreach($params as $key => $value){
|
185 |
-
$value = base64_decode($value);
|
186 |
-
if(strpos($value, '|')){
|
187 |
-
$param = explode('|', $value);
|
188 |
-
if($key == 'Category'){
|
189 |
-
$categories = array_merge(array_slice(explode('/', $param[0]), 1), array($param[1]));
|
190 |
-
foreach($categories AS $k => $v) { $categories[$k] = urldecode($v); }
|
191 |
-
$filterkey = '';
|
192 |
-
foreach($categories as $category){
|
193 |
-
$category = str_replace('%2F', '/', str_replace('%2B', '+', $category));
|
194 |
-
$this->_setParam('filtercategoryROOT'.$filterkey, $category);
|
195 |
-
$filterkey .= '/'.str_replace('+', '%2B', str_replace('/', '%2F', $category));
|
196 |
-
}
|
197 |
-
}else{
|
198 |
-
$this->_setParam('filter'.$param[0], $param[1]);
|
199 |
-
}
|
200 |
-
}
|
201 |
-
}
|
202 |
-
|
203 |
-
break;
|
204 |
-
|
205 |
-
case "catalog":
|
206 |
-
$_query = '*';
|
207 |
-
if (!isset($params['Category'])) {
|
208 |
-
$params['Category'] = $this->_getCurrentFactfinderCategoryPath();
|
209 |
-
}
|
210 |
-
|
211 |
-
case "catalogsearch":
|
212 |
-
default:
|
213 |
-
if ($_request->getModuleName() == 'catalogsearch') {
|
214 |
-
$_query = $helper->getQueryText();
|
215 |
-
}
|
216 |
-
|
217 |
-
// add Default Params
|
218 |
-
$this->_setParam('idsOnly', 'true')
|
219 |
-
->_setParam('productsPerPage', $helper->getPageLimit())
|
220 |
-
->_setParam('query', $_query)
|
221 |
-
->_setParam('page', $helper->getCurrentPage());
|
222 |
-
|
223 |
-
// add Sorting Param, but only if it was set explicit via url
|
224 |
-
foreach($params as $key => $value){
|
225 |
-
if($key == 'order'
|
226 |
-
&& $helper->getCurrentOrder()
|
227 |
-
&& $helper->getCurrentDirection()
|
228 |
-
&& $helper->getCurrentOrder() != 'position'
|
229 |
-
&& $helper->getCurrentOrder() != 'relevance'){
|
230 |
-
$this->_setParam('sort'.$helper->getCurrentOrder(), $helper->getCurrentDirection());
|
231 |
-
}
|
232 |
-
}
|
233 |
-
|
234 |
-
// add Filter Params
|
235 |
-
foreach($params as $key => $value){
|
236 |
-
if(strpos($value, '|')){
|
237 |
-
$param = explode('|', $value);
|
238 |
-
switch($param[1]){
|
239 |
-
|
240 |
-
case 'slider':
|
241 |
-
$subparam = explode(':', $param[2]);
|
242 |
-
$this->_setParam($subparam[0], $subparam[1]);
|
243 |
-
$subparam = explode(':', $param[3]);
|
244 |
-
$this->_setParam($subparam[0], $subparam[1]);
|
245 |
-
break;
|
246 |
-
|
247 |
-
default:
|
248 |
-
if($key == 'Category'){
|
249 |
-
$categories = array_merge(array_slice(explode('/', $param[0]), 1), array($param[1]));
|
250 |
-
foreach($categories AS $k => $v) { $categories[$k] = $v; }
|
251 |
-
$filterkey = '';
|
252 |
-
foreach($categories as $category){
|
253 |
-
$category = str_replace('%2F', '/', str_replace('%2B', '+', $category));
|
254 |
-
$this->_setParam('filtercategoryROOT'.$filterkey, $category);
|
255 |
-
$filterkey .= '/'.str_replace('+', '%2B', str_replace('/', '%2F', $category));
|
256 |
-
}
|
257 |
-
|
258 |
-
}else{
|
259 |
-
$this->_setParam('filter'.$param[0], $param[1]);
|
260 |
-
}
|
261 |
-
break;
|
262 |
-
}
|
263 |
-
}
|
264 |
-
}
|
265 |
-
break;
|
266 |
-
|
267 |
-
}
|
268 |
-
}
|
269 |
-
|
270 |
-
|
271 |
-
/**
|
272 |
-
* execute search
|
273 |
-
*/
|
274 |
-
public function checkStatus($configarray = null)
|
275 |
-
{
|
276 |
-
$status = false;
|
277 |
-
try {
|
278 |
-
$this->_getConfiguration($configarray);
|
279 |
-
$this->_setParam('query', 'FACT-Finder Version');
|
280 |
-
$this->_setParam('productsPerPage', '1');
|
281 |
-
|
282 |
-
$status = $this->_getSearchAdapter(false)->getStatus() == 'resultsFound';
|
283 |
-
} catch (Exception $e) {
|
284 |
-
$status = false;
|
285 |
-
}
|
286 |
-
return $status;
|
287 |
-
}
|
288 |
-
|
289 |
-
/**
|
290 |
-
* get Redirect URL if there is set one
|
291 |
-
*
|
292 |
-
* @return string
|
293 |
-
*/
|
294 |
-
public function getRedirect()
|
295 |
-
{
|
296 |
-
$url = null;
|
297 |
-
$campaigns = $this->getCampaigns();
|
298 |
-
|
299 |
-
if (!empty($campaigns) && $campaigns->hasRedirect()) {
|
300 |
-
$url = $campaigns->getRedirectUrl();
|
301 |
-
}
|
302 |
-
return $url;
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
*
|
307 |
-
*/
|
308 |
-
public function getCampaigns()
|
309 |
-
{
|
310 |
-
$campaigns = null;
|
311 |
-
try {
|
312 |
-
$campaigns = $this->_getSearchAdapter()->getCampaigns();
|
313 |
-
}
|
314 |
-
catch (Exception $e) {
|
315 |
-
Mage::logException($e);
|
316 |
-
}
|
317 |
-
return $campaigns;
|
318 |
-
}
|
319 |
-
|
320 |
-
/**
|
321 |
-
* get Search Suggest URL
|
322 |
-
*
|
323 |
-
* @return string
|
324 |
-
*/
|
325 |
-
public function getSuggestUrl()
|
326 |
-
{
|
327 |
-
$dataprovider = $this->_getDataProvider();
|
328 |
-
$dataprovider->setType('Suggest.ff');
|
329 |
-
$dataprovider->setParams(array());
|
330 |
-
|
331 |
-
return $dataprovider->getNonAuthenticationUrl();
|
332 |
-
}
|
333 |
-
|
334 |
-
/**
|
335 |
-
* get Suggest Adapter
|
336 |
-
*
|
337 |
-
* @return FACTFinder_Abstract_SuggestAdapter
|
338 |
-
*/
|
339 |
-
protected function _getSuggestAdapter()
|
340 |
-
{
|
341 |
-
if ($this->_suggestAdapter == null) {
|
342 |
-
$config = $this->_getConfiguration();
|
343 |
-
$encodingHandler = FF::getSingleton('encodingHandler', $config);
|
344 |
-
$params = $this->_getParamsParser()->getServerRequestParams();
|
345 |
-
$dataProvider = $this->_getDataProvider();
|
346 |
-
$this->_suggestAdapter = FF::getSingleton('http/suggestAdapter', $dataProvider, $this->_getParamsParser(), $encodingHandler);
|
347 |
-
}
|
348 |
-
|
349 |
-
return $this->_suggestAdapter;
|
350 |
-
}
|
351 |
-
|
352 |
-
/**
|
353 |
-
* get Suggest Results as Array
|
354 |
-
*
|
355 |
-
* @param string $query
|
356 |
-
* @return array
|
357 |
-
*/
|
358 |
-
public function getSuggestResult($query)
|
359 |
-
{
|
360 |
-
$this->_setParam('query', $query);
|
361 |
-
$this->_setParam('format', 'json');
|
362 |
-
|
363 |
-
return Zend_Json_Decoder::decode($this->_getSuggestAdapter()->getSuggestions());
|
364 |
-
}
|
365 |
-
|
366 |
-
/**
|
367 |
-
* get Suggest Results as JSON
|
368 |
-
*
|
369 |
-
* @param string $query
|
370 |
-
* @return string json
|
371 |
-
*/
|
372 |
-
public function getSuggestResultJsonp($query, $jqueryCallback)
|
373 |
-
{
|
374 |
-
$this->_setParam('query', $query, false);
|
375 |
-
$this->_setParam('format', 'jsonp', false);
|
376 |
-
|
377 |
-
return $this->_getSuggestAdapter()->getSuggestions();
|
378 |
-
}
|
379 |
-
|
380 |
-
/**
|
381 |
-
* get FactFinder TagCloudAdapter
|
382 |
-
*
|
383 |
-
* @return FACTFinder_Abstract_TagCloudAdapter
|
384 |
-
*/
|
385 |
-
protected function _getTagCloudAdapter()
|
386 |
-
{
|
387 |
-
if ($this->_tagCloudAdapter == null) {
|
388 |
-
$config = $this->_getConfiguration();
|
389 |
-
$encodingHandler = FF::getSingleton('encodingHandler', $config);
|
390 |
-
$dataProvider = $this->_getDataProvider();
|
391 |
-
$this->_tagCloudAdapter = FF::getSingleton(
|
392 |
-
'xml'.Mage::getStoreConfig('factfinder/search/ffversion').'/tagCloudAdapter',
|
393 |
-
$dataProvider,
|
394 |
-
$this->_getParamsParser(),
|
395 |
-
$encodingHandler
|
396 |
-
);
|
397 |
-
|
398 |
-
}
|
399 |
-
|
400 |
-
return $this->_tagCloudAdapter;
|
401 |
-
}
|
402 |
-
|
403 |
-
/**
|
404 |
-
* get tag cloud information as Array
|
405 |
-
*
|
406 |
-
* @param string $query
|
407 |
-
* @return array
|
408 |
-
*/
|
409 |
-
public function getTagCloud()
|
410 |
-
{
|
411 |
-
try {
|
412 |
-
return $this->_getTagCloudAdapter()->getTagCloud();
|
413 |
-
} catch (Exception $e) {
|
414 |
-
Mage::logException($e);
|
415 |
-
return array();
|
416 |
-
}
|
417 |
-
}
|
418 |
-
|
419 |
-
/**
|
420 |
-
* get Scic Adapter
|
421 |
-
*
|
422 |
-
* @return FACTFinder_Abstract_ScicAdapter
|
423 |
-
*/
|
424 |
-
public function getScicAdapter()
|
425 |
-
{
|
426 |
-
if ($this->_scicAdapter == null) {
|
427 |
-
$config = $this->_getConfiguration();
|
428 |
-
$encodingHandler = FF::getSingleton('encodingHandler', $config);
|
429 |
-
$params = $this->_getParamsParser()->getServerRequestParams();
|
430 |
-
$dataProvider = $this->_getDataProvider();
|
431 |
-
$this->_scicAdapter = FF::getSingleton('http/scicAdapter', $dataProvider, $this->_getParamsParser(), $encodingHandler);
|
432 |
-
}
|
433 |
-
return $this->_scicAdapter;
|
434 |
-
}
|
435 |
-
|
436 |
-
/**
|
437 |
-
* get Recommendation Adapter
|
438 |
-
*
|
439 |
-
* @return FACTFinder_Abstract_RecommendationAdapter
|
440 |
-
*/
|
441 |
-
public function getRecommendationAdapter()
|
442 |
-
{
|
443 |
-
if ($this->_recommendationAdapter == null) {
|
444 |
-
$config = $this->_getConfiguration();
|
445 |
-
$encodingHandler = FF::getSingleton('encodingHandler', $config);
|
446 |
-
$params = $this->_getParamsParser()->getServerRequestParams();
|
447 |
-
$dataProvider = $this->_getDataProvider();
|
448 |
-
$dataProvider->setParam('idsOnly', 'true');
|
449 |
-
$this->_recommendationAdapter = FF::getSingleton('xml'.Mage::getStoreConfig('factfinder/search/ffversion').'/recommendationAdapter', $dataProvider, $this->_getParamsParser(), $encodingHandler);
|
450 |
-
}
|
451 |
-
return $this->_recommendationAdapter;
|
452 |
-
}
|
453 |
-
|
454 |
-
/**
|
455 |
-
* get Product Campaign Adapter
|
456 |
-
*
|
457 |
-
* @return FACTFinder_Abstract_ProductCampaignAdapter
|
458 |
-
*/
|
459 |
-
public function getProductCampaignAdapter()
|
460 |
-
{
|
461 |
-
// Note: this will only work as long as version numbers are used with the same amount of decimal points
|
462 |
-
if (Mage::getStoreConfig('factfinder/search/ffversion') < 67)
|
463 |
-
throw new Exception('Feature not supported by used FACT-Finder version.');
|
464 |
-
|
465 |
-
if ($this->_productCampaignAdapter == null) {
|
466 |
-
$config = $this->_getConfiguration();
|
467 |
-
$encodingHandler = FF::getSingleton('encodingHandler', $config);
|
468 |
-
$params = $this->_getParamsParser()->getServerRequestParams();
|
469 |
-
$dataProvider = $this->_getDataProvider();
|
470 |
-
$dataProvider->setParam('idsOnly', 'true');
|
471 |
-
$this->_productCampaignAdapter = FF::getSingleton('xml'.Mage::getStoreConfig('factfinder/search/ffversion').'/productCampaignAdapter', $dataProvider, $this->_getParamsParser(), $encodingHandler);
|
472 |
-
}
|
473 |
-
return $this->_productCampaignAdapter;
|
474 |
-
}
|
475 |
-
|
476 |
-
/**
|
477 |
-
* get Search Result Count
|
478 |
-
*
|
479 |
-
* @return int
|
480 |
-
*/
|
481 |
-
public function getSearchResultCount()
|
482 |
-
{
|
483 |
-
$count = 0;
|
484 |
-
try {
|
485 |
-
$count = $this->_getSearchAdapter()->getResult()->getFoundRecordsCount();
|
486 |
-
}
|
487 |
-
catch (Exception $e) {
|
488 |
-
Mage::logException($e);
|
489 |
-
}
|
490 |
-
|
491 |
-
return $count;
|
492 |
-
}
|
493 |
-
|
494 |
-
/**
|
495 |
-
* get After Search Navigation as Array
|
496 |
-
* this simulates Magento Filter Attributes with Options
|
497 |
-
*
|
498 |
-
* @return array
|
499 |
-
*/
|
500 |
-
public function getAfterSearchNavigation()
|
501 |
-
{
|
502 |
-
if($this->_afterSearchNavigation == null){
|
503 |
-
$this->_afterSearchNavigation = array();
|
504 |
-
|
505 |
-
$result = array();
|
506 |
-
try {
|
507 |
-
$result = $this->_getSearchAdapter()->getAsn();
|
508 |
-
}
|
509 |
-
catch (Exception $e) {
|
510 |
-
Mage::logException($e);
|
511 |
-
}
|
512 |
-
|
513 |
-
|
514 |
-
if ($result instanceof FACTFinder_Asn
|
515 |
-
&& count($result)){
|
516 |
-
|
517 |
-
foreach ($result as $row) {
|
518 |
-
$this->_afterSearchNavigation[] = array(
|
519 |
-
'attribute_code' => $row->getName(),
|
520 |
-
'name' => $row->getName(),
|
521 |
-
'unit' => $row->getUnit(),
|
522 |
-
'items' => $this->_getAttributeOptions($row->getArrayCopy(), $row->getUnit()),
|
523 |
-
'count' => $row->count(),
|
524 |
-
'type' => $this->_getFilterType($row->getArrayCopy()),
|
525 |
-
'store_label' => $row->getName()
|
526 |
-
);
|
527 |
-
}
|
528 |
-
}
|
529 |
-
}
|
530 |
-
|
531 |
-
return $this->_afterSearchNavigation;
|
532 |
-
}
|
533 |
-
|
534 |
-
/**
|
535 |
-
* get Filter Type by FACT-Finder FilterItem
|
536 |
-
*
|
537 |
-
* @param array $options
|
538 |
-
* @return string
|
539 |
-
*/
|
540 |
-
protected function _getFilterType($options)
|
541 |
-
{
|
542 |
-
$defaultType = 'item';
|
543 |
-
foreach($options as $option){
|
544 |
-
if(!$option->getType()){
|
545 |
-
continue;
|
546 |
-
}
|
547 |
-
$defaultType = $option->getType();
|
548 |
-
break;
|
549 |
-
}
|
550 |
-
return $defaultType;
|
551 |
-
}
|
552 |
-
|
553 |
-
/**
|
554 |
-
* get Attribute Options Array from FactFinder FilterGroupItems
|
555 |
-
*
|
556 |
-
* @param FACTFinder_AsnFilterItem $options
|
557 |
-
* @return array
|
558 |
-
*/
|
559 |
-
protected function _getAttributeOptions($options, $unit = '')
|
560 |
-
{
|
561 |
-
$attributeOption = array();
|
562 |
-
if (!empty($unit)) $unit = ' ' . $unit;
|
563 |
-
$_currentCategoryPath = $this->_getCurrentFactfinderCategoryPath(true);
|
564 |
-
$helper = Mage::helper('factfinder/search');
|
565 |
-
foreach($options as $option){
|
566 |
-
|
567 |
-
switch ($option->getType()){
|
568 |
-
|
569 |
-
case "slider":
|
570 |
-
$attributeOption[] = array(
|
571 |
-
'type' => $option->getType(),
|
572 |
-
'label' => 'slider',
|
573 |
-
'value' => $this->_getAttributeOptionValue($option),
|
574 |
-
'absolute_min' => $option->getAbsoluteMin(),
|
575 |
-
'absolute_max' => $option->getAbsoluteMax(),
|
576 |
-
'selected_min' => $option->getSelectedMin(),
|
577 |
-
'selected_max' => $option->getSelectedMax(),
|
578 |
-
'count' => true,
|
579 |
-
'selected' => false //$option->isSelected()
|
580 |
-
);
|
581 |
-
break;
|
582 |
-
|
583 |
-
default:
|
584 |
-
if (!Mage::helper('core/string')->strlen($option->getValue())) {
|
585 |
-
continue;
|
586 |
-
}
|
587 |
-
// remove Categories from top Level Navigation
|
588 |
-
$_value = $this->_getAttributeOptionValue($option);
|
589 |
-
if(Mage::getStoreConfigFlag('factfinder/activation/navigation')
|
590 |
-
&& !$helper->getIsOnSearchPage()
|
591 |
-
&& (
|
592 |
-
empty($_value) === true
|
593 |
-
|| in_array($_value, $_currentCategoryPath)
|
594 |
-
&& $_currentCategoryPath[count($_currentCategoryPath)-1] != $_value
|
595 |
-
)){
|
596 |
-
continue;
|
597 |
-
}
|
598 |
-
|
599 |
-
$attributeOption[] = array(
|
600 |
-
'type' => 'attribute',
|
601 |
-
'label' => $option->getValue() . $unit,
|
602 |
-
'value' => $_value,
|
603 |
-
'count' => $option->getMatchCount(),
|
604 |
-
'selected' => $option->isSelected(),
|
605 |
-
'clusterLevel' => $option->getClusterLevel()
|
606 |
-
);
|
607 |
-
break;
|
608 |
-
}
|
609 |
-
}
|
610 |
-
return $attributeOption;
|
611 |
-
}
|
612 |
-
|
613 |
-
/**
|
614 |
-
* get current FACT-Finder Catgory Path
|
615 |
-
*
|
616 |
-
* @return string
|
617 |
-
*/
|
618 |
-
protected function _getCurrentFactfinderCategoryPath($all = false)
|
619 |
-
{
|
620 |
-
$returnValue = '';
|
621 |
-
if($this->_currentFactfinderCategoryPath == null && Mage::getStoreConfigFlag('factfinder/activation/navigation') && Mage::registry('current_category')){
|
622 |
-
$this->_currentFactfinderCategoryPath = array();
|
623 |
-
/* @var $category Mage_Catalog_Model_Category */
|
624 |
-
$category = Mage::registry('current_category');
|
625 |
-
|
626 |
-
$pathInStore = $category->getPathInStore();
|
627 |
-
$pathIds = array_reverse(explode(',', $pathInStore));
|
628 |
-
|
629 |
-
$categories = $category->getParentCategories();
|
630 |
-
$mainCategoriesString = '';
|
631 |
-
foreach ($pathIds as $categoryId) {
|
632 |
-
if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
|
633 |
-
if(empty($mainCategoriesString)){
|
634 |
-
$this->_currentFactfinderCategoryPath[] = 'categoryROOT|'.$categories[$categoryId]->getName();
|
635 |
-
}else{
|
636 |
-
$this->_currentFactfinderCategoryPath[] = 'categoryROOT'.$mainCategoriesString.'|'.$categories[$categoryId]->getName();
|
637 |
-
}
|
638 |
-
$mainCategoriesString .= '/'. str_replace('/', '%2F', $categories[$categoryId]->getName());
|
639 |
-
}
|
640 |
-
}
|
641 |
-
} else {
|
642 |
-
$this->_currentFactfinderCategoryPath = array();
|
643 |
-
}
|
644 |
-
|
645 |
-
if($all === false){
|
646 |
-
if (isset($this->_currentFactfinderCategoryPath[count($this->_currentFactfinderCategoryPath)-1])) {
|
647 |
-
$returnValue = $this->_currentFactfinderCategoryPath[count($this->_currentFactfinderCategoryPath)-1];
|
648 |
-
}
|
649 |
-
else {
|
650 |
-
$returnValue = false;
|
651 |
-
}
|
652 |
-
} else {
|
653 |
-
$returnValue = $this->_currentFactfinderCategoryPath;
|
654 |
-
}
|
655 |
-
|
656 |
-
return $returnValue;
|
657 |
-
}
|
658 |
-
|
659 |
-
/**
|
660 |
-
* get Attribute option Value
|
661 |
-
*
|
662 |
-
* @param string $option
|
663 |
-
* @return string
|
664 |
-
*/
|
665 |
-
protected function _getAttributeOptionValue($option)
|
666 |
-
{
|
667 |
-
$selectOptions = $this->_getSearchAdapter()->getSearchParams()->getFilters();
|
668 |
-
$value = null;
|
669 |
-
switch ($option->getType()) {
|
670 |
-
|
671 |
-
// handle Slider Attributes
|
672 |
-
case "slider";
|
673 |
-
$value = $option->getField().'|'.$option->getType().'|'.str_replace(array('&', '='), array('|', ':'), $option->getValue()).'[VALUE]';
|
674 |
-
break;
|
675 |
-
|
676 |
-
// handle default Attributes
|
677 |
-
default:
|
678 |
-
$value = $option->getField();
|
679 |
-
if($option->isSelected()){
|
680 |
-
|
681 |
-
// handle multiselectable Attributes
|
682 |
-
if(!empty($selectOptions[$option->getField()]) ){
|
683 |
-
if(strpos($option->getField(), 'categoryROOT') === false){
|
684 |
-
$values = explode('~~~', $selectOptions[$option->getField()]);
|
685 |
-
unset($values[array_search($option->getValue(), $values)]);
|
686 |
-
$value .= '|'.implode('~~~', $values);
|
687 |
-
|
688 |
-
}else{
|
689 |
-
$values = explode('/',str_replace('|'.$selectOptions[$option->getField()], '', $value));
|
690 |
-
$valueCount = count($values);
|
691 |
-
$value = '';
|
692 |
-
if($valueCount > 1){
|
693 |
-
for($i=0 ; $valueCount > $i ; $i++){
|
694 |
-
$value .= ($i != 0 ? ($i == $valueCount-1 ? '|' : '/') : '').$values[$i];
|
695 |
-
}
|
696 |
-
}
|
697 |
-
}
|
698 |
-
}
|
699 |
-
}else{
|
700 |
-
$value .= '|'.$option->getValue();
|
701 |
-
// handle multiselectable Attributes
|
702 |
-
if(!empty($selectOptions[$option->getField()])){
|
703 |
-
$value .= '~~~'.$selectOptions[$option->getField()];
|
704 |
-
}
|
705 |
-
}
|
706 |
-
break;
|
707 |
-
}
|
708 |
-
return $value;
|
709 |
-
}
|
710 |
-
|
711 |
-
|
712 |
-
/**
|
713 |
-
* get Search Result Product Ids and additional Data
|
714 |
-
*
|
715 |
-
* @return array Products Ids
|
716 |
-
*/
|
717 |
-
public function getSearchResultProductIds()
|
718 |
-
{
|
719 |
-
if($this->_searchResultProductIds == null){
|
720 |
-
try {
|
721 |
-
$result = $this->_getSearchAdapter()->getResult();
|
722 |
-
|
723 |
-
$this->_searchResultProductIds = array();
|
724 |
-
if($result instanceof FACTFinder_Result){
|
725 |
-
foreach ($result AS $record){
|
726 |
-
if(isset($this->_searchResultProductIds[$record->getId()])){
|
727 |
-
continue;
|
728 |
-
}
|
729 |
-
$this->_searchResultProductIds[$record->getId()] = new Varien_Object(
|
730 |
-
array(
|
731 |
-
'similarity' => $record->getSimilarity(),
|
732 |
-
'position' => $record->getPosition(),
|
733 |
-
'original_position' => $record->getOriginalPosition()
|
734 |
-
)
|
735 |
-
);
|
736 |
-
}
|
737 |
-
}
|
738 |
-
}
|
739 |
-
catch (Exception $e) {
|
740 |
-
Mage::logException($e);
|
741 |
-
$this->_searchResultProductIds = array();
|
742 |
-
}
|
743 |
-
}
|
744 |
-
|
745 |
-
return $this->_searchResultProductIds;
|
746 |
-
}
|
747 |
-
|
748 |
-
/**
|
749 |
-
* get secondary Search Results
|
750 |
-
*
|
751 |
-
* @return array Products Ids
|
752 |
-
*/
|
753 |
-
public function getSecondarySearchResult($channel)
|
754 |
-
{
|
755 |
-
// array_filter() is used to turn a one-element array into an empty array in the case of an empty config-string
|
756 |
-
$channels = array_filter(explode(';', Mage::getStoreConfig('factfinder/search/secondary_channels')));
|
757 |
-
|
758 |
-
if(!in_array($channel, $channels))
|
759 |
-
{
|
760 |
-
Mage::logException(new Exception("Tried to query a channel that was not configured as a secondary channel."));
|
761 |
-
return array();
|
762 |
-
}
|
763 |
-
|
764 |
-
if($this->_secondarySearchResults == null)
|
765 |
-
{
|
766 |
-
$this->_secondarySearchResults = array();
|
767 |
-
|
768 |
-
$query = Mage::helper('factfinder/search')->getQueryText();
|
769 |
-
|
770 |
-
$searchAdapters = array();
|
771 |
-
|
772 |
-
foreach($channels AS $currentChannel)
|
773 |
-
{
|
774 |
-
try {
|
775 |
-
$searchAdapters[$currentChannel] = $this->_getSecondarySearchAdapter($currentChannel, $query);
|
776 |
-
}
|
777 |
-
catch (Exception $e) {
|
778 |
-
Mage::logException($e);
|
779 |
-
}
|
780 |
-
}
|
781 |
-
|
782 |
-
FACTFinder_Http_ParallelDataProvider::loadAllData();
|
783 |
-
|
784 |
-
foreach($searchAdapters AS $currentChannel => $searchAdapter)
|
785 |
-
{
|
786 |
-
try {
|
787 |
-
$this->_secondarySearchResults[$currentChannel] = $searchAdapter->getResult();
|
788 |
-
}
|
789 |
-
catch (Exception $e) {
|
790 |
-
Mage::logException($e);
|
791 |
-
}
|
792 |
-
}
|
793 |
-
}
|
794 |
-
|
795 |
-
if(!array_key_exists($channel, $this->_secondarySearchResults))
|
796 |
-
{
|
797 |
-
Mage::logException(new Exception("Result for channel '".$channel."' could not be retrieved."));
|
798 |
-
return array();
|
799 |
-
}
|
800 |
-
|
801 |
-
return $this->_secondarySearchResults[$channel];
|
802 |
-
}
|
803 |
-
|
804 |
-
/**
|
805 |
-
* get a (new) FactFinder SearchAdapter for a secondary channel
|
806 |
-
*
|
807 |
-
* @return FACTFinder_Abstract_SearchAdapter
|
808 |
-
*/
|
809 |
-
protected function _getSecondarySearchAdapter($channel, $query)
|
810 |
-
{
|
811 |
-
$config = $this->_getConfiguration();
|
812 |
-
$encodingHandler = FF::getSingleton('encodingHandler', $config);
|
813 |
-
$dataProvider = $this->_getParallelDataProvider($channel);
|
814 |
-
|
815 |
-
// Overwrite the channel set by the configuration
|
816 |
-
$dataProvider->setParam('channel', $channel);
|
817 |
-
$dataProvider->setParam('query', $query);
|
818 |
-
|
819 |
-
$searchAdapter = FF::getInstance(
|
820 |
-
'xml'.Mage::getStoreConfig('factfinder/search/ffversion').'/searchAdapter',
|
821 |
-
$dataProvider,
|
822 |
-
$this->_getParamsParser(),
|
823 |
-
$encodingHandler
|
824 |
-
);
|
825 |
-
|
826 |
-
return $searchAdapter;
|
827 |
-
}
|
828 |
-
|
829 |
-
/**
|
830 |
-
* get a (new) FactFinder DataProvider that works in parallel
|
831 |
-
*
|
832 |
-
* @return FACTFinder_Abstract_Dataprovider
|
833 |
-
**/
|
834 |
-
protected function _getParallelDataProvider()
|
835 |
-
{
|
836 |
-
$config = $this->_getConfiguration();
|
837 |
-
$params = $this->_getParamsParser()->getServerRequestParams();
|
838 |
-
|
839 |
-
$dp = FACTFinder_Http_ParallelDataProvider::getDataProvider($params, $config);
|
840 |
-
|
841 |
-
return $dp;
|
842 |
-
}
|
843 |
-
|
844 |
-
/**
|
845 |
-
* set single parameter, which will be looped through to the FACT-Finder request
|
846 |
-
*
|
847 |
-
* @param string name
|
848 |
-
* @param string value
|
849 |
-
*/
|
850 |
-
protected function _setParam($name, $value, $log = true)
|
851 |
-
{
|
852 |
-
if($log){
|
853 |
-
Mage::helper('factfinder/debug')->log('set Param:'.$name.' => '.$value);
|
854 |
-
}
|
855 |
-
$this->_getDataProvider()->setParam($name, $value);
|
856 |
-
return $this;
|
857 |
-
}
|
858 |
-
|
859 |
-
/**
|
860 |
-
* get FactFinder DataProvider
|
861 |
-
*
|
862 |
-
* @return FACTFinder_Abstract_DataProvider
|
863 |
-
*/
|
864 |
-
protected function _getDataProvider()
|
865 |
-
{
|
866 |
-
if ($this->_dataProvider == null) {
|
867 |
-
$config = $this->_getConfiguration();
|
868 |
-
$params = $this->_getParamsParser()->getServerRequestParams();
|
869 |
-
|
870 |
-
$this->_dataProvider = FF::getInstance('http/dataProvider', $params, $config);
|
871 |
-
}
|
872 |
-
return $this->_dataProvider;
|
873 |
-
}
|
874 |
-
|
875 |
-
/**
|
876 |
-
* get Autentivation URL
|
877 |
-
*
|
878 |
-
* @return string
|
879 |
-
*/
|
880 |
-
public function getAuthenticationUrl()
|
881 |
-
{
|
882 |
-
$dataprovider = $this->_getDataProvider();
|
883 |
-
$dataprovider->setType('Management.ff');
|
884 |
-
return $dataprovider->getNonAuthenticationUrl();
|
885 |
-
}
|
886 |
-
|
887 |
-
/**
|
888 |
-
* get FactFinder Params Parser
|
889 |
-
*
|
890 |
-
* @return FACTFinder_ParametersParser
|
891 |
-
*/
|
892 |
-
protected function _getParamsParser()
|
893 |
-
{
|
894 |
-
if ($this->_paramsParser == null) {
|
895 |
-
$config = $this->_getConfiguration();
|
896 |
-
$encodingHandler = FF::getSingleton('encodingHandler', $config);
|
897 |
-
$this->_paramsParser = FF::getInstance('parametersParser', $config, $encodingHandler);
|
898 |
-
}
|
899 |
-
return $this->_paramsParser;
|
900 |
-
}
|
901 |
-
|
902 |
-
/**
|
903 |
-
* set FactFinder Configuration
|
904 |
-
*
|
905 |
-
* @param array $configarray
|
906 |
-
*/
|
907 |
-
public function setConfiguration($configarray)
|
908 |
-
{
|
909 |
-
$this->_config = FF::getSingleton('configuration', $configarray);
|
910 |
-
}
|
911 |
-
|
912 |
-
/**
|
913 |
-
* get FactFinder Configuration
|
914 |
-
*
|
915 |
-
* @return FACTFinder_Abstract_Configuration config
|
916 |
-
*/
|
917 |
-
protected function _getConfiguration($configarray = null)
|
918 |
-
{
|
919 |
-
if ($this->_config == null) {
|
920 |
-
$this->_config = FF::getSingleton('configuration', $configarray);
|
921 |
-
}
|
922 |
-
return $this->_config;
|
923 |
-
}
|
924 |
-
|
925 |
-
|
926 |
-
/**
|
927 |
-
* Set StoreId for current configuration
|
928 |
-
*
|
929 |
-
* @param unknown_type $storeId
|
930 |
-
*/
|
931 |
-
public function setStoreId($storeId) {
|
932 |
-
$this->_getConfiguration()->setStoreId($storeId);
|
933 |
-
|
934 |
-
return $this;
|
935 |
-
}
|
936 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|