Version Notes
The EasyAsk Search module (EAS module) is designed to let customers leverage the considerable development investment in their website user interface. All enhancements are made to the layer beneath the UI code. Hence there are minimal changes to the design code.
The only changes made to the templates was for SAYT (Search As You Type) and multi attribute selection in addition to price slider.
Download this release
Release Info
Developer | Srinivas Kotamreddy |
Extension | EasyAsk_Search |
Version | 1.2.0 |
Comparing to | |
See all releases |
Version 1.2.0
- app/code/local/EasyAsk/Search/Block/Adminhtml/System/Config/Testconnection.php +78 -0
- app/code/local/EasyAsk/Search/Block/Adminhtml/System/Config/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Block/Catalog/Breadcrumbs.php +84 -0
- app/code/local/EasyAsk/Search/Block/Catalog/Layer.php +153 -0
- app/code/local/EasyAsk/Search/Block/Catalog/Layer.php.bak +137 -0
- app/code/local/EasyAsk/Search/Block/Catalog/Layer/Filter/Attribute.php +43 -0
- app/code/local/EasyAsk/Search/Block/Catalog/Layer/Filter/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Block/Catalog/Layer/State.php +47 -0
- app/code/local/EasyAsk/Search/Block/Catalog/Layer/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Block/Catalog/Product/List.php +242 -0
- app/code/local/EasyAsk/Search/Block/Catalog/Product/List/Toolbar.php +96 -0
- app/code/local/EasyAsk/Search/Block/Catalog/Product/List/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Block/Catalog/Product/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Block/Catalog/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Block/CatalogSearch/Layer.php +141 -0
- app/code/local/EasyAsk/Search/Block/CatalogSearch/Layer/Filter/Attribute.php +38 -0
- app/code/local/EasyAsk/Search/Block/CatalogSearch/Layer/Filter/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Block/CatalogSearch/Layer/State.php +36 -0
- app/code/local/EasyAsk/Search/Block/CatalogSearch/Layer/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Block/CatalogSearch/Result.php +113 -0
- app/code/local/EasyAsk/Search/Block/CatalogSearch/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Block/Html/Pager.php +28 -0
- app/code/local/EasyAsk/Search/Block/Html/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Helper/Category.php +30 -0
- app/code/local/EasyAsk/Search/Helper/Data.php +141 -0
- app/code/local/EasyAsk/Search/Helper/Eae.php +416 -0
- app/code/local/EasyAsk/Search/Helper/Eae.php.bak +338 -0
- app/code/local/EasyAsk/Search/Helper/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Model/Adminhtml/System/Config/Backend/Engine.php +54 -0
- app/code/local/EasyAsk/Search/Model/Adminhtml/System/Config/Backend/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Model/Adminhtml/System/Config/Source/Engine.php +52 -0
- app/code/local/EasyAsk/Search/Model/Adminhtml/System/Config/Source/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Model/Catalog/Layer.php +199 -0
- app/code/local/EasyAsk/Search/Model/Catalog/Layer.php.bak +152 -0
- app/code/local/EasyAsk/Search/Model/Catalog/Layer/Filter/Attribute.php +416 -0
- app/code/local/EasyAsk/Search/Model/Catalog/Layer/Filter/Attribute.php.bak +417 -0
- app/code/local/EasyAsk/Search/Model/Catalog/Layer/Filter/Category.php +173 -0
- app/code/local/EasyAsk/Search/Model/Catalog/Layer/Filter/Item.php +156 -0
- app/code/local/EasyAsk/Search/Model/Catalog/Layer/Filter/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Model/Catalog/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Model/CatalogSearch/Layer.php +168 -0
- app/code/local/EasyAsk/Search/Model/CatalogSearch/Layer/Filter/Attribute.php +397 -0
- app/code/local/EasyAsk/Search/Model/CatalogSearch/Layer/Filter/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Model/CatalogSearch/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Model/Observer.php +190 -0
- app/code/local/EasyAsk/Search/Model/Resource/Catalog/Product/Collection.php +18 -0
- app/code/local/EasyAsk/Search/Model/Resource/Catalog/Product/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Model/Resource/CatalogSearch/Fulltext/Collection.php +105 -0
- app/code/local/EasyAsk/Search/Model/Resource/CatalogSearch/Fulltext/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/Model/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/controllers/Adminhtml/Search/System/Config/TestconnectionController.php +83 -0
- app/code/local/EasyAsk/Search/controllers/Adminhtml/Search/System/Config/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/controllers/IndexController.php +59 -0
- app/code/local/EasyAsk/Search/controllers/ResultController.php +253 -0
- app/code/local/EasyAsk/Search/controllers/vssver.scc +0 -0
- app/code/local/EasyAsk/Search/etc/attrib.xml +72 -0
- app/code/local/EasyAsk/Search/etc/config.xml +161 -0
- app/code/local/EasyAsk/Search/etc/system.xml +135 -0
- app/code/local/EasyAsk/Search/etc/vssver.scc +0 -0
- app/design/adminhtml/default/default/template/easyask/search/js.phtml +45 -0
- app/design/adminhtml/default/default/template/easyask/search/system/config/testconnection.phtml +64 -0
- app/design/adminhtml/default/default/template/easyask/search/system/config/vssver.scc +0 -0
- app/design/adminhtml/default/default/template/easyask/search/vssver.scc +0 -0
- app/design/frontend/base/default/template/catalog/layer/filter.phtml +170 -0
- app/design/frontend/base/default/template/catalog/layer/view.phtml +300 -0
- app/design/frontend/base/default/template/catalogsearch/form.mini.phtml +170 -0
- app/design/frontend/base/default/template/catalogsearch/result.phtml +58 -0
- app/etc/modules/EasyAsk_Search.xml +13 -0
- js/easyask/2.0/ea-autocomplete-2.0.1.css +69 -0
- js/easyask/2.0/ea-autocomplete-2.0.1.js +878 -0
- js/easyask/2.0/ea-autocomplete-2.0.1.js_save +881 -0
- js/easyask/2.0/images/sug-title-gradient.gif +0 -0
- js/easyask/2.0/images/tm-logo.png +0 -0
- js/easyask/images/price_filter.png +0 -0
- js/easyask/sayt20_search.html +108 -0
- lib/EasyAsk/IBreadCrumbTrail.php +11 -0
- lib/EasyAsk/ICarveOut.php +13 -0
- lib/EasyAsk/IDataDescription.php +19 -0
- lib/EasyAsk/IFeaturedProducts.php +9 -0
- lib/EasyAsk/IGroupedResult.php +37 -0
- lib/EasyAsk/IGroupedResultSet.php +25 -0
- lib/EasyAsk/INavigateAttribute.php +33 -0
- lib/EasyAsk/INavigateCategory.php +21 -0
- lib/EasyAsk/INavigateHierarchy.php +19 -0
- lib/EasyAsk/INavigateNode.php +22 -0
- lib/EasyAsk/INavigateResults.php +109 -0
- lib/EasyAsk/IOptions.php +53 -0
- lib/EasyAsk/IRemoteEasyAsk.php +21 -0
- lib/EasyAsk/IResultRow.php +9 -0
- lib/EasyAsk/Impl/AttributeInfo.php +91 -0
- lib/EasyAsk/Impl/AttributesInfo.php +116 -0
- lib/EasyAsk/Impl/Banner.php +33 -0
- lib/EasyAsk/Impl/Banners.php +46 -0
- lib/EasyAsk/Impl/BreadCrumbTrail.php +33 -0
- lib/EasyAsk/Impl/CarveOut.php +48 -0
- lib/EasyAsk/Impl/CategoriesInfo.php +120 -0
- lib/EasyAsk/Impl/DataDescription.php +46 -0
- lib/EasyAsk/Impl/DisplayFormat.php +34 -0
- lib/EasyAsk/Impl/DomUtilities.php +21 -0
- lib/EasyAsk/Impl/FeaturedProducts.php +43 -0
- lib/EasyAsk/Impl/GroupInfo.php +173 -0
- lib/EasyAsk/Impl/GroupedPageLayout.php +102 -0
- lib/EasyAsk/Impl/GroupedSetInfo.php +146 -0
- lib/EasyAsk/Impl/ItemDescriptions.php +75 -0
- lib/EasyAsk/Impl/ItemRow.php +38 -0
- lib/EasyAsk/Impl/NavigateAttribute.php +114 -0
- lib/EasyAsk/Impl/NavigateCategory.php +64 -0
- lib/EasyAsk/Impl/NavigateHierarchy.php +53 -0
- lib/EasyAsk/Impl/NavigateNode.php +54 -0
- lib/EasyAsk/Impl/Options.php +144 -0
- lib/EasyAsk/Impl/RemoteEasyAsk.php +127 -0
- lib/EasyAsk/Impl/RemoteFactory.php +9 -0
- lib/EasyAsk/Impl/RemoteResults.php +616 -0
- lib/EasyAsk/constants.php +22 -0
- package.xml +20 -0
app/code/local/EasyAsk/Search/Block/Adminhtml/System/Config/Testconnection.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento Enterprise Edition
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Magento Enterprise Edition License
|
8 |
+
* that is bundled with this package in the file LICENSE_EE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.magentocommerce.com/license/enterprise-edition
|
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 Enterprise
|
22 |
+
* @package Enterprise_Search
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://www.magentocommerce.com/license/enterprise-edition
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Enterprise test connection block
|
29 |
+
*
|
30 |
+
* @category Enterprise
|
31 |
+
* @package Enterprise_Search
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class EasyAsk_Search_Block_Adminhtml_System_Config_Testconnection
|
35 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* Set template to itself
|
39 |
+
*/
|
40 |
+
protected function _prepareLayout()
|
41 |
+
{
|
42 |
+
parent::_prepareLayout();
|
43 |
+
if (!$this->getTemplate()) {
|
44 |
+
$this->setTemplate('easyask/search/system/config/testconnection.phtml');
|
45 |
+
}
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Unset some non-related element parameters
|
51 |
+
*
|
52 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
56 |
+
{
|
57 |
+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
|
58 |
+
return parent::render($element);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Get the button and scripts contents
|
63 |
+
*
|
64 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
68 |
+
{
|
69 |
+
$originalData = $element->getOriginalData();
|
70 |
+
$this->addData(array(
|
71 |
+
'button_label' => Mage::helper('easyask_search')->__($originalData['button_label']),
|
72 |
+
'html_id' => $element->getHtmlId(),
|
73 |
+
'ajax_url' => Mage::getSingleton('adminhtml/url')->getUrl('*/search_system_config_testconnection/ping')
|
74 |
+
));
|
75 |
+
|
76 |
+
return $this->_toHtml();
|
77 |
+
}
|
78 |
+
}
|
app/code/local/EasyAsk/Search/Block/Adminhtml/System/Config/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Block/Catalog/Breadcrumbs.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Block_Catalog_Breadcrumbs extends Mage_Catalog_Block_Breadcrumbs {
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Prepare layout
|
6 |
+
*
|
7 |
+
* @return Mage_Catalog_Block_Breadcrumbs
|
8 |
+
*/
|
9 |
+
protected function _prepareLayout()
|
10 |
+
{
|
11 |
+
$res = Mage::registry('ea_result');
|
12 |
+
if ($res != null){
|
13 |
+
// add Home breadcrumb
|
14 |
+
$breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
|
15 |
+
if ($breadcrumbs) {
|
16 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
17 |
+
|
18 |
+
$breadcrumbs->addCrumb('home', array(
|
19 |
+
'label' => $this->__('Home'),
|
20 |
+
'title' => $this->__('Go to Home Page'),
|
21 |
+
'link' => Mage::getBaseUrl()
|
22 |
+
));
|
23 |
+
if (count($searchPath) > 0){
|
24 |
+
for($i = 1; $i < count($searchPath) ; $i++){
|
25 |
+
if ($i != count($searchPath) - 1){
|
26 |
+
$seopath = $searchPath[$i]->getSEOPath();
|
27 |
+
if ($searchPath[$i]->getType() == 1){
|
28 |
+
$seopatharr = explode('/', $seopath);
|
29 |
+
$bcpath = $seopatharr[count($seopatharr) - 1];
|
30 |
+
$link = Mage::getBaseUrl() . str_replace('_', '/', $bcpath);
|
31 |
+
} else if ($searchPath[$i]->getType() == 2){
|
32 |
+
$eapath = $searchPath[$i]->getPath();
|
33 |
+
$eapatharr = explode('////', $eapath);
|
34 |
+
$attrarray = array();
|
35 |
+
foreach ($eapatharr as $attrpath){
|
36 |
+
if (strpos($attrpath, 'AttribSelect') !== false){
|
37 |
+
$attribsel = substr($attrpath, 13);
|
38 |
+
$attrarray[] = substr($attribsel, 0, strpos($attribsel, '='));
|
39 |
+
}
|
40 |
+
}
|
41 |
+
$seopatharr = explode('/', $seopath);
|
42 |
+
$attrvalarray = array();
|
43 |
+
foreach ($seopatharr as $seopathpart){
|
44 |
+
if (strpos($seopathpart, ':') !== false){
|
45 |
+
$attrvalarray[] = $seopathpart;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
if (sizeof($attrarray) == sizeof($attrvalarray)){
|
50 |
+
$link = '';
|
51 |
+
for($j = 0; $j < sizeof($attrarray); $j++){
|
52 |
+
$link = $link . '&' . $attrarray[$j] . '=' . $attrvalarray[$j];
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
57 |
+
$breadcrumbs->addCrumb($searchPath[$i]->getValue(), array(
|
58 |
+
'label' => $searchPath[$i]->getValue(),
|
59 |
+
'title' => $searchPath[$i]->getValue(),
|
60 |
+
'link' => $link
|
61 |
+
));
|
62 |
+
} else {
|
63 |
+
$breadcrumbs->addCrumb($searchPath[$i]->getValue(), array(
|
64 |
+
'label' => $searchPath[$i]->getValue(),
|
65 |
+
'title' => $searchPath[$i]->getValue()
|
66 |
+
));
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
// modify page title
|
73 |
+
$title = $this->__("Search results for: '%s'", $this->helper('catalogsearch')->getEscapedQueryText());
|
74 |
+
$this->getLayout()->getBlock('head')->setTitle($title);
|
75 |
+
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
|
79 |
+
return parent::_prepareLayout();
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
}
|
84 |
+
?>
|
app/code/local/EasyAsk/Search/Block/Catalog/Layer.php
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Block_Catalog_Layer extends Mage_Catalog_Block_Layer_View {
|
3 |
+
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Get all layer filters
|
7 |
+
*
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
public function getFilters()
|
11 |
+
{
|
12 |
+
$res = Mage::registry('ea_result');
|
13 |
+
if ($res != null){
|
14 |
+
$filters = array();
|
15 |
+
if ($categoryFilter = $this->_getCategoryFilter()) {
|
16 |
+
$filters[] = $categoryFilter;
|
17 |
+
}
|
18 |
+
|
19 |
+
$filterableAttributes = $this->_getFilterableAttributes();
|
20 |
+
foreach ($filterableAttributes as $attribute) {
|
21 |
+
$filters[] = $this->getChild($attribute['name'] . '_filter');
|
22 |
+
}
|
23 |
+
|
24 |
+
return $filters;
|
25 |
+
} else {
|
26 |
+
return parent::getFilters();
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get all fiterable attributes of current category
|
34 |
+
*
|
35 |
+
* @return array
|
36 |
+
*/
|
37 |
+
protected function _getFilterableAttributes()
|
38 |
+
{
|
39 |
+
$res = Mage::registry('ea_result');
|
40 |
+
if ($res != null){
|
41 |
+
$attributes = $this->getData('_filterable_attributes');
|
42 |
+
if (is_null($attributes)) {
|
43 |
+
$attributes = $this->getLayer()->getFilterableAttributes();
|
44 |
+
$this->setData('_filterable_attributes', $attributes);
|
45 |
+
}
|
46 |
+
|
47 |
+
return $attributes;
|
48 |
+
} else {
|
49 |
+
return parent::_getFilterableAttributes();
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Get all fiterable attributes of current category
|
55 |
+
*
|
56 |
+
* @return array
|
57 |
+
*/
|
58 |
+
protected function _getStateAttributes()
|
59 |
+
{
|
60 |
+
$res = Mage::registry('ea_result');
|
61 |
+
if ($res != null){
|
62 |
+
$attributes = $this->getData('_state_attributes');
|
63 |
+
if (is_null($attributes)) {
|
64 |
+
$attributes = $this->getLayer()->getStateAttributes();
|
65 |
+
$this->setData('_state_attributes', $attributes);
|
66 |
+
}
|
67 |
+
|
68 |
+
return $attributes;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Prepare child blocks
|
74 |
+
*
|
75 |
+
* @return Mage_Catalog_Block_Layer_View
|
76 |
+
*/
|
77 |
+
protected function _prepareLayout()
|
78 |
+
{
|
79 |
+
|
80 |
+
$res = Mage::registry('ea_result');
|
81 |
+
if ($res != null){
|
82 |
+
$categoryCount = $res->getInitDisplayLimitForCategories();
|
83 |
+
|
84 |
+
$stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)
|
85 |
+
->setLayer($this->getLayer());
|
86 |
+
|
87 |
+
if ($categoryCount > 0){
|
88 |
+
$categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
|
89 |
+
->setLayer($this->getLayer())
|
90 |
+
->setIsInitDisplayLimited($categoryCount)
|
91 |
+
->init();
|
92 |
+
} else {
|
93 |
+
$categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
|
94 |
+
->setLayer($this->getLayer())
|
95 |
+
->init();
|
96 |
+
}
|
97 |
+
|
98 |
+
$this->setChild('layer_state', $stateBlock);
|
99 |
+
$this->setChild('category_filter', $categoryBlock);
|
100 |
+
|
101 |
+
$filterableAttributes = $this->_getFilterableAttributes();
|
102 |
+
$stateAttributes = $this->_getStateAttributes();
|
103 |
+
$selectedAttributes = array();
|
104 |
+
|
105 |
+
foreach ($stateAttributes as $selectedAttribute){
|
106 |
+
$selectedAttributes[] = substr($selectedAttribute, 0, strpos($selectedAttribute, '='));
|
107 |
+
}
|
108 |
+
|
109 |
+
foreach ($filterableAttributes as $attribute) {
|
110 |
+
$filterBlockName = $this->_attributeFilterBlockName;
|
111 |
+
if ($attribute['expand'] == true || in_array($attribute['name'], $selectedAttributes)){
|
112 |
+
$this->setChild($attribute['name'] . '_filter',
|
113 |
+
$this->getLayout()->createBlock($filterBlockName)
|
114 |
+
->setLayer($this->getLayer())
|
115 |
+
->setAttributeModel($attribute['name'])
|
116 |
+
->setAttributeCode('2')
|
117 |
+
->setIsInitDisplayLimited($attribute['dispLimited'])
|
118 |
+
->setIsRangeFilter($attribute['isRangeFilter'])
|
119 |
+
->init());
|
120 |
+
} else {
|
121 |
+
if ($attribute['name']){
|
122 |
+
$this->setChild($attribute['name'] . '_filter',
|
123 |
+
$this->getLayout()->createBlock($filterBlockName)
|
124 |
+
->setLayer($this->getLayer())
|
125 |
+
->setAttributeModel($attribute['name'])
|
126 |
+
->setAttributeCode('0')
|
127 |
+
->setIsInitDisplayLimited($attribute['dispLimited'])
|
128 |
+
->setIsRangeFilter($attribute['isRangeFilter'])
|
129 |
+
->init());
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
foreach ($stateAttributes as $attribute) {
|
135 |
+
$filterBlockName = $this->_attributeFilterBlockName;
|
136 |
+
$this->setChild($attribute . '_state_filter',
|
137 |
+
$this->getLayout()->createBlock($filterBlockName)
|
138 |
+
->setLayer($this->getLayer())
|
139 |
+
->setAttributeModel($attribute)
|
140 |
+
->setAttributeCode('1')
|
141 |
+
// ->setIsInitDisplayLimited($attribute['dispLimited'])
|
142 |
+
// ->setIsRangeFilter($attribute['isRangeFilter'])
|
143 |
+
->init());
|
144 |
+
}
|
145 |
+
|
146 |
+
$this->getLayer()->apply();
|
147 |
+
return;
|
148 |
+
} else {
|
149 |
+
return parent::_prepareLayout();
|
150 |
+
}
|
151 |
+
|
152 |
+
}
|
153 |
+
}
|
app/code/local/EasyAsk/Search/Block/Catalog/Layer.php.bak
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Block_Catalog_Layer extends Mage_Catalog_Block_Layer_View {
|
3 |
+
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Get all layer filters
|
7 |
+
*
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
public function getFilters()
|
11 |
+
{
|
12 |
+
$filters = array();
|
13 |
+
if ($categoryFilter = $this->_getCategoryFilter()) {
|
14 |
+
$filters[] = $categoryFilter;
|
15 |
+
}
|
16 |
+
|
17 |
+
$filterableAttributes = $this->_getFilterableAttributes();
|
18 |
+
foreach ($filterableAttributes as $attribute) {
|
19 |
+
$filters[] = $this->getChild($attribute['name'] . '_filter');
|
20 |
+
}
|
21 |
+
|
22 |
+
return $filters;
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get all fiterable attributes of current category
|
29 |
+
*
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
protected function _getFilterableAttributes()
|
33 |
+
{
|
34 |
+
$attributes = $this->getData('_filterable_attributes');
|
35 |
+
if (is_null($attributes)) {
|
36 |
+
$attributes = $this->getLayer()->getFilterableAttributes();
|
37 |
+
$this->setData('_filterable_attributes', $attributes);
|
38 |
+
}
|
39 |
+
|
40 |
+
return $attributes;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Get all fiterable attributes of current category
|
45 |
+
*
|
46 |
+
* @return array
|
47 |
+
*/
|
48 |
+
protected function _getStateAttributes()
|
49 |
+
{
|
50 |
+
$attributes = $this->getData('_state_attributes');
|
51 |
+
if (is_null($attributes)) {
|
52 |
+
$attributes = $this->getLayer()->getStateAttributes();
|
53 |
+
$this->setData('_state_attributes', $attributes);
|
54 |
+
}
|
55 |
+
|
56 |
+
return $attributes;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Prepare child blocks
|
61 |
+
*
|
62 |
+
* @return Mage_Catalog_Block_Layer_View
|
63 |
+
*/
|
64 |
+
protected function _prepareLayout()
|
65 |
+
{
|
66 |
+
|
67 |
+
$res = Mage::registry('ea_result');
|
68 |
+
$categoryCount = 0;
|
69 |
+
if ($res != null){
|
70 |
+
$categoryCount = $res->getInitDisplayLimitForCategories();
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
$stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)
|
75 |
+
->setLayer($this->getLayer());
|
76 |
+
|
77 |
+
if ($categoryCount > 0){
|
78 |
+
$categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
|
79 |
+
->setLayer($this->getLayer())
|
80 |
+
->setIsInitDisplayLimited($categoryCount)
|
81 |
+
->init();
|
82 |
+
} else {
|
83 |
+
$categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
|
84 |
+
->setLayer($this->getLayer())
|
85 |
+
->init();
|
86 |
+
}
|
87 |
+
|
88 |
+
$this->setChild('layer_state', $stateBlock);
|
89 |
+
$this->setChild('category_filter', $categoryBlock);
|
90 |
+
|
91 |
+
$filterableAttributes = $this->_getFilterableAttributes();
|
92 |
+
$stateAttributes = $this->_getStateAttributes();
|
93 |
+
$selectedAttributes = array();
|
94 |
+
|
95 |
+
foreach ($stateAttributes as $selectedAttribute){
|
96 |
+
$selectedAttributes[] = substr($selectedAttribute, 0, strpos($selectedAttribute, '='));
|
97 |
+
}
|
98 |
+
|
99 |
+
foreach ($filterableAttributes as $attribute) {
|
100 |
+
$filterBlockName = $this->_attributeFilterBlockName;
|
101 |
+
if ($attribute['expand'] == true || in_array($attribute['name'], $selectedAttributes)){
|
102 |
+
$this->setChild($attribute['name'] . '_filter',
|
103 |
+
$this->getLayout()->createBlock($filterBlockName)
|
104 |
+
->setLayer($this->getLayer())
|
105 |
+
->setAttributeModel($attribute['name'])
|
106 |
+
->setAttributeCode('2')
|
107 |
+
->setIsInitDisplayLimited($attribute['dispLimited'])
|
108 |
+
->init());
|
109 |
+
} else {
|
110 |
+
if ($attribute['name']){
|
111 |
+
$this->setChild($attribute['name'] . '_filter',
|
112 |
+
$this->getLayout()->createBlock($filterBlockName)
|
113 |
+
->setLayer($this->getLayer())
|
114 |
+
->setAttributeModel($attribute['name'])
|
115 |
+
->setAttributeCode('0')
|
116 |
+
->setIsInitDisplayLimited($attribute['dispLimited'])
|
117 |
+
->init());
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
foreach ($stateAttributes as $attribute) {
|
123 |
+
$filterBlockName = $this->_attributeFilterBlockName;
|
124 |
+
$this->setChild($attribute . '_state_filter',
|
125 |
+
$this->getLayout()->createBlock($filterBlockName)
|
126 |
+
->setLayer($this->getLayer())
|
127 |
+
->setAttributeModel($attribute)
|
128 |
+
->setAttributeCode('1')
|
129 |
+
->setIsInitDisplayLimited($attribute['dispLimited'])
|
130 |
+
->init());
|
131 |
+
}
|
132 |
+
|
133 |
+
$this->getLayer()->apply();
|
134 |
+
return;
|
135 |
+
|
136 |
+
}
|
137 |
+
}
|
app/code/local/EasyAsk/Search/Block/Catalog/Layer/Filter/Attribute.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Block_Catalog_Layer_Filter_Attribute extends Mage_Catalog_Block_Layer_Filter_Attribute
|
3 |
+
{
|
4 |
+
protected function _prepareFilter()
|
5 |
+
{
|
6 |
+
$res = Mage::registry('ea_result');
|
7 |
+
if ($res != null){
|
8 |
+
$this->_filter->setAttributeModel($this->getAttributeModel());
|
9 |
+
$this->_filter->setAttributeCode($this->getAttributeCode());
|
10 |
+
$this->_filter->setIsAttributeSelected($this->_isAttributeSelected());
|
11 |
+
return $this;
|
12 |
+
} else {
|
13 |
+
return parent::_prepareFilter();
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
protected function _isAttributeSelected(){
|
18 |
+
$isCurrentAttribute = false;
|
19 |
+
$res = Mage::registry('ea_result');
|
20 |
+
if ($res != null){
|
21 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
22 |
+
if (count($searchPath) > 0){
|
23 |
+
for($i = 1; $i < count($searchPath) ; $i++){
|
24 |
+
$eapath = $searchPath[$i]->getPath();
|
25 |
+
$eapatharr = explode('////', $eapath);
|
26 |
+
$attrarray = array();
|
27 |
+
foreach ($eapatharr as $attrpath){
|
28 |
+
if (strpos($attrpath, 'AttribSelect') !== false){
|
29 |
+
$attribsel = substr($attrpath, 13);
|
30 |
+
$attrib = substr($attribsel, 0, strpos($attribsel, '='));
|
31 |
+
if ($attrib === $this->getAttributeModel()){
|
32 |
+
$isCurrentAttribute = true;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
return $isCurrentAttribute;
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
43 |
+
?>
|
app/code/local/EasyAsk/Search/Block/Catalog/Layer/Filter/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Block/Catalog/Layer/State.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EasyAsk_Search_Block_Catalog_Layer_State extends Mage_Catalog_Block_Layer_State
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Retrieve Clear Filters URL
|
8 |
+
*
|
9 |
+
* @return string
|
10 |
+
*/
|
11 |
+
public function getClearUrl()
|
12 |
+
{
|
13 |
+
$res = Mage::registry('ea_result');
|
14 |
+
|
15 |
+
if ($res != null){
|
16 |
+
|
17 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
18 |
+
$eapath = $searchPath[1]->getSEOPath();
|
19 |
+
if (strpos ( $eapath, '-' ) === 0) {
|
20 |
+
|
21 |
+
$params = array();
|
22 |
+
$params['ea_path'] = $eapath;
|
23 |
+
$params['ea_c'] = '';
|
24 |
+
$params['ea_a'] = '';
|
25 |
+
$params['ea_bc'] = '';
|
26 |
+
|
27 |
+
$urlParams = array();
|
28 |
+
$urlParams['_current'] = true;
|
29 |
+
$urlParams['_escape'] = true;
|
30 |
+
$urlParams['_use_rewrite'] = true;
|
31 |
+
$urlParams['_query'] = $params;
|
32 |
+
return $this->getUrl('*/*/*', $urlParams);
|
33 |
+
|
34 |
+
} else {
|
35 |
+
$index = count($searchPath) >= 2 ? 1 : 0;
|
36 |
+
$eapath = $searchPath[$index]->getSEOPath();
|
37 |
+
|
38 |
+
return Mage::getBaseUrl() . str_replace('_', '/', $eapath);
|
39 |
+
}
|
40 |
+
|
41 |
+
} else {
|
42 |
+
return parent::getClearUrl();
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
47 |
+
?>
|
app/code/local/EasyAsk/Search/Block/Catalog/Layer/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Block/Catalog/Product/List.php
ADDED
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EasyAsk_Search_Block_Catalog_Product_List extends Mage_Catalog_Block_Product_List {
|
4 |
+
|
5 |
+
protected $_eaProductCollection;
|
6 |
+
|
7 |
+
public function getLoadedProductCollection()
|
8 |
+
{
|
9 |
+
$res = Mage::registry('ea_result');
|
10 |
+
$loadProductsFromMagentoDB = Mage::helper('easyask_search')->loadProductsFromMagentoDB();
|
11 |
+
$easyask_nav = Mage::getStoreConfig('catalog/navigation/use_easyask');
|
12 |
+
|
13 |
+
if ($res) {
|
14 |
+
if (is_null($this->_eaProductCollection)) {
|
15 |
+
|
16 |
+
//from parent to populate current category
|
17 |
+
$layer = $this->getLayer();
|
18 |
+
$origCategory = null;
|
19 |
+
if ($res->getSuggestedCategoryID()) {
|
20 |
+
$category = Mage::getModel('catalog/category')->load($res->getSuggestedCategoryID());
|
21 |
+
if ($category->getId()) {
|
22 |
+
$origCategory = $layer->getCurrentCategory();
|
23 |
+
$layer->setCurrentCategory($category);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
//from parent
|
28 |
+
$last = $res->getLastItem();
|
29 |
+
$rpp = $res->getResultsPerPage();
|
30 |
+
$pNum = $last / $rpp;
|
31 |
+
$offset = ($pNum - 1) * $rpp - 1;
|
32 |
+
|
33 |
+
$layer = $this->getLayer();
|
34 |
+
|
35 |
+
if ($loadProductsFromMagentoDB || ($easyask_nav && (get_class($layer) == 'EasyAsk_Search_Model_Catalog_Layer'))) {
|
36 |
+
$eaCollection = $this->_loadDBCollection($res);
|
37 |
+
}
|
38 |
+
else {
|
39 |
+
$eaCollection = $this->_buildManualCollection($res);
|
40 |
+
}
|
41 |
+
|
42 |
+
Mage::dispatchEvent('easyask_search_block_product_list_collection', array(
|
43 |
+
'collection' => $eaCollection
|
44 |
+
));
|
45 |
+
// echo get_class($eaCollection);
|
46 |
+
|
47 |
+
if ($loadProductsFromMagentoDB || ($easyask_nav && (get_class($layer) == 'EasyAsk_Search_Model_Catalog_Layer'))) {
|
48 |
+
$eaCollection->load();
|
49 |
+
$eaCollection = $this->_sortCollectionAfterLoad($eaCollection, $res);
|
50 |
+
}
|
51 |
+
else {
|
52 |
+
$eaCollection->setIsLoaded(true);
|
53 |
+
}
|
54 |
+
|
55 |
+
echo 'Size of list is' . sizeof($eaCollection);
|
56 |
+
$this->_eaProductCollection = $eaCollection;
|
57 |
+
}
|
58 |
+
|
59 |
+
Mage::dispatchEvent('easyask_search_block_product_list_collection', array(
|
60 |
+
'collection' => $this->_eaProductCollection
|
61 |
+
));
|
62 |
+
|
63 |
+
return $this->_eaProductCollection;
|
64 |
+
|
65 |
+
} else {
|
66 |
+
return parent::getLoadedProductCollection();
|
67 |
+
}
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
public function prepareProductCollection($collection, $res)
|
72 |
+
{
|
73 |
+
$collection
|
74 |
+
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
75 |
+
->setStore(Mage::app()->getStore())
|
76 |
+
->setPageSize($res->getResultsPerPage())
|
77 |
+
// ->setCurPage($res->getCurrentPage())
|
78 |
+
->addMinimalPrice()
|
79 |
+
->addFinalPrice()
|
80 |
+
->addTaxPercents()
|
81 |
+
->addStoreFilter()
|
82 |
+
->addUrlRewrite();
|
83 |
+
|
84 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
|
85 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
|
86 |
+
|
87 |
+
return $this;
|
88 |
+
}
|
89 |
+
|
90 |
+
protected function _getProductCollection()
|
91 |
+
{
|
92 |
+
$res = Mage::registry('ea_result');
|
93 |
+
|
94 |
+
if ($res) {
|
95 |
+
return $this->_eaProductCollection;
|
96 |
+
} else {
|
97 |
+
return parent::_getProductCollection();
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
protected function _buildManualCollection($res)
|
102 |
+
{
|
103 |
+
// Clear the existing list
|
104 |
+
$eaLayer = $this->getLayer();
|
105 |
+
$eaCollection = $eaLayer->getProductCollection();
|
106 |
+
$eaCollection->clear();
|
107 |
+
|
108 |
+
if ($res->getFirstItem() != -1) {
|
109 |
+
$last = $res->getLastItem();
|
110 |
+
for ($i = $res->getFirstItem() - 1; $i < $last; $i++) {
|
111 |
+
$item = $eaCollection->getNewEmptyItem();
|
112 |
+
$data = array();
|
113 |
+
|
114 |
+
$regularPrice = $this->_getPriceAmount($res->getCellData($i, $res->getColumnIndex('Regular Price')));
|
115 |
+
$price = $this->_getPriceAmount($res->getCellData($i, $res->getColumnIndex('Regular Price')));
|
116 |
+
|
117 |
+
$finalPrice = $this->_getPriceAmount($res->getCellData($i, $res->getColumnIndex('Price')));
|
118 |
+
$minPrice = $this->_getPriceAmount($res->getCellData($i,$res->getColumnIndex('Min Price')));
|
119 |
+
$maxPrice = $this->_getPriceAmount($res->getCellData($i,$res->getColumnIndex('Price')));
|
120 |
+
|
121 |
+
$data['final_price'] = $finalPrice;
|
122 |
+
$data['min_price'] = $minPrice;
|
123 |
+
$data['max_price'] = $maxPrice;
|
124 |
+
|
125 |
+
if ((float) $finalPrice < (float) $regularPrice) {
|
126 |
+
$data['price'] = $regularPrice;
|
127 |
+
$data['special_price'] = $finalPrice;
|
128 |
+
}
|
129 |
+
else {
|
130 |
+
$data['price'] = $price;
|
131 |
+
$data['special_price'] = NULL;
|
132 |
+
}
|
133 |
+
|
134 |
+
$productName;
|
135 |
+
$productImage;
|
136 |
+
|
137 |
+
$numberInGroup = $res->getCellData($i, $res->getColumnIndex('No. products in group'));
|
138 |
+
$productName = $res->getCellData($i, $res->getColumnIndex('Product Name'));
|
139 |
+
$productImage = $res->getCellData($i, $res->getColumnIndex('Small Image'));
|
140 |
+
$skuProductName = $res->getCellData($i, $res->getColumnIndex('SKU Product Name'));
|
141 |
+
$skuProductImage = $res->getCellData($i, $res->getColumnIndex('SKU Product Image'));
|
142 |
+
|
143 |
+
if (isset($numberInGroup) && $numberInGroup > 1){
|
144 |
+
$data['name'] = $productName;
|
145 |
+
$data['small_image'] = $productImage;
|
146 |
+
} else {
|
147 |
+
$data['name'] = $productName;
|
148 |
+
if (isset($skuProductImage)){
|
149 |
+
$data['small_image'] = $skuProductImage;
|
150 |
+
} else {
|
151 |
+
$data['small_image'] = $productImage;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
$data['entity_id'] = $res->getCellData($i, $res->getColumnIndex('Product Id'));
|
156 |
+
$data['sku'] = $res->getCellData($i, $res->getColumnIndex('Sku'));
|
157 |
+
$data['url_key'] = $res->getCellData($i, $res->getColumnIndex('Small Image'));
|
158 |
+
$data['thumbnail'] = $res->getCellData($i, $res->getColumnIndex('Thumbnail URL'));
|
159 |
+
$data['type_id'] = $res->getCellData($i, $res->getColumnIndex('Type Id'));
|
160 |
+
$data['enable_category_checkout'] = (bool) $res->getCellData($i, $res->getColumnIndex('Enable Category Checkout'));
|
161 |
+
$data['dynamic_image'] = $res->getCellData($i, $res->getColumnIndex('Dynamic Image'));
|
162 |
+
$data['intro_date'] = $res->getCellData($i, $res->getColumnIndex('Intro Date'));
|
163 |
+
$data['repeat_image'] = $res->getCellData($i, $res->getColumnIndex('Repeat Image'));
|
164 |
+
$data['application_image'] = $res->getCellData($i, $res->getColumnIndex('Application Image'));
|
165 |
+
$data['short_description'] = $res->getCellData($i, $res->getColumnIndex('Short Description'));
|
166 |
+
$data['status'] = '1';
|
167 |
+
$data['request_path'] = $res->getCellData($i, $res->getColumnIndex('Url Path'));
|
168 |
+
$data['is_salable'] = '1';
|
169 |
+
|
170 |
+
$item->addData($data);
|
171 |
+
$eaCollection->addItem($item);
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
return $eaCollection;
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
protected function _loadDBCollection($res)
|
180 |
+
{
|
181 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
182 |
+
if ($res->getFirstItem() != -1) {
|
183 |
+
$productIds = array();
|
184 |
+
$last = $res->getLastItem();
|
185 |
+
for ($i = $res->getFirstItem() - 1; $i < $last; $i++) {
|
186 |
+
$productIds[] = (int) $res->getCellData($i, $res->getColumnIndex('Product Id'));
|
187 |
+
}
|
188 |
+
$collection->addAttributeToFilter('entity_id', array('in' => $productIds));
|
189 |
+
$this->prepareProductCollection($collection, $res);
|
190 |
+
}
|
191 |
+
return $collection;
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Return price without currency sent by EasyAsk
|
196 |
+
*
|
197 |
+
* @param string $price price including currency symbol
|
198 |
+
*
|
199 |
+
* @return string
|
200 |
+
*/
|
201 |
+
protected function _getPriceAmount($price)
|
202 |
+
{
|
203 |
+
$pattern = "/([0-9,]+\.?[0-9]+)/";
|
204 |
+
if (preg_match($pattern, $price, $matches)) {
|
205 |
+
return str_replace(',', '', $matches[0]);
|
206 |
+
}
|
207 |
+
return $price;
|
208 |
+
}
|
209 |
+
|
210 |
+
protected function _sortCollectionAfterLoad($_productCollection, $res){
|
211 |
+
$collectionReflection = new ReflectionObject($_productCollection);
|
212 |
+
$itemsPropertyReflection = $collectionReflection->getProperty('_items');
|
213 |
+
$itemsPropertyReflection->setAccessible(true); // Make it accessible
|
214 |
+
|
215 |
+
$collectionItems = $itemsPropertyReflection->getValue($_productCollection);
|
216 |
+
|
217 |
+
$collectionItems = $this->_sortItems($collectionItems, $res);
|
218 |
+
|
219 |
+
$itemsPropertyReflection->setValue($_productCollection, $collectionItems);
|
220 |
+
|
221 |
+
$itemsPropertyReflection->setAccessible(false);
|
222 |
+
return $_productCollection;
|
223 |
+
}
|
224 |
+
|
225 |
+
protected function _sortItems($collection, $res){
|
226 |
+
$sortCollection = array();
|
227 |
+
|
228 |
+
$productIds = array();
|
229 |
+
$last = $res->getLastItem();
|
230 |
+
for ($i = $res->getFirstItem() - 1; $i < $last; $i++) {
|
231 |
+
$productIds[] = (int) $res->getCellData($i, $res->getColumnIndex('Product Id'));
|
232 |
+
}
|
233 |
+
|
234 |
+
foreach ($productIds as $productId){
|
235 |
+
if (isset($collection[$productId])){
|
236 |
+
$sortCollection[$productId] = $collection[$productId];
|
237 |
+
}
|
238 |
+
}
|
239 |
+
return $sortCollection;
|
240 |
+
}
|
241 |
+
|
242 |
+
}
|
app/code/local/EasyAsk/Search/Block/Catalog/Product/List/Toolbar.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EasyAsk_Search_Block_Catalog_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar{
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Set collection to pager
|
7 |
+
*
|
8 |
+
* @param Varien_Data_Collection $collection
|
9 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
10 |
+
*/
|
11 |
+
public function setCollection($collection)
|
12 |
+
{
|
13 |
+
$res = Mage::registry('ea_result');
|
14 |
+
|
15 |
+
if ($res != null){
|
16 |
+
|
17 |
+
//over write the collection with ea collection
|
18 |
+
// $this->_collection = $collection;
|
19 |
+
$this->_collection = $this->getParentBlock()->getLoadedProductCollection();
|
20 |
+
// $this->_collection = $this->getLayout()->getBlock('search.result')->getListBlock()->getLoadedProductCollection() ;
|
21 |
+
|
22 |
+
$this->_collection->setCurPage($this->getCurrentPage());
|
23 |
+
|
24 |
+
// we need to set pagination only if passed value integer and more that 0
|
25 |
+
$limit = (int)$this->getLimit();
|
26 |
+
if ($limit) {
|
27 |
+
$this->_collection->setPageSize($limit);
|
28 |
+
}
|
29 |
+
if ($this->getCurrentOrder()) {
|
30 |
+
$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
|
31 |
+
}
|
32 |
+
return $this;
|
33 |
+
} else {
|
34 |
+
return parent::setCollection($collection);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get grit products sort order field
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function getCurrentOrder()
|
44 |
+
{
|
45 |
+
$res = Mage::registry('ea_result');
|
46 |
+
|
47 |
+
if ($res != null){
|
48 |
+
//get the order from easyask
|
49 |
+
$order = $this->_getData('_current_grid_order');
|
50 |
+
if ($order) {
|
51 |
+
return $order;
|
52 |
+
}
|
53 |
+
|
54 |
+
$event_data_array = array(
|
55 |
+
'relevance' => 'relevance',
|
56 |
+
'Product Name' => 'name',
|
57 |
+
'Price' => 'price');
|
58 |
+
$varien_object = new Varien_Object($event_data_array);
|
59 |
+
Mage::dispatchEvent('catalog_controller_sortmap_update_get', array('varien_obj'=>$varien_object));
|
60 |
+
|
61 |
+
$orders = $varien_object->getData();
|
62 |
+
|
63 |
+
$defaultOrder = $this->_orderField;
|
64 |
+
|
65 |
+
if (!isset($orders[$defaultOrder])) {
|
66 |
+
$keys = array_keys($orders);
|
67 |
+
$defaultOrder = $keys[0];
|
68 |
+
}
|
69 |
+
|
70 |
+
$order = substr($res->getSortOrder(), 0, strpos($res->getSortOrder(), ','));
|
71 |
+
if ($order === 'EAScore'){
|
72 |
+
$order = $defaultOrder;
|
73 |
+
}
|
74 |
+
if ($order && isset($orders[$order])) {
|
75 |
+
if ($order == $defaultOrder) {
|
76 |
+
Mage::getSingleton('catalog/session')->unsSortOrder();
|
77 |
+
} else {
|
78 |
+
$this->_memorizeParam('sort_order', $orders[$order]);
|
79 |
+
}
|
80 |
+
} else {
|
81 |
+
$order = Mage::getSingleton('catalog/session')->getSortOrder();
|
82 |
+
}
|
83 |
+
// validate session value
|
84 |
+
if (!$order || !isset($orders[$order])) {
|
85 |
+
$order = $defaultOrder;
|
86 |
+
}
|
87 |
+
$this->setData('_current_grid_order', $orders[$order]);
|
88 |
+
return $order;
|
89 |
+
} else {
|
90 |
+
return parent::getCurrentOrder();
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
}
|
96 |
+
?>
|
app/code/local/EasyAsk/Search/Block/Catalog/Product/List/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Block/Catalog/Product/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Block/Catalog/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Block/CatalogSearch/Layer.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Block_CatalogSearch_Layer extends Mage_CatalogSearch_Block_Layer {
|
3 |
+
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Get all layer filters
|
7 |
+
*
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
public function getFilters()
|
11 |
+
{
|
12 |
+
$filters = array();
|
13 |
+
if ($categoryFilter = $this->_getCategoryFilter()) {
|
14 |
+
$filters[] = $categoryFilter;
|
15 |
+
}
|
16 |
+
|
17 |
+
$filterableAttributes = $this->_getFilterableAttributes();
|
18 |
+
foreach ($filterableAttributes as $attribute) {
|
19 |
+
$filters[] = $this->getChild($attribute['name'] . '_filter');
|
20 |
+
}
|
21 |
+
|
22 |
+
return $filters;
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get all fiterable attributes of current category
|
29 |
+
*
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
protected function _getFilterableAttributes()
|
33 |
+
{
|
34 |
+
$attributes = $this->getData('_filterable_attributes');
|
35 |
+
if (is_null($attributes)) {
|
36 |
+
$attributes = $this->getLayer()->getFilterableAttributes();
|
37 |
+
$this->setData('_filterable_attributes', $attributes);
|
38 |
+
}
|
39 |
+
|
40 |
+
return $attributes;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Get all fiterable attributes of current category
|
45 |
+
*
|
46 |
+
* @return array
|
47 |
+
*/
|
48 |
+
protected function _getStateAttributes()
|
49 |
+
{
|
50 |
+
$attributes = $this->getData('_state_attributes');
|
51 |
+
if (is_null($attributes)) {
|
52 |
+
$attributes = $this->getLayer()->getStateAttributes();
|
53 |
+
$this->setData('_state_attributes', $attributes);
|
54 |
+
}
|
55 |
+
|
56 |
+
return $attributes;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Prepare child blocks
|
61 |
+
*
|
62 |
+
* @return Mage_Catalog_Block_Layer_View
|
63 |
+
*/
|
64 |
+
protected function _prepareLayout()
|
65 |
+
{
|
66 |
+
|
67 |
+
$res = Mage::registry('ea_result');
|
68 |
+
$categoryCount = 0;
|
69 |
+
if ($res != null){
|
70 |
+
$categoryCount = $res->getInitDisplayLimitForCategories();
|
71 |
+
// }
|
72 |
+
|
73 |
+
|
74 |
+
$stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)
|
75 |
+
->setLayer($this->getLayer());
|
76 |
+
|
77 |
+
if ($categoryCount > 0){
|
78 |
+
$categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
|
79 |
+
->setLayer($this->getLayer())
|
80 |
+
->setIsInitDisplayLimited($categoryCount)
|
81 |
+
->init();
|
82 |
+
} else {
|
83 |
+
$categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
|
84 |
+
->setLayer($this->getLayer())
|
85 |
+
->init();
|
86 |
+
}
|
87 |
+
|
88 |
+
$this->setChild('layer_state', $stateBlock);
|
89 |
+
$this->setChild('category_filter', $categoryBlock);
|
90 |
+
|
91 |
+
$filterableAttributes = $this->_getFilterableAttributes();
|
92 |
+
$stateAttributes = $this->_getStateAttributes();
|
93 |
+
$selectedAttributes = array();
|
94 |
+
|
95 |
+
foreach ($stateAttributes as $selectedAttribute){
|
96 |
+
$selectedAttributes[] = substr($selectedAttribute, 0, strpos($selectedAttribute, '='));
|
97 |
+
}
|
98 |
+
|
99 |
+
foreach ($filterableAttributes as $attribute) {
|
100 |
+
$filterBlockName = $this->_attributeFilterBlockName;
|
101 |
+
if ($attribute['expand'] == true || in_array($attribute['name'], $selectedAttributes)){
|
102 |
+
$this->setChild($attribute['name'] . '_filter',
|
103 |
+
$this->getLayout()->createBlock($filterBlockName)
|
104 |
+
->setLayer($this->getLayer())
|
105 |
+
->setAttributeModel($attribute['name'])
|
106 |
+
->setAttributeCode('2')
|
107 |
+
->setIsInitDisplayLimited($attribute['dispLimited'])
|
108 |
+
->setIsRangeFilter($attribute['isRangeFilter'])
|
109 |
+
->init());
|
110 |
+
} else {
|
111 |
+
if ($attribute['name']){
|
112 |
+
$this->setChild($attribute['name'] . '_filter',
|
113 |
+
$this->getLayout()->createBlock($filterBlockName)
|
114 |
+
->setLayer($this->getLayer())
|
115 |
+
->setAttributeModel($attribute['name'])
|
116 |
+
->setAttributeCode('0')
|
117 |
+
->setIsInitDisplayLimited($attribute['dispLimited'])
|
118 |
+
->setIsRangeFilter($attribute['isRangeFilter'])
|
119 |
+
->init());
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
foreach ($stateAttributes as $attribute) {
|
125 |
+
$filterBlockName = $this->_attributeFilterBlockName;
|
126 |
+
$this->setChild($attribute . '_state_filter',
|
127 |
+
$this->getLayout()->createBlock($filterBlockName)
|
128 |
+
->setLayer($this->getLayer())
|
129 |
+
->setAttributeModel($attribute)
|
130 |
+
->setAttributeCode('1')
|
131 |
+
->init());
|
132 |
+
}
|
133 |
+
|
134 |
+
$this->getLayer()->apply();
|
135 |
+
return;
|
136 |
+
|
137 |
+
} else {
|
138 |
+
return parent::_prepareLayout();
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
app/code/local/EasyAsk/Search/Block/CatalogSearch/Layer/Filter/Attribute.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Block_CatalogSearch_Layer_Filter_Attribute extends Mage_CatalogSearch_Block_Layer_Filter_Attribute
|
3 |
+
{
|
4 |
+
protected function _prepareFilter()
|
5 |
+
{
|
6 |
+
$this->_filter->setAttributeModel($this->getAttributeModel());
|
7 |
+
$this->_filter->setAttributeCode($this->getAttributeCode());
|
8 |
+
$this->_filter->setIsAttributeSelected($this->_isAttributeSelected());
|
9 |
+
return $this;
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function _isAttributeSelected(){
|
13 |
+
$isCurrentAttribute = false;
|
14 |
+
$res = Mage::registry('ea_result');
|
15 |
+
if ($res != null){
|
16 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
17 |
+
if (count($searchPath) > 0){
|
18 |
+
for($i = 1; $i < count($searchPath) ; $i++){
|
19 |
+
$eapath = $searchPath[$i]->getPath();
|
20 |
+
$eapatharr = explode('////', $eapath);
|
21 |
+
$attrarray = array();
|
22 |
+
foreach ($eapatharr as $attrpath){
|
23 |
+
if (strpos($attrpath, 'AttribSelect') !== false){
|
24 |
+
$attribsel = substr($attrpath, 13);
|
25 |
+
$attrib = substr($attribsel, 0, strpos($attribsel, '='));
|
26 |
+
if ($attrib === $this->getAttributeModel()){
|
27 |
+
$isCurrentAttribute = true;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
return $isCurrentAttribute;
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
38 |
+
?>
|
app/code/local/EasyAsk/Search/Block/CatalogSearch/Layer/Filter/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Block/CatalogSearch/Layer/State.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EasyAsk_Search_Block_CatalogSearch_Layer_State extends Mage_Catalog_Block_Layer_State
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Retrieve Clear Filters URL
|
8 |
+
*
|
9 |
+
* @return string
|
10 |
+
*/
|
11 |
+
public function getClearUrl()
|
12 |
+
{
|
13 |
+
$res = Mage::registry('ea_result');
|
14 |
+
|
15 |
+
if ($res != null){
|
16 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
17 |
+
$eapath = $searchPath[1]->getSEOPath();
|
18 |
+
$params = array();
|
19 |
+
$params['ea_path'] = $eapath;
|
20 |
+
$params['ea_c'] = '';
|
21 |
+
$params['ea_a'] = '';
|
22 |
+
$params['ea_bc'] = '';
|
23 |
+
|
24 |
+
$urlParams = array();
|
25 |
+
$urlParams['_current'] = true;
|
26 |
+
$urlParams['_escape'] = true;
|
27 |
+
$urlParams['_use_rewrite'] = true;
|
28 |
+
$urlParams['_query'] = $params;
|
29 |
+
return $this->getUrl('*/*/*', $urlParams);
|
30 |
+
} else {
|
31 |
+
return parent::getClearUrl();
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
36 |
+
?>
|
app/code/local/EasyAsk/Search/Block/CatalogSearch/Layer/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Block/CatalogSearch/Result.php
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Block_CatalogSearch_Result extends Mage_CatalogSearch_Block_Result {
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Prepare layout
|
6 |
+
*
|
7 |
+
* @return Mage_CatalogSearch_Block_Result
|
8 |
+
*/
|
9 |
+
protected function _prepareLayout()
|
10 |
+
{
|
11 |
+
$res = Mage::registry('ea_result');
|
12 |
+
if ($res != null){
|
13 |
+
// add Home breadcrumb
|
14 |
+
$breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
|
15 |
+
if ($breadcrumbs) {
|
16 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
17 |
+
|
18 |
+
$breadcrumbs->addCrumb('home', array(
|
19 |
+
'label' => $this->__('Home'),
|
20 |
+
'title' => $this->__('Go to Home Page'),
|
21 |
+
'link' => Mage::getBaseUrl()
|
22 |
+
));
|
23 |
+
if (count($searchPath) > 0){
|
24 |
+
for($i = 1; $i < count($searchPath) ; $i++){
|
25 |
+
if ($i != count($searchPath) - 1){
|
26 |
+
$seopath = $searchPath[$i]->getSEOPath();
|
27 |
+
$link = '?q='.Mage::helper('catalogsearch')->getQueryText().'&ea_bc='. $seopath;
|
28 |
+
if ($searchPath[$i]->getType() == 1){
|
29 |
+
$link = $link . '&cat=' . $searchPath[$i]->getValue();
|
30 |
+
} else if ($searchPath[$i]->getType() == 2){
|
31 |
+
$eapath = $searchPath[$i]->getPath();
|
32 |
+
$eapatharr = explode('////', $eapath);
|
33 |
+
$attrarray = array();
|
34 |
+
foreach ($eapatharr as $attrpath){
|
35 |
+
if (strpos($attrpath, 'AttribSelect') !== false){
|
36 |
+
$attribsel = substr($attrpath, 13);
|
37 |
+
$attrarray[] = substr($attribsel, 0, strpos($attribsel, '='));
|
38 |
+
}
|
39 |
+
}
|
40 |
+
$seopatharr = explode('/', $seopath);
|
41 |
+
$attrvalarray = array();
|
42 |
+
foreach ($seopatharr as $seopathpart){
|
43 |
+
if (strpos($seopathpart, ':') !== false){
|
44 |
+
$attrvalarray[] = $seopathpart;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
if (sizeof($attrarray) == sizeof($attrvalarray)){
|
49 |
+
for($j = 0; $j < sizeof($attrarray); $j++){
|
50 |
+
$link = $link . '&' . $attrarray[$j] . '=' . $attrvalarray[$j];
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
}
|
55 |
+
$breadcrumbs->addCrumb($searchPath[$i]->getValue(), array(
|
56 |
+
'label' => $searchPath[$i]->getValue(),
|
57 |
+
'title' => $searchPath[$i]->getValue(),
|
58 |
+
'link' => $link
|
59 |
+
));
|
60 |
+
} else {
|
61 |
+
$breadcrumbs->addCrumb($searchPath[$i]->getValue(), array(
|
62 |
+
'label' => $searchPath[$i]->getValue(),
|
63 |
+
'title' => $searchPath[$i]->getValue()
|
64 |
+
));
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
// modify page title
|
71 |
+
$title = $this->__("Search results for: '%s'", $this->helper('catalogsearch')->getEscapedQueryText());
|
72 |
+
$this->getLayout()->getBlock('head')->setTitle($title);
|
73 |
+
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
return parent::_prepareLayout();
|
78 |
+
}
|
79 |
+
|
80 |
+
public function hasBanner($type){
|
81 |
+
$hasBanner = false;
|
82 |
+
$res = Mage::registry('ea_result');
|
83 |
+
if ($res != null){
|
84 |
+
$hasBanner = $res->hasBanner($type);
|
85 |
+
}
|
86 |
+
return $hasBanner;
|
87 |
+
}
|
88 |
+
|
89 |
+
public function getBanner($type){
|
90 |
+
$res = Mage::registry('ea_result');
|
91 |
+
if ($res != null){
|
92 |
+
$banner = $res->getBanner($type);
|
93 |
+
$banneridentifier = $banner->getBlockIdentifier();
|
94 |
+
|
95 |
+
$html = '';
|
96 |
+
$block = Mage::getModel('cms/block')
|
97 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
98 |
+
->load($banneridentifier);
|
99 |
+
if ($block->getIsActive()) {
|
100 |
+
/* @var $helper Mage_Cms_Helper_Data */
|
101 |
+
$helper = Mage::helper('cms');
|
102 |
+
$processor = $helper->getBlockTemplateProcessor();
|
103 |
+
$html = $processor->filter($block->getContent());
|
104 |
+
$this->addModelTags($block);
|
105 |
+
}
|
106 |
+
return $html;
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
}
|
113 |
+
?>
|
app/code/local/EasyAsk/Search/Block/CatalogSearch/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Block/Html/Pager.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Block_Html_Pager extends Mage_Page_Block_Html_Pager{
|
3 |
+
|
4 |
+
public function getPagerUrl($params=array())
|
5 |
+
{
|
6 |
+
$res = Mage::registry('ea_result');
|
7 |
+
|
8 |
+
if ($res != null){
|
9 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
10 |
+
$eapath = $searchPath[count($searchPath) - 1]->getSEOPath();
|
11 |
+
$params['ea_path'] = $eapath;
|
12 |
+
$params['ea_c'] = '';
|
13 |
+
$params['ea_a'] = '';
|
14 |
+
$params['ea_bc'] = '';
|
15 |
+
|
16 |
+
$urlParams = array();
|
17 |
+
$urlParams['_current'] = true;
|
18 |
+
$urlParams['_escape'] = true;
|
19 |
+
$urlParams['_use_rewrite'] = true;
|
20 |
+
$urlParams['_query'] = $params;
|
21 |
+
return $this->getUrl('*/*/*', $urlParams);
|
22 |
+
} else {
|
23 |
+
return parent::getPagerUrl($params);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
28 |
+
?>
|
app/code/local/EasyAsk/Search/Block/Html/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Helper/Category.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Helper_Category extends Mage_Catalog_Helper_Category {
|
3 |
+
/**
|
4 |
+
* Retrieve category url
|
5 |
+
*
|
6 |
+
* @param Mage_Catalog_Model_Category $category
|
7 |
+
* @return string
|
8 |
+
*/
|
9 |
+
public function getCategoryUrl($category)
|
10 |
+
{
|
11 |
+
$easyask_nav = Mage::getStoreConfig('catalog/navigation/use_easyask');
|
12 |
+
|
13 |
+
$catUrl = null;
|
14 |
+
if ($category instanceof Mage_Catalog_Model_Category) {
|
15 |
+
$catUrl = $category->getUrl();
|
16 |
+
} else {
|
17 |
+
$catUrl = Mage::getModel('catalog/category')
|
18 |
+
->setData($category->getData())
|
19 |
+
->getUrl();
|
20 |
+
}
|
21 |
+
|
22 |
+
if ($easyask_nav){
|
23 |
+
//Rewrite the url for EasyAsk
|
24 |
+
$catUrl = Mage::getBaseUrl().'catalogsearch/result/index/?ea_c='.str_replace('/', '_', substr($catUrl, strlen(Mage::getBaseUrl())));
|
25 |
+
}
|
26 |
+
return $catUrl;
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
}
|
app/code/local/EasyAsk/Search/Helper/Data.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento Enterprise Edition
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Magento Enterprise Edition License
|
8 |
+
* that is bundled with this package in the file LICENSE_EE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.magentocommerce.com/license/enterprise-edition
|
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 Enterprise
|
22 |
+
* @package Enterprise_Search
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://www.magentocommerce.com/license/enterprise-edition
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* EasyAsk search helper
|
29 |
+
*
|
30 |
+
* @category EasyAsk
|
31 |
+
* @package EasyAsk_Search
|
32 |
+
* @author EasyAsk
|
33 |
+
*/
|
34 |
+
|
35 |
+
class EasyAsk_Search_Helper_Data extends Mage_Core_Helper_Abstract
|
36 |
+
{
|
37 |
+
public function loadProductsFromMagentoDB() {
|
38 |
+
return Mage::getStoreConfig('catalog/frontend/use_magento_db');
|
39 |
+
}
|
40 |
+
|
41 |
+
public function cacheAttributes($cacheKey, $res, $cache){
|
42 |
+
|
43 |
+
$attributedata = array();
|
44 |
+
// As this is the first time a search is done, store it in cache
|
45 |
+
$attributes = $res->getAttributeNamesFull();
|
46 |
+
foreach ($attributes as $attribute) {
|
47 |
+
$attributeValues = null;
|
48 |
+
if ($res->getInitialDispLimitForAttrValues($attribute) > 0){
|
49 |
+
$attributeValues = $res->getDetailedAttributeValues($attribute, 1);
|
50 |
+
foreach ($res->getDetailedAttributeValuesFull($attribute) as $attrValue){
|
51 |
+
$attributeValues [] = $attrValue;
|
52 |
+
}
|
53 |
+
} else {
|
54 |
+
$attributeValues = $res->getDetailedAttributeValuesFull($attribute);
|
55 |
+
}
|
56 |
+
$attrvalues = array();
|
57 |
+
foreach ($attributeValues as $attributeValue) {
|
58 |
+
$attrvalues[] = array('ns'=>$attributeValue->getNodeString(), 'ds'=>$attributeValue->getDisplayName(), 'pc'=>$attributeValue->getProductCount(), 'id'=>$res->getInitialDispLimitForAttrValues($attribute));
|
59 |
+
}
|
60 |
+
$attributedata [$attribute] = $attrvalues;
|
61 |
+
}
|
62 |
+
|
63 |
+
// Save the initial attributes list if there is one
|
64 |
+
$isDispLimited = $res->isInitialDispLimitedForAttrNames();
|
65 |
+
if ($isDispLimited){
|
66 |
+
// If the initial display is limited then expand the number of attributes specified
|
67 |
+
$initialdisparray = $res->getInitialDisplayList(1);
|
68 |
+
$cache->save(serialize($initialdisparray), $cacheKey . '_initial', array("easyask_cache"), 60*60*24);
|
69 |
+
}
|
70 |
+
// if (!$cache->load($queryText)){
|
71 |
+
$cache->save(serialize($attributedata), $cacheKey, array("easyask_cache"), 60*60*24);
|
72 |
+
$cache->save(serialize($attributedata), $cacheKey . '_original', array("easyask_cache"), 60*60*24);
|
73 |
+
// }
|
74 |
+
}
|
75 |
+
|
76 |
+
public function updateCachedAttributes($queryText, $attributes, $res, $cache){
|
77 |
+
//Now let us save the attribute values of all the attribute other than the selected attribute
|
78 |
+
$allAttributes = unserialize(Mage::app()->getCache()->load($queryText));
|
79 |
+
foreach ($attributes as $attribute){
|
80 |
+
$path = $res->getCatPath();
|
81 |
+
|
82 |
+
if(strpos($path, $attribute) == false){
|
83 |
+
if ($res->getInitialDispLimitForAttrValues($attribute) > 0){
|
84 |
+
$attributeValues = $res->getDetailedAttributeValues($attribute, 1);
|
85 |
+
foreach ($res->getDetailedAttributeValuesFull($attribute) as $attrValue){
|
86 |
+
$attributeValues [] = $attrValue;
|
87 |
+
}
|
88 |
+
} else {
|
89 |
+
$attributeValues = $res->getDetailedAttributeValuesFull($attribute);
|
90 |
+
}
|
91 |
+
$attrvalues = array();
|
92 |
+
foreach ($attributeValues as $attributeValue) {
|
93 |
+
$attrvalues[] = array('ns'=>$attributeValue->getNodeString(), 'ds'=>$attributeValue->getDisplayName(), 'pc'=>$attributeValue->getProductCount(), 'id'=>$res->getInitialDispLimitForAttrValues($attribute));
|
94 |
+
}
|
95 |
+
$allAttributes[$attribute] = $attrvalues;
|
96 |
+
} else if ($this->isOnlyAttribute($res)){
|
97 |
+
$origAttributes = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked() . '_original'));
|
98 |
+
if (in_array($attribute, array_keys($allAttributes))){
|
99 |
+
if (in_array($attribute, array_keys($origAttributes))){
|
100 |
+
$allAttributes[$attribute] = $origAttributes[$attribute];
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
$cache->save(serialize($allAttributes), $queryText, array("easyask_cache"), 60*60*24);
|
107 |
+
}
|
108 |
+
|
109 |
+
public function getCatPath($res){
|
110 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
111 |
+
// var_dump($searchPath); exit;
|
112 |
+
$eapathseo = $searchPath[count($searchPath) - 1]->getSEOPath();
|
113 |
+
|
114 |
+
$eapathseoarr = explode('/', $eapathseo);
|
115 |
+
$catPath = '';
|
116 |
+
foreach ($eapathseoarr as $eapathseo1) {
|
117 |
+
if (!(strpos($eapathseo1, '-', 0) === 0) && !(strpos($eapathseo1, ':') > 0)){
|
118 |
+
$catPath = strlen($catPath) > 0 ? $catPath . '-'. $eapathseo1 : $eapathseo1;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
return $catPath;
|
122 |
+
}
|
123 |
+
|
124 |
+
private function isOnlyAttribute($res){
|
125 |
+
$numAttrs = 0;
|
126 |
+
$numCategories = 0;
|
127 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
128 |
+
foreach ($searchPath as $path){
|
129 |
+
if ($path->getType() == 2){
|
130 |
+
$numAttrs += 1;
|
131 |
+
}
|
132 |
+
if($path->getType() == 1){
|
133 |
+
$numCategories +=1;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
if (($numAttrs == 1) && !($numCategories > 1)){
|
137 |
+
return true;
|
138 |
+
}
|
139 |
+
return false;
|
140 |
+
}
|
141 |
+
}
|
app/code/local/EasyAsk/Search/Helper/Eae.php
ADDED
@@ -0,0 +1,416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
ini_set('memory_limit', '1024M');
|
3 |
+
|
4 |
+
class EasyAsk_Search_Helper_Eae extends Mage_Core_Helper_Abstract
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* Contains current category collection
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_categoryList = null;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Contains current attribute collection
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $_attributeList = null;
|
17 |
+
protected $_selectableAttributeList = null;
|
18 |
+
protected $_multiselectableAttributeList = null;
|
19 |
+
protected $_selectableAttributes = null;
|
20 |
+
protected $_multiselectableAttributes = null;
|
21 |
+
protected $_config = null;
|
22 |
+
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
+
|
26 |
+
$atts = $this->_getXmlConfig()->getXpath('field');
|
27 |
+
|
28 |
+
//Categories
|
29 |
+
$category = Mage::getModel ( 'catalog/category' );
|
30 |
+
$tree = $category->getTreeModel ();
|
31 |
+
$tree->load ();
|
32 |
+
|
33 |
+
$this->setCategoryList($tree->getCollection ()->getAllIds());
|
34 |
+
|
35 |
+
// $tempAttribs = null;
|
36 |
+
$attributes = null;
|
37 |
+
foreach ($atts as $attr){
|
38 |
+
$attributes[] = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', $attr->asArray());
|
39 |
+
}
|
40 |
+
|
41 |
+
//Attributes
|
42 |
+
// $attributes = Mage::getResourceModel ( 'catalog/product_attribute_collection' )->getItems();
|
43 |
+
$this->setAttributeList($attributes);
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Sets current collection
|
49 |
+
* @param $query
|
50 |
+
*/
|
51 |
+
public function setCategoryList($collection)
|
52 |
+
{
|
53 |
+
$this->_categoryList = $collection;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Sets current collection
|
58 |
+
* @param $query
|
59 |
+
*/
|
60 |
+
public function setAttributeList($collection)
|
61 |
+
{
|
62 |
+
$this->_attributeList = $collection;
|
63 |
+
|
64 |
+
|
65 |
+
//make a subset of selectable attributes
|
66 |
+
foreach ($collection as $attribute){
|
67 |
+
$attribData = $attribute->getData();
|
68 |
+
if ($attribData['frontend_input'] == 'select'){
|
69 |
+
$this->_selectableAttributeList[] = $attribData;
|
70 |
+
$this->_selectableAttributes[$attribData['attribute_code']] = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribData['attribute_code'])->getSource()->getAllOptions(true);
|
71 |
+
}
|
72 |
+
if ($attribData['frontend_input'] == 'multiselect'){
|
73 |
+
$this->_multiselectableAttributeList[] = $attribData;
|
74 |
+
$this->_multiselectableAttributes[$attribData['attribute_code']] = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribData['attribute_code'])->getSource()->getAllOptions(true);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Returns indexes of the fetched array as headers for CSV
|
81 |
+
* @param array $products
|
82 |
+
* @return array
|
83 |
+
*/
|
84 |
+
protected function _getCsvHeaders($product)
|
85 |
+
{
|
86 |
+
$headers = array();
|
87 |
+
|
88 |
+
$keys = array_keys($product->getData());
|
89 |
+
foreach($keys as $key){
|
90 |
+
if (!in_array($key, $headers) && ($key != 'stock_item')){
|
91 |
+
$headers[] = $key;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
foreach ($this->_attributeList as $attribute){
|
96 |
+
$attrCode = $attribute['attribute_code'];
|
97 |
+
if (!in_array($attrCode, $headers) && ($attrCode != 'stock_item')){
|
98 |
+
$headers[] = $attrCode;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
$headers[] = 'qty';
|
103 |
+
$headers[] = 'is_in_stock';
|
104 |
+
$headers[] = 'parent_ids';
|
105 |
+
|
106 |
+
return $headers;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Returns indexes of the fetched array as headers for CSV
|
111 |
+
* @param array $ids
|
112 |
+
* @return array
|
113 |
+
*/
|
114 |
+
protected function _getCatCsvHeaders($ids)
|
115 |
+
{
|
116 |
+
$cat = Mage::getModel('catalog/category');
|
117 |
+
$cat->load($ids[sizeof($ids) - 1]);
|
118 |
+
|
119 |
+
$headers = array_keys($cat->getData());
|
120 |
+
|
121 |
+
return $headers;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Returns indexes of the fetched array as headers for CSV
|
126 |
+
* @param array $attributes
|
127 |
+
* @return array
|
128 |
+
*/
|
129 |
+
protected function _getAttrCsvHeaders($attributes)
|
130 |
+
{
|
131 |
+
$attribute = current($attributes);
|
132 |
+
$headers = array_keys($attribute->getData());
|
133 |
+
|
134 |
+
return $headers;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Returns indexes of the fetched array as data for CSV
|
139 |
+
* @param array $products
|
140 |
+
* @return array
|
141 |
+
*/
|
142 |
+
protected function _getCsvData($rec, $headers)
|
143 |
+
{
|
144 |
+
$data = array();
|
145 |
+
foreach ($headers as $header){
|
146 |
+
$data[$header] = isset($rec[$header]) ? $rec[$header] : '';
|
147 |
+
}
|
148 |
+
|
149 |
+
return $data;
|
150 |
+
}
|
151 |
+
|
152 |
+
protected function _transformProductData($product)
|
153 |
+
{
|
154 |
+
$selectAttributes = $this->_selectableAttributeList;
|
155 |
+
$multiSelectAttributes = $this->_multiselectableAttributeList;
|
156 |
+
foreach ($selectAttributes as $selectAttribute){
|
157 |
+
if (isset($product[$selectAttribute['attribute_code']])){
|
158 |
+
$attributeOptions = $this->_selectableAttributes[$selectAttribute['attribute_code']];
|
159 |
+
foreach ($attributeOptions as $option) {
|
160 |
+
if ($option['value'] == $product[$selectAttribute['attribute_code']]){
|
161 |
+
$product[$selectAttribute['attribute_code']] = $option['label'];
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
}
|
166 |
+
foreach ($multiSelectAttributes as $multiSelectAttribute){
|
167 |
+
if (isset($product[$multiSelectAttribute['attribute_code']])){
|
168 |
+
$multiAttributes = explode(",", $product[$multiSelectAttribute['attribute_code']]);
|
169 |
+
$multiAttributeLabels = array();
|
170 |
+
$attributeOptions = $this->_multiselectableAttributes[$multiSelectAttribute['attribute_code']];
|
171 |
+
|
172 |
+
foreach ($multiAttributes as $multiAttribute){
|
173 |
+
foreach ($attributeOptions as $option) {
|
174 |
+
if ($option['value'] == $multiAttribute){
|
175 |
+
$multiAttributeLabels[] = $option['label'];
|
176 |
+
}
|
177 |
+
}
|
178 |
+
}
|
179 |
+
$product[$multiSelectAttribute['attribute_code']] = implode(",", $multiAttributeLabels);
|
180 |
+
}
|
181 |
+
}
|
182 |
+
return $product;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Generates CSV file with product's list according to the collection in the $this->_productList
|
187 |
+
* @return array
|
188 |
+
*/
|
189 |
+
public function generateEaeProductsList()
|
190 |
+
{
|
191 |
+
$prodcollection = Mage::getModel('catalog/product')->getCollection()->setPageSize(1);//->addAttributeToSelect('*');
|
192 |
+
|
193 |
+
$count = $prodcollection->getSize();
|
194 |
+
|
195 |
+
$io = new Varien_Io_File();
|
196 |
+
$path = Mage::getBaseDir('var') . DS . 'export' . DS;
|
197 |
+
$name = md5(microtime());
|
198 |
+
$file = $path . DS . $name . '.csv';
|
199 |
+
$io->setAllowCreateFolders(true);
|
200 |
+
$io->open(array('path' => $path));
|
201 |
+
$io->streamOpen($file, 'w+');
|
202 |
+
$io->streamLock(true);
|
203 |
+
|
204 |
+
$page = 1;
|
205 |
+
$pageSize = 200;
|
206 |
+
$headers = array();
|
207 |
+
|
208 |
+
foreach ($prodcollection as $prod){
|
209 |
+
$headers = $this->_getCsvHeaders($prod);
|
210 |
+
}
|
211 |
+
|
212 |
+
while ($count > ($pageSize * ($page - 1))){
|
213 |
+
$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->setPageSize($pageSize)->setCurPage($page);
|
214 |
+
|
215 |
+
if (!is_null($collection)) {
|
216 |
+
$i = 0;
|
217 |
+
foreach ($collection as $product) {
|
218 |
+
|
219 |
+
if (($i == 0) && ($page == 1)){
|
220 |
+
$io->streamWriteCsv($headers);
|
221 |
+
}
|
222 |
+
|
223 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
224 |
+
$proddata = $product->getData();
|
225 |
+
$proddata = $this->_transformProductData($proddata);
|
226 |
+
unset($proddata['stock_item']);
|
227 |
+
$proddata['qty'] = $stockItem->getQty();
|
228 |
+
$proddata['is_in_stock'] = $stockItem->getIsInStock;
|
229 |
+
$proddata['parent_ids'] = $this->_getParentIds($product);
|
230 |
+
$data = $this->_getCsvData($proddata, $headers);
|
231 |
+
$io->streamWriteCsv($data);
|
232 |
+
$i++;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
$page++;
|
236 |
+
}
|
237 |
+
return array(
|
238 |
+
'type' => 'filename',
|
239 |
+
'value' => $file,
|
240 |
+
'rm' => false // can delete file after use
|
241 |
+
);
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Generates CSV file with category list according to the collection in the $this->_categoryList
|
247 |
+
* @return array
|
248 |
+
*/
|
249 |
+
public function generateEaeCategoriesList()
|
250 |
+
{
|
251 |
+
|
252 |
+
if (!is_null($this->_categoryList)) {
|
253 |
+
$ids = $this->_categoryList;
|
254 |
+
if (count($ids) > 0) {
|
255 |
+
|
256 |
+
$io = new Varien_Io_File();
|
257 |
+
$path = Mage::getBaseDir('var') . DS . 'export' . DS;
|
258 |
+
$name = md5(microtime());
|
259 |
+
$file = $path . DS . $name . '.csv';
|
260 |
+
$io->setAllowCreateFolders(true);
|
261 |
+
$io->open(array('path' => $path));
|
262 |
+
$io->streamOpen($file, 'w+');
|
263 |
+
$io->streamLock(true);
|
264 |
+
|
265 |
+
$headers = $this->_getCatCsvHeaders($ids);
|
266 |
+
$io->streamWriteCsv($headers);
|
267 |
+
foreach ($ids as $id) {
|
268 |
+
|
269 |
+
$cat = Mage::getModel('catalog/category');
|
270 |
+
$cat->load($id);
|
271 |
+
|
272 |
+
$data = $this->_getCsvData($cat->getData(), $headers);
|
273 |
+
|
274 |
+
$io->streamWriteCsv($data);
|
275 |
+
}
|
276 |
+
|
277 |
+
return array(
|
278 |
+
'type' => 'filename',
|
279 |
+
'value' => $file,
|
280 |
+
'rm' => false // can delete file after use
|
281 |
+
);
|
282 |
+
}
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Generates CSV file with attribute list according to the collection in the $this->_attributeList
|
288 |
+
* @return array
|
289 |
+
*/
|
290 |
+
public function generateEaeAttributesList()
|
291 |
+
{
|
292 |
+
|
293 |
+
if (!is_null($this->_attributeList)) {
|
294 |
+
$attributes = $this->_attributeList;
|
295 |
+
if (count($attributes) > 0) {
|
296 |
+
|
297 |
+
$io = new Varien_Io_File();
|
298 |
+
$path = Mage::getBaseDir('var') . DS . 'export' . DS;
|
299 |
+
$name = md5(microtime());
|
300 |
+
$file = $path . DS . $name . '.csv';
|
301 |
+
$io->setAllowCreateFolders(true);
|
302 |
+
$io->open(array('path' => $path));
|
303 |
+
$io->streamOpen($file, 'w+');
|
304 |
+
$io->streamLock(true);
|
305 |
+
|
306 |
+
$io->streamWriteCsv($this->_getAttrCsvHeaders($attributes));
|
307 |
+
foreach ($attributes as $attribute) {
|
308 |
+
$attrdata = $attribute->getData();
|
309 |
+
$io->streamWriteCsv($attrdata);
|
310 |
+
}
|
311 |
+
|
312 |
+
return array(
|
313 |
+
'type' => 'filename',
|
314 |
+
'value' => $file,
|
315 |
+
'rm' => false // can delete file after use
|
316 |
+
);
|
317 |
+
}
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Generates CSV file with category products list according to the collection in the $this->_categoryList
|
323 |
+
* @return array
|
324 |
+
*/
|
325 |
+
public function generateEaeCategoryProductsList()
|
326 |
+
{
|
327 |
+
|
328 |
+
if (!is_null($this->_categoryList)) {
|
329 |
+
$ids = $this->_categoryList;
|
330 |
+
if (count($ids) > 0) {
|
331 |
+
|
332 |
+
$io = new Varien_Io_File();
|
333 |
+
$path = Mage::getBaseDir('var') . DS . 'export' . DS;
|
334 |
+
$name = md5(microtime());
|
335 |
+
$file = $path . DS . $name . '.csv';
|
336 |
+
$io->setAllowCreateFolders(true);
|
337 |
+
$io->open(array('path' => $path));
|
338 |
+
$io->streamOpen($file, 'w+');
|
339 |
+
$io->streamLock(true);
|
340 |
+
|
341 |
+
$headers = array('category_id', 'product_id');
|
342 |
+
$io->streamWriteCsv($headers);
|
343 |
+
foreach ($ids as $id) {
|
344 |
+
|
345 |
+
$cat = Mage::getModel('catalog/category');
|
346 |
+
$cat->load($id);
|
347 |
+
|
348 |
+
$products = Mage::getModel('catalog/product')
|
349 |
+
->getCollection()
|
350 |
+
->addCategoryFilter($cat)
|
351 |
+
->load();
|
352 |
+
|
353 |
+
if (!is_null($products)) {
|
354 |
+
foreach ($products as $product) {
|
355 |
+
$catProduct = array();
|
356 |
+
|
357 |
+
$catProduct['category_id'] = $cat->getEntityId();
|
358 |
+
|
359 |
+
$proddata = $product->getData();
|
360 |
+
$catProduct['product_id'] = $proddata['entity_id'];
|
361 |
+
|
362 |
+
$data = $this->_getCsvData($catProduct, $headers);
|
363 |
+
$io->streamWriteCsv($data);
|
364 |
+
}
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
return array(
|
369 |
+
'type' => 'filename',
|
370 |
+
'value' => $file,
|
371 |
+
'rm' => false // can delete file after use
|
372 |
+
);
|
373 |
+
}
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
protected function _getParentIds($product){
|
378 |
+
$parentIds = array();
|
379 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')
|
380 |
+
->getParentIdsByChild( $product->getId() );
|
381 |
+
$parentIds = Mage::getResourceSingleton('bundle/selection')
|
382 |
+
->getParentIdsByChild($childId);
|
383 |
+
$parentIds = Mage::getModel('catalog/product_type_virtual')
|
384 |
+
->getParentIdsByChild( $product->getId() );
|
385 |
+
return implode(",", $parentIds);
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Load config from files and try to cache it
|
390 |
+
*
|
391 |
+
* @return Varien_Simplexml_Config
|
392 |
+
*/
|
393 |
+
protected function _getXmlConfig()
|
394 |
+
{
|
395 |
+
if (is_null($this->_config)) {
|
396 |
+
$canUseCache = Mage::app()->useCache('config');
|
397 |
+
$cachedXml = Mage::app()->loadCache('attrib_config');
|
398 |
+
if ($canUseCache && $cachedXml) {
|
399 |
+
$xmlConfig = new Varien_Simplexml_Config($cachedXml);
|
400 |
+
} else {
|
401 |
+
|
402 |
+
|
403 |
+
$xmlPath = Mage::getBaseDir().DS.'app'.DS.'code'.DS.'local'.DS.'EasyAsk'.DS.'Search'.DS.'etc'.DS.'attrib.xml';
|
404 |
+
$xmlConfig = new Varien_Simplexml_Config($xmlPath);
|
405 |
+
|
406 |
+
if ($canUseCache) {
|
407 |
+
Mage::app()->saveCache($xmlConfig->getXmlString(), 'attrib_config',
|
408 |
+
array(Mage_Core_Model_Config::CACHE_TAG));
|
409 |
+
}
|
410 |
+
}
|
411 |
+
$this->_config = $xmlConfig;
|
412 |
+
}
|
413 |
+
return $this->_config;
|
414 |
+
}
|
415 |
+
|
416 |
+
}
|
app/code/local/EasyAsk/Search/Helper/Eae.php.bak
ADDED
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
ini_set('memory_limit', '1024M');
|
3 |
+
|
4 |
+
class EasyAsk_Search_Helper_Eae extends Mage_Core_Helper_Abstract
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* Contains current category collection
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_categoryList = null;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Contains current attribute collection
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $_attributeList = null;
|
17 |
+
protected $_selectableAttributeList = null;
|
18 |
+
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
//Categories
|
22 |
+
$category = Mage::getModel ( 'catalog/category' );
|
23 |
+
$tree = $category->getTreeModel ();
|
24 |
+
$tree->load ();
|
25 |
+
|
26 |
+
$this->setCategoryList($tree->getCollection ()->getAllIds());
|
27 |
+
|
28 |
+
//Attributes
|
29 |
+
$attributes = Mage::getResourceModel ( 'catalog/product_attribute_collection' )->getItems();
|
30 |
+
$this->setAttributeList($attributes);
|
31 |
+
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Sets current collection
|
36 |
+
* @param $query
|
37 |
+
*/
|
38 |
+
public function setCategoryList($collection)
|
39 |
+
{
|
40 |
+
$this->_categoryList = $collection;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Sets current collection
|
45 |
+
* @param $query
|
46 |
+
*/
|
47 |
+
public function setAttributeList($collection)
|
48 |
+
{
|
49 |
+
$this->_attributeList = $collection;
|
50 |
+
//make a subset of selectable attributes
|
51 |
+
foreach ($collection as $attribute){
|
52 |
+
$attribData = $attribute->getData();
|
53 |
+
if ($attribData['frontend_input'] == 'select'){
|
54 |
+
$this->_selectableAttributeList[] = $attribData;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Returns indexes of the fetched array as headers for CSV
|
61 |
+
* @param array $products
|
62 |
+
* @return array
|
63 |
+
*/
|
64 |
+
protected function _getCsvHeaders($product)
|
65 |
+
{
|
66 |
+
$headers = array();
|
67 |
+
|
68 |
+
$keys = array_keys($product->getData());
|
69 |
+
foreach($keys as $key){
|
70 |
+
if (!in_array($key, $headers) && ($key != 'stock_item')){
|
71 |
+
$headers[] = $key;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
foreach ($this->_attributeList as $attribute){
|
76 |
+
$attrCode = $attribute['attribute_code'];
|
77 |
+
if (!in_array($attrCode, $headers) && ($attrCode != 'stock_item')){
|
78 |
+
$headers[] = $attrCode;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
$headers[] = 'qty';
|
83 |
+
$headers[] = 'is_in_stock';
|
84 |
+
|
85 |
+
return $headers;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Returns indexes of the fetched array as headers for CSV
|
90 |
+
* @param array $ids
|
91 |
+
* @return array
|
92 |
+
*/
|
93 |
+
protected function _getCatCsvHeaders($ids)
|
94 |
+
{
|
95 |
+
$cat = Mage::getModel('catalog/category');
|
96 |
+
$cat->load($ids[sizeof($ids) - 1]);
|
97 |
+
|
98 |
+
$headers = array_keys($cat->getData());
|
99 |
+
|
100 |
+
return $headers;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Returns indexes of the fetched array as headers for CSV
|
105 |
+
* @param array $attributes
|
106 |
+
* @return array
|
107 |
+
*/
|
108 |
+
protected function _getAttrCsvHeaders($attributes)
|
109 |
+
{
|
110 |
+
$attribute = current($attributes);
|
111 |
+
$headers = array_keys($attribute->getData());
|
112 |
+
|
113 |
+
return $headers;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Returns indexes of the fetched array as data for CSV
|
118 |
+
* @param array $products
|
119 |
+
* @return array
|
120 |
+
*/
|
121 |
+
protected function _getCsvData($rec, $headers)
|
122 |
+
{
|
123 |
+
$data = array();
|
124 |
+
foreach ($headers as $header){
|
125 |
+
$data[$header] = isset($rec[$header]) ? $rec[$header] : '';
|
126 |
+
}
|
127 |
+
|
128 |
+
return $data;
|
129 |
+
}
|
130 |
+
|
131 |
+
protected function _transformProductData($product)
|
132 |
+
{
|
133 |
+
$selectAttributes = $this->_selectableAttributeList;
|
134 |
+
foreach ($selectAttributes as $selectAttribute){
|
135 |
+
if (isset($product[$selectAttribute['attribute_code']])){
|
136 |
+
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $selectAttribute['attribute_code']);
|
137 |
+
foreach ($attribute->getSource()->getAllOptions(true) as $option) {
|
138 |
+
if ($option['value'] == $product[$selectAttribute['attribute_code']]){
|
139 |
+
$product[$selectAttribute['attribute_code']] = $option['label'];
|
140 |
+
}
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
return $product;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Generates CSV file with product's list according to the collection in the $this->_productList
|
149 |
+
* @return array
|
150 |
+
*/
|
151 |
+
public function generateEaeProductsList()
|
152 |
+
{
|
153 |
+
$prodcollection = Mage::getModel('catalog/product')->getCollection()->setPageSize(1);//->addAttributeToSelect('*');
|
154 |
+
|
155 |
+
$count = $prodcollection->getSize();
|
156 |
+
|
157 |
+
$io = new Varien_Io_File();
|
158 |
+
$path = Mage::getBaseDir('var') . DS . 'export' . DS;
|
159 |
+
$name = md5(microtime());
|
160 |
+
$file = $path . DS . $name . '.csv';
|
161 |
+
$io->setAllowCreateFolders(true);
|
162 |
+
$io->open(array('path' => $path));
|
163 |
+
$io->streamOpen($file, 'w+');
|
164 |
+
$io->streamLock(true);
|
165 |
+
|
166 |
+
$page = 1;
|
167 |
+
$pageSize = 200;
|
168 |
+
$headers = array();
|
169 |
+
|
170 |
+
foreach ($prodcollection as $prod){
|
171 |
+
$headers = $this->_getCsvHeaders($prod);
|
172 |
+
}
|
173 |
+
|
174 |
+
while ($count > ($pageSize * ($page - 1))){
|
175 |
+
$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->setPageSize($pageSize)->setCurPage($page);
|
176 |
+
|
177 |
+
if (!is_null($collection)) {
|
178 |
+
$i = 0;
|
179 |
+
foreach ($collection as $product) {
|
180 |
+
|
181 |
+
if (($i == 0) && ($page == 1)){
|
182 |
+
$io->streamWriteCsv($headers);
|
183 |
+
}
|
184 |
+
|
185 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
186 |
+
$proddata = $product->getData();
|
187 |
+
$proddata = $this->_transformProductData($proddata);
|
188 |
+
unset($proddata['stock_item']);
|
189 |
+
$proddata['qty'] = $stockItem->getQty();
|
190 |
+
$proddata['is_in_stock'] = $stockItem->getIsInStock;
|
191 |
+
$data = $this->_getCsvData($proddata, $headers);
|
192 |
+
$io->streamWriteCsv($data);
|
193 |
+
$i++;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
$page++;
|
197 |
+
}
|
198 |
+
return array(
|
199 |
+
'type' => 'filename',
|
200 |
+
'value' => $file,
|
201 |
+
'rm' => false // can delete file after use
|
202 |
+
);
|
203 |
+
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Generates CSV file with category list according to the collection in the $this->_categoryList
|
208 |
+
* @return array
|
209 |
+
*/
|
210 |
+
public function generateEaeCategoriesList()
|
211 |
+
{
|
212 |
+
|
213 |
+
if (!is_null($this->_categoryList)) {
|
214 |
+
$ids = $this->_categoryList;
|
215 |
+
if (count($ids) > 0) {
|
216 |
+
|
217 |
+
$io = new Varien_Io_File();
|
218 |
+
$path = Mage::getBaseDir('var') . DS . 'export' . DS;
|
219 |
+
$name = md5(microtime());
|
220 |
+
$file = $path . DS . $name . '.csv';
|
221 |
+
$io->setAllowCreateFolders(true);
|
222 |
+
$io->open(array('path' => $path));
|
223 |
+
$io->streamOpen($file, 'w+');
|
224 |
+
$io->streamLock(true);
|
225 |
+
|
226 |
+
$headers = $this->_getCatCsvHeaders($ids);
|
227 |
+
$io->streamWriteCsv($headers);
|
228 |
+
foreach ($ids as $id) {
|
229 |
+
|
230 |
+
$cat = Mage::getModel('catalog/category');
|
231 |
+
$cat->load($id);
|
232 |
+
|
233 |
+
$data = $this->_getCsvData($cat->getData(), $headers);
|
234 |
+
|
235 |
+
$io->streamWriteCsv($data);
|
236 |
+
}
|
237 |
+
|
238 |
+
return array(
|
239 |
+
'type' => 'filename',
|
240 |
+
'value' => $file,
|
241 |
+
'rm' => false // can delete file after use
|
242 |
+
);
|
243 |
+
}
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Generates CSV file with attribute list according to the collection in the $this->_attributeList
|
249 |
+
* @return array
|
250 |
+
*/
|
251 |
+
public function generateEaeAttributesList()
|
252 |
+
{
|
253 |
+
|
254 |
+
if (!is_null($this->_attributeList)) {
|
255 |
+
$attributes = $this->_attributeList;
|
256 |
+
if (count($attributes) > 0) {
|
257 |
+
|
258 |
+
$io = new Varien_Io_File();
|
259 |
+
$path = Mage::getBaseDir('var') . DS . 'export' . DS;
|
260 |
+
$name = md5(microtime());
|
261 |
+
$file = $path . DS . $name . '.csv';
|
262 |
+
$io->setAllowCreateFolders(true);
|
263 |
+
$io->open(array('path' => $path));
|
264 |
+
$io->streamOpen($file, 'w+');
|
265 |
+
$io->streamLock(true);
|
266 |
+
|
267 |
+
$io->streamWriteCsv($this->_getAttrCsvHeaders($attributes));
|
268 |
+
foreach ($attributes as $attribute) {
|
269 |
+
$attrdata = $attribute->getData();
|
270 |
+
$io->streamWriteCsv($attrdata);
|
271 |
+
}
|
272 |
+
|
273 |
+
return array(
|
274 |
+
'type' => 'filename',
|
275 |
+
'value' => $file,
|
276 |
+
'rm' => false // can delete file after use
|
277 |
+
);
|
278 |
+
}
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Generates CSV file with category products list according to the collection in the $this->_categoryList
|
284 |
+
* @return array
|
285 |
+
*/
|
286 |
+
public function generateEaeCategoryProductsList()
|
287 |
+
{
|
288 |
+
|
289 |
+
if (!is_null($this->_categoryList)) {
|
290 |
+
$ids = $this->_categoryList;
|
291 |
+
if (count($ids) > 0) {
|
292 |
+
|
293 |
+
$io = new Varien_Io_File();
|
294 |
+
$path = Mage::getBaseDir('var') . DS . 'export' . DS;
|
295 |
+
$name = md5(microtime());
|
296 |
+
$file = $path . DS . $name . '.csv';
|
297 |
+
$io->setAllowCreateFolders(true);
|
298 |
+
$io->open(array('path' => $path));
|
299 |
+
$io->streamOpen($file, 'w+');
|
300 |
+
$io->streamLock(true);
|
301 |
+
|
302 |
+
$headers = array('category_id', 'product_id');
|
303 |
+
$io->streamWriteCsv($headers);
|
304 |
+
foreach ($ids as $id) {
|
305 |
+
|
306 |
+
$cat = Mage::getModel('catalog/category');
|
307 |
+
$cat->load($id);
|
308 |
+
|
309 |
+
$products = Mage::getModel('catalog/product')
|
310 |
+
->getCollection()
|
311 |
+
->addCategoryFilter($cat)
|
312 |
+
->load();
|
313 |
+
|
314 |
+
if (!is_null($products)) {
|
315 |
+
foreach ($products as $product) {
|
316 |
+
$catProduct = array();
|
317 |
+
|
318 |
+
$catProduct['category_id'] = $cat->getEntityId();
|
319 |
+
|
320 |
+
$proddata = $product->getData();
|
321 |
+
$catProduct['product_id'] = $proddata['entity_id'];
|
322 |
+
|
323 |
+
$data = $this->_getCsvData($catProduct, $headers);
|
324 |
+
$io->streamWriteCsv($data);
|
325 |
+
}
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
return array(
|
330 |
+
'type' => 'filename',
|
331 |
+
'value' => $file,
|
332 |
+
'rm' => false // can delete file after use
|
333 |
+
);
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
|
338 |
+
}
|
app/code/local/EasyAsk/Search/Helper/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Model/Adminhtml/System/Config/Backend/Engine.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento Enterprise Edition
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Magento Enterprise Edition License
|
8 |
+
* that is bundled with this package in the file LICENSE_EE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.magentocommerce.com/license/enterprise-edition
|
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 Enterprise
|
22 |
+
* @package Enterprise_Search
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://www.magentocommerce.com/license/enterprise-edition
|
25 |
+
*/
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Catalog search backend model
|
30 |
+
*
|
31 |
+
* @category Enterprise
|
32 |
+
* @package Enterprise_Search
|
33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
+
*/
|
35 |
+
class EasyAsk_Search_Model_Adminhtml_System_Config_Backend_Engine extends Mage_Core_Model_Config_Data
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* After save call
|
39 |
+
* Invalidate catalog search index if engine was changed
|
40 |
+
*
|
41 |
+
* @return Enterprise_Search_Model_Adminhtml_System_Config_Backend_Engine
|
42 |
+
*/
|
43 |
+
protected function _afterSave()
|
44 |
+
{
|
45 |
+
parent::_afterSave();
|
46 |
+
|
47 |
+
if ($this->isValueChanged()) {
|
48 |
+
Mage::getSingleton('index/indexer')->getProcessByCode('catalogsearch_fulltext')
|
49 |
+
->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX);
|
50 |
+
}
|
51 |
+
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
}
|
app/code/local/EasyAsk/Search/Model/Adminhtml/System/Config/Backend/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Model/Adminhtml/System/Config/Source/Engine.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento Enterprise Edition
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Magento Enterprise Edition License
|
8 |
+
* that is bundled with this package in the file LICENSE_EE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.magentocommerce.com/license/enterprise-edition
|
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 Enterprise
|
22 |
+
* @package Enterprise_Search
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://www.magentocommerce.com/license/enterprise-edition
|
25 |
+
*/
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Catalog search types
|
30 |
+
*
|
31 |
+
* @category Enterprise
|
32 |
+
* @package Enterprise_Search
|
33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
+
*/
|
35 |
+
class EasyAsk_Search_Model_Adminhtml_System_Config_Source_Engine
|
36 |
+
{
|
37 |
+
public function toOptionArray()
|
38 |
+
{
|
39 |
+
$engines = array(
|
40 |
+
'catalogsearch/fulltext_engine' => Mage::helper('easyask_search')->__('MySql Fulltext'),
|
41 |
+
'easyask_search/engine' => Mage::helper('easyask_search')->__('EasyAsk')
|
42 |
+
);
|
43 |
+
$options = array();
|
44 |
+
foreach ($engines as $k => $v) {
|
45 |
+
$options[] = array(
|
46 |
+
'value' => $k,
|
47 |
+
'label' => $v
|
48 |
+
);
|
49 |
+
}
|
50 |
+
return $options;
|
51 |
+
}
|
52 |
+
}
|
app/code/local/EasyAsk/Search/Model/Adminhtml/System/Config/Source/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Model/Catalog/Layer.php
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Model_Catalog_Layer extends Mage_Catalog_Model_Layer {
|
3 |
+
|
4 |
+
public function getFilterableAttributes()
|
5 |
+
{
|
6 |
+
|
7 |
+
$res = Mage::registry('ea_result');
|
8 |
+
if ($res != null){
|
9 |
+
|
10 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
11 |
+
$eapath = $searchPath[count($searchPath) - 1]->getPath();
|
12 |
+
|
13 |
+
$originalAttributes = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked() . '_original'));
|
14 |
+
|
15 |
+
if (!$originalAttributes){ // In rare cases we may get a search result without a question. This may happen when the user
|
16 |
+
//selects a category from SAYT. In this case the original Attributes are from the cache for the category selected
|
17 |
+
$eapathseo = $searchPath[count($searchPath) - 1]->getSEOPath();
|
18 |
+
|
19 |
+
$eapathseoarr = explode('/', $eapathseo);
|
20 |
+
|
21 |
+
$catPath = '';
|
22 |
+
foreach ($eapathseoarr as $eapathseo1) {
|
23 |
+
if (!(strpos($eapathseo1, '-', 0) === 0) && !(strpos($eapathseo1, ':') > 0)){
|
24 |
+
$catPath = strlen($catPath) > 0 ? $catPath . '-'. $eapathseo1 : $eapathseo1;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
if (strlen($catPath) > 0){
|
29 |
+
$originalAttributes = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked() . '-'.$catPath));
|
30 |
+
} else {
|
31 |
+
$originalAttributes = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked()));
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
$collection = null;
|
36 |
+
|
37 |
+
$currentAttribute = '';
|
38 |
+
$eapatharr = explode('////', $eapath);
|
39 |
+
if (strpos($eapatharr[count($eapatharr) - 1], 'AttribSelect') !== false){
|
40 |
+
$currentAttributePath = substr($eapatharr[count($eapatharr) - 1], 13);
|
41 |
+
$currentAttribute = substr($currentAttributePath, 0, strpos($currentAttributePath, '='));
|
42 |
+
}
|
43 |
+
|
44 |
+
// $currentAttribute = substr($eapatharr[count($eapatharr) - 1], 0, strpos($eapatharr[count($eapatharr) - 1], ':'));
|
45 |
+
|
46 |
+
$originalAttribNames = array();
|
47 |
+
if ($originalAttributes){
|
48 |
+
$originalAttribNames = array_keys($originalAttributes);
|
49 |
+
}
|
50 |
+
|
51 |
+
if (Mage::getStoreConfig('catalog/layered_navigation/ea_multiselect') == 1){
|
52 |
+
$commonAttribs = $res->getCommonAttributeNames(true);
|
53 |
+
foreach ($commonAttribs as $commonAttrib){
|
54 |
+
if (($commonAttrib == $currentAttribute) ){
|
55 |
+
$collection[]= $commonAttrib;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
$attribs = $res->getAttributeNamesFull();
|
61 |
+
foreach ($attribs as $attrib){
|
62 |
+
// if (in_array($attrib, $originalAttribNames)){
|
63 |
+
$collection[] = $attrib;
|
64 |
+
// }
|
65 |
+
}
|
66 |
+
|
67 |
+
$isDispLimited = $res->isInitialDispLimitedForAttrNames();
|
68 |
+
$attribCollection = array();
|
69 |
+
if ($collection){
|
70 |
+
if ($isDispLimited){
|
71 |
+
$initialdisparray = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked() . '_initial'));
|
72 |
+
// If the initial display is limited then expand the number of attributes specified
|
73 |
+
if (!$initialdisparray){
|
74 |
+
$initialdisparray = $res->getInitialDisplayList(1);
|
75 |
+
}
|
76 |
+
foreach ($collection as $item){
|
77 |
+
$initDispLimited = $res->getInitialDispLimitForAttrValues($item) > 0 ? $res->getInitialDispLimitForAttrValues($item) : ($originalAttributes[$item][0]['id'] > 0 ? $originalAttributes[$item][0]['id'] : 0);
|
78 |
+
if (in_array($item, $initialdisparray)){
|
79 |
+
$attrib = array(
|
80 |
+
'name' => $item,
|
81 |
+
'expand' => true,
|
82 |
+
'dispLimited' => $initDispLimited,
|
83 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
84 |
+
);
|
85 |
+
}else{
|
86 |
+
$attrib = array(
|
87 |
+
'name' => $item,
|
88 |
+
'expand' => false,
|
89 |
+
'dispLimited' => $initDispLimited,
|
90 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
91 |
+
);
|
92 |
+
}
|
93 |
+
$attribCollection[] = $attrib;
|
94 |
+
}
|
95 |
+
|
96 |
+
}else{
|
97 |
+
// If the initial display is not limited then by default expand the first 3 attributes
|
98 |
+
$i = 0;
|
99 |
+
|
100 |
+
foreach ($collection as $item){
|
101 |
+
$initDispLimited = $res->getInitialDispLimitForAttrValues($item) > 0 ? $res->getInitialDispLimitForAttrValues($item) : (in_array($item, $originalAttribNames) ? $originalAttributes[$item][0]['id'] : 0);
|
102 |
+
if ($i < 3){
|
103 |
+
$attrib = array(
|
104 |
+
'name' => $item,
|
105 |
+
'expand' => true,
|
106 |
+
'dispLimited' => $initDispLimited,
|
107 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
108 |
+
);
|
109 |
+
} else {
|
110 |
+
$attrib = array(
|
111 |
+
'name' => $item,
|
112 |
+
'expand' => false,
|
113 |
+
'dispLimited' => $initDispLimited,
|
114 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
115 |
+
);
|
116 |
+
|
117 |
+
}
|
118 |
+
$i++;
|
119 |
+
$attribCollection[] = $attrib;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
return $attribCollection;
|
124 |
+
}
|
125 |
+
|
126 |
+
return parent::getFilterableAttributes();
|
127 |
+
}
|
128 |
+
|
129 |
+
public function getStateAttributes()
|
130 |
+
{
|
131 |
+
|
132 |
+
$res = Mage::registry('ea_result');
|
133 |
+
if ($res != null){
|
134 |
+
|
135 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
136 |
+
$eapath = $searchPath[count($searchPath) - 1]->getPath();
|
137 |
+
|
138 |
+
$eapatharr = explode('////', $eapath);
|
139 |
+
$attrarray = array();
|
140 |
+
foreach ($eapatharr as $attrpath){
|
141 |
+
if (strpos($attrpath, 'AttribSelect') !== false){
|
142 |
+
$attribsel = substr($attrpath, 13);
|
143 |
+
$attrarray[] = $attribsel;//substr($attribsel, 0, strpos($attribsel, '='));
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
return $attrarray;
|
148 |
+
} else {
|
149 |
+
return parent::getStateAttributes();
|
150 |
+
}
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
/* public function getProductCollection()
|
155 |
+
{
|
156 |
+
$res = Mage::registry('ea_result');
|
157 |
+
if ($res != null){
|
158 |
+
$eaCollection = $this->_loadDBCollection($res);
|
159 |
+
$eaCollection->load();
|
160 |
+
return $eaCollection;
|
161 |
+
} else {
|
162 |
+
return parent::getProductCollection();
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
public function prepareProductCollection($collection, $res)
|
167 |
+
{
|
168 |
+
$collection
|
169 |
+
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
170 |
+
->setStore(Mage::app()->getStore())
|
171 |
+
->setPageSize($res->getResultsPerPage())
|
172 |
+
// ->setCurPage($res->getCurrentPage())
|
173 |
+
->addMinimalPrice()
|
174 |
+
->addFinalPrice()
|
175 |
+
->addTaxPercents()
|
176 |
+
->addStoreFilter()
|
177 |
+
->addUrlRewrite();
|
178 |
+
|
179 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
|
180 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
|
181 |
+
|
182 |
+
return $this;
|
183 |
+
}
|
184 |
+
|
185 |
+
protected function _loadDBCollection($res)
|
186 |
+
{
|
187 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
188 |
+
if ($res->getFirstItem() != -1) {
|
189 |
+
$productIds = array();
|
190 |
+
$last = $res->getLastItem();
|
191 |
+
for ($i = $res->getFirstItem() - 1; $i < $last; $i++) {
|
192 |
+
$productIds[] = (int) $res->getCellData($i, $res->getColumnIndex('Product Id'));
|
193 |
+
}
|
194 |
+
$collection->addAttributeToFilter('entity_id', array('in' => $productIds));
|
195 |
+
$this->prepareProductCollection($collection, $res);
|
196 |
+
}
|
197 |
+
return $collection;
|
198 |
+
}*/
|
199 |
+
}
|
app/code/local/EasyAsk/Search/Model/Catalog/Layer.php.bak
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Model_Catalog_Layer extends Mage_Catalog_Model_Layer {
|
3 |
+
|
4 |
+
public function getFilterableAttributes()
|
5 |
+
{
|
6 |
+
|
7 |
+
$res = Mage::registry('ea_result');
|
8 |
+
if ($res != null){
|
9 |
+
|
10 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
11 |
+
$eapath = $searchPath[count($searchPath) - 1]->getPath();
|
12 |
+
|
13 |
+
$originalAttributes = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked() . '_original'));
|
14 |
+
|
15 |
+
if (!$originalAttributes){ // In rare cases we may get a search result without a question. This may happen when the user
|
16 |
+
//selects a category from SAYT. In this case the original Attributes are from the cache for the category selected
|
17 |
+
$eapathseo = $searchPath[count($searchPath) - 1]->getSEOPath();
|
18 |
+
|
19 |
+
$eapathseoarr = explode('/', $eapathseo);
|
20 |
+
|
21 |
+
$catPath = '';
|
22 |
+
foreach ($eapathseoarr as $eapathseo1) {
|
23 |
+
if (!(strpos($eapathseo1, '-', 0) === 0) && !(strpos($eapathseo1, ':') > 0)){
|
24 |
+
$catPath = strlen($catPath) > 0 ? $catPath . '-'. $eapathseo1 : $eapathseo1;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
if (strlen($catPath) > 0){
|
29 |
+
$originalAttributes = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked() . '-'.$catPath));
|
30 |
+
} else {
|
31 |
+
$originalAttributes = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked()));
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
$collection = null;
|
36 |
+
|
37 |
+
$currentAttribute = '';
|
38 |
+
$eapatharr = explode('////', $eapath);
|
39 |
+
if (strpos($eapatharr[count($eapatharr) - 1], 'AttribSelect') !== false){
|
40 |
+
$currentAttributePath = substr($eapatharr[count($eapatharr) - 1], 13);
|
41 |
+
$currentAttribute = substr($currentAttributePath, 0, strpos($currentAttributePath, '='));
|
42 |
+
}
|
43 |
+
|
44 |
+
// $currentAttribute = substr($eapatharr[count($eapatharr) - 1], 0, strpos($eapatharr[count($eapatharr) - 1], ':'));
|
45 |
+
|
46 |
+
$originalAttribNames = array();
|
47 |
+
if ($originalAttributes){
|
48 |
+
$originalAttribNames = array_keys($originalAttributes);
|
49 |
+
}
|
50 |
+
|
51 |
+
if (Mage::getStoreConfig('catalog/layered_navigation/ea_multiselect') == 1){
|
52 |
+
$commonAttribs = $res->getCommonAttributeNames(true);
|
53 |
+
foreach ($commonAttribs as $commonAttrib){
|
54 |
+
if (($commonAttrib == $currentAttribute) ){
|
55 |
+
$collection[]= $commonAttrib;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
$attribs = $res->getAttributeNamesFull();
|
61 |
+
foreach ($attribs as $attrib){
|
62 |
+
// if (in_array($attrib, $originalAttribNames)){
|
63 |
+
$collection[] = $attrib;
|
64 |
+
// }
|
65 |
+
}
|
66 |
+
|
67 |
+
$isDispLimited = $res->isInitialDispLimitedForAttrNames();
|
68 |
+
$attribCollection = array();
|
69 |
+
if ($collection){
|
70 |
+
if ($isDispLimited){
|
71 |
+
$initialdisparray = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked() . '_initial'));
|
72 |
+
// If the initial display is limited then expand the number of attributes specified
|
73 |
+
if (!$initialdisparray){
|
74 |
+
$initialdisparray = $res->getInitialDisplayList(1);
|
75 |
+
}
|
76 |
+
foreach ($collection as $item){
|
77 |
+
$initDispLimited = $res->getInitialDispLimitForAttrValues($item) > 0 ? $res->getInitialDispLimitForAttrValues($item) : ($originalAttributes[$item][0]['id'] > 0 ? $originalAttributes[$item][0]['id'] : 0);
|
78 |
+
if (in_array($item, $initialdisparray)){
|
79 |
+
$attrib = array(
|
80 |
+
'name' => $item,
|
81 |
+
'expand' => true,
|
82 |
+
'dispLimited' => $initDispLimited,
|
83 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
84 |
+
);
|
85 |
+
}else{
|
86 |
+
$attrib = array(
|
87 |
+
'name' => $item,
|
88 |
+
'expand' => false,
|
89 |
+
'dispLimited' => $initDispLimited,
|
90 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
91 |
+
);
|
92 |
+
}
|
93 |
+
$attribCollection[] = $attrib;
|
94 |
+
}
|
95 |
+
|
96 |
+
}else{
|
97 |
+
// If the initial display is not limited then by default expand the first 3 attributes
|
98 |
+
$i = 0;
|
99 |
+
|
100 |
+
foreach ($collection as $item){
|
101 |
+
$initDispLimited = $res->getInitialDispLimitForAttrValues($item) > 0 ? $res->getInitialDispLimitForAttrValues($item) : (in_array($item, $originalAttribNames) ? $originalAttributes[$item][0]['id'] : 0);
|
102 |
+
if ($i < 3){
|
103 |
+
$attrib = array(
|
104 |
+
'name' => $item,
|
105 |
+
'expand' => true,
|
106 |
+
'dispLimited' => $initDispLimited,
|
107 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
108 |
+
);
|
109 |
+
} else {
|
110 |
+
$attrib = array(
|
111 |
+
'name' => $item,
|
112 |
+
'expand' => false,
|
113 |
+
'dispLimited' => $initDispLimited,
|
114 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
115 |
+
);
|
116 |
+
|
117 |
+
}
|
118 |
+
$i++;
|
119 |
+
$attribCollection[] = $attrib;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
return $attribCollection;
|
124 |
+
}
|
125 |
+
|
126 |
+
return parent::getFilterableAttributes();
|
127 |
+
}
|
128 |
+
|
129 |
+
public function getStateAttributes()
|
130 |
+
{
|
131 |
+
|
132 |
+
$res = Mage::registry('ea_result');
|
133 |
+
if ($res != null){
|
134 |
+
|
135 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
136 |
+
$eapath = $searchPath[count($searchPath) - 1]->getPath();
|
137 |
+
|
138 |
+
$eapatharr = explode('////', $eapath);
|
139 |
+
$attrarray = array();
|
140 |
+
foreach ($eapatharr as $attrpath){
|
141 |
+
if (strpos($attrpath, 'AttribSelect') !== false){
|
142 |
+
$attribsel = substr($attrpath, 13);
|
143 |
+
$attrarray[] = $attribsel;//substr($attribsel, 0, strpos($attribsel, '='));
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
return $attrarray;
|
148 |
+
}
|
149 |
+
|
150 |
+
}
|
151 |
+
|
152 |
+
}
|
app/code/local/EasyAsk/Search/Model/Catalog/Layer/Filter/Attribute.php
ADDED
@@ -0,0 +1,416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EasyAsk_Search_Model_Catalog_Layer_Filter_Attribute extends Mage_Catalog_Model_Layer_Filter_Attribute
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Initialize filter items
|
8 |
+
*
|
9 |
+
* @return Mage_Catalog_Model_Layer_Filter_Abstract
|
10 |
+
*/
|
11 |
+
protected function _initItems()
|
12 |
+
{
|
13 |
+
$res = Mage::registry('ea_result');
|
14 |
+
if ($res != null){
|
15 |
+
$data = $this->_getItemsData();
|
16 |
+
$items=array();
|
17 |
+
if ($data != null){
|
18 |
+
foreach ($data as $itemData) {
|
19 |
+
$items[] = $this->_createItem(
|
20 |
+
$itemData['label'],
|
21 |
+
$itemData['value'],
|
22 |
+
$itemData['count'],
|
23 |
+
isset($itemData['ea_path'])?$itemData['ea_path']:'',
|
24 |
+
isset($itemData['ea_c'])?$itemData['ea_c']:'',
|
25 |
+
isset($itemData['ea_a'])?$itemData['ea_a']:'',
|
26 |
+
isset($itemData['ea_bc'])?$itemData['ea_bc']:'',
|
27 |
+
isset($itemData['isDisabled'])?$itemData['isDisabled']:'',
|
28 |
+
isset($itemData['isChecked'])?$itemData['isChecked']:'',
|
29 |
+
isset($itemData['minValue'])?$itemData['minValue']:'',
|
30 |
+
isset($itemData['maxValue'])?$itemData['maxValue']:'',
|
31 |
+
isset($itemData['minRangeValue'])?$itemData['minRangeValue']:'',
|
32 |
+
isset($itemData['maxRangeValue'])?$itemData['maxRangeValue']:'',
|
33 |
+
isset($itemData['rangeRound'])?$itemData['rangeRound']:'',
|
34 |
+
isset($itemData['ea_seoAttr'])?$itemData['ea_seoAttr']:'',
|
35 |
+
isset($itemData['imageURL'])?$itemData['imageURL']:''
|
36 |
+
);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
$this->_items = $items;
|
40 |
+
return $this;
|
41 |
+
} else {
|
42 |
+
return parent::_initItems();
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Create filter item object
|
49 |
+
*
|
50 |
+
* @param string $label
|
51 |
+
* @param mixed $value
|
52 |
+
* @param int $count
|
53 |
+
* @return Mage_Catalog_Model_Layer_Filter_Item
|
54 |
+
*/
|
55 |
+
protected function _createItem($label, $value, $count=0, $eapath='', $eacat='', $eaattrib='', $eabc='', $isDisabled='', $isChecked=false,
|
56 |
+
$minValue='', $maxValue='', $minRangeValue='', $maxRangeValue='', $rangeRound='', $eaSeoAttr='', $imageURL='')
|
57 |
+
{
|
58 |
+
$res = Mage::registry('ea_result');
|
59 |
+
if ($res != null){
|
60 |
+
return Mage::getModel('catalog/layer_filter_item')
|
61 |
+
->setFilter($this)
|
62 |
+
->setLabel($label)
|
63 |
+
->setValue($value)
|
64 |
+
->setCount($count)
|
65 |
+
->setEapath($eapath)
|
66 |
+
->setEacat($eacat)
|
67 |
+
->setEaattrib($eaattrib)
|
68 |
+
->setEabc($eabc)
|
69 |
+
->setIsDisabled($isDisabled)
|
70 |
+
->setIsChecked($isChecked)
|
71 |
+
->setMinValue($minValue)
|
72 |
+
->setMaxValue($maxValue)
|
73 |
+
->setMinRangeValue($minRangeValue)
|
74 |
+
->setMaxRangeValue($maxRangeValue)
|
75 |
+
->setRangeRound($rangeRound)
|
76 |
+
->setEaSeoAttr($eaSeoAttr)
|
77 |
+
->setImageURL($imageURL);
|
78 |
+
} else {
|
79 |
+
return parent::_createItem($label, $value, $count);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Set attribute model to filter
|
85 |
+
*
|
86 |
+
* @param Mage_Eav_Model_Entity_Attribute $attribute
|
87 |
+
* @return Mage_Catalog_Model_Layer_Filter_Abstract
|
88 |
+
*/
|
89 |
+
public function setAttributeModel($attribute)
|
90 |
+
{
|
91 |
+
$res = Mage::registry('ea_result');
|
92 |
+
if ($res != null){
|
93 |
+
$this->setRequestVar($attribute);
|
94 |
+
$this->setData('attribute_model', $attribute);
|
95 |
+
return $this;
|
96 |
+
} else {
|
97 |
+
return parent::setAttributeModel($attribute);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Get filter text label
|
103 |
+
*
|
104 |
+
* @return string
|
105 |
+
*/
|
106 |
+
public function getName()
|
107 |
+
{
|
108 |
+
$res = Mage::registry('ea_result');
|
109 |
+
if ($res != null){
|
110 |
+
return strpos($this->getAttributeModel(), '=') > 0 ? substr($this->getAttributeModel(), 0, strpos($this->getAttributeModel(), '=')) : $this->getAttributeModel();
|
111 |
+
} else {
|
112 |
+
return $this->getAttributeModel()->getStoreLabel();
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Retrieve Attribute code
|
118 |
+
*
|
119 |
+
* @return int
|
120 |
+
*/
|
121 |
+
public function getAttributeCode()
|
122 |
+
{
|
123 |
+
$attributeCode = $this->_getData('attribute_code');
|
124 |
+
return $attributeCode;
|
125 |
+
}
|
126 |
+
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Set Attribute code
|
130 |
+
*
|
131 |
+
* @param int $attributeCode
|
132 |
+
* @return Mage_Catalog_Model_Layer_Filter_Abstract
|
133 |
+
*/
|
134 |
+
public function setAttributeCode($attributeCode)
|
135 |
+
{
|
136 |
+
return $this->setData('attribute_code', $attributeCode);
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Get option text from frontend model by option id
|
141 |
+
*
|
142 |
+
* @param int $optionId
|
143 |
+
* @return unknown
|
144 |
+
*/
|
145 |
+
protected function _getOptionText($optionId)
|
146 |
+
{
|
147 |
+
$res = Mage::registry('ea_result');
|
148 |
+
if ($res != null){
|
149 |
+
return $this->getAttributeModel();
|
150 |
+
} else {
|
151 |
+
return parent::_getOptionText($optionId);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Apply attribute option filter to product collection
|
157 |
+
*
|
158 |
+
* @param Zend_Controller_Request_Abstract $request
|
159 |
+
* @param Varien_Object $filterBlock
|
160 |
+
* @return Mage_Catalog_Model_Layer_Filter_Attribute
|
161 |
+
*/
|
162 |
+
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
|
163 |
+
{
|
164 |
+
$res = Mage::registry('ea_result');
|
165 |
+
if ($res != null){
|
166 |
+
if ($this->getAttributeCode() == '1'){
|
167 |
+
|
168 |
+
$text = $this->_getOptionText(null);
|
169 |
+
|
170 |
+
if ($text) {
|
171 |
+
// $this->_getResource()->applyFilterToCollection($this, $filter);
|
172 |
+
|
173 |
+
//Get the current path and exclude the selected attribute form the path
|
174 |
+
$removepath = '';
|
175 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
176 |
+
$eapathseo = $searchPath[count($searchPath) - 1]->getSEOPath();
|
177 |
+
$eavaluepath = $searchPath[count($searchPath) - 1]->getPath();
|
178 |
+
|
179 |
+
$eapathseoarr = explode('/', $eapathseo);
|
180 |
+
$eavaluepatharr = explode('////', $eavaluepath);
|
181 |
+
for($i = 0; sizeof($eapathseoarr) > $i; $i++){
|
182 |
+
if (strpos($eapathseoarr[$i], ':') > 0){
|
183 |
+
$eavalue = substr($eavaluepatharr[$i + 1], 13);
|
184 |
+
$eapath = $eapathseoarr[$i];
|
185 |
+
if (strcmp($eavalue, $text) == 0){
|
186 |
+
$eapatharrsize = sizeof(explode (';', $eapath));
|
187 |
+
if ($eapatharrsize > 1){ // multi select
|
188 |
+
unset($eapathseoarr[$i]);
|
189 |
+
$removepath = implode('/', $eapathseoarr);
|
190 |
+
$filter = '';
|
191 |
+
for ($j = 0; $eapatharrsize > $j; $j++){
|
192 |
+
$eapatharr = explode (';;;;', $eavalue);
|
193 |
+
$eaval = $eapatharr[$j];
|
194 |
+
if (strpos($eaval, '=') !== false){
|
195 |
+
$filterSub = substr($eaval, strpos($eaval, '=') + 1);
|
196 |
+
}
|
197 |
+
$filter = $filter . '<div>' . str_replace("'", "", $filterSub) . '</div>';
|
198 |
+
}
|
199 |
+
$this->getLayer()->getState()->addFilter($this->_createItem($filter, $filter, 0, '', '', '', $removepath));
|
200 |
+
}else{
|
201 |
+
unset($eapathseoarr[$i]);
|
202 |
+
$removepath = implode('/', $eapathseoarr);
|
203 |
+
// if (strpos($text, '=') !== false){
|
204 |
+
// $filter = substr($text, strpos($text, '=') + 1);
|
205 |
+
// }
|
206 |
+
$filter = $searchPath[$i + 1]->getValue();
|
207 |
+
$this->getLayer()->getState()->addFilter($this->_createItem($filter, $filter, 0, '', '', '', $removepath));
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
$this->_items = array();
|
215 |
+
}
|
216 |
+
}
|
217 |
+
return $this;
|
218 |
+
} else {
|
219 |
+
return parent::apply($request, $filterBlock);
|
220 |
+
}
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Get data array for building attribute filter items
|
226 |
+
*
|
227 |
+
* @return array
|
228 |
+
*/
|
229 |
+
protected function _getItemsData()
|
230 |
+
{
|
231 |
+
$res = Mage::registry('ea_result');
|
232 |
+
|
233 |
+
if ($res != null){
|
234 |
+
$attribute = $this->getAttributeModel();
|
235 |
+
$this->_requestVar = $attribute;
|
236 |
+
|
237 |
+
$key = $this->getLayer()->getStateKey().'_'.$this->_requestVar;
|
238 |
+
$data = $this->getLayer()->getAggregator()->getCacheData($key);
|
239 |
+
|
240 |
+
if ($data === null) {
|
241 |
+
|
242 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
243 |
+
$eapathseo = $searchPath[count($searchPath) - 1]->getSEOPath();
|
244 |
+
|
245 |
+
$eapathseoarr = explode('/', $eapathseo);
|
246 |
+
$currentAttribute = substr($eapathseoarr[count($eapathseoarr) - 1], 0, strpos($eapathseoarr[count($eapathseoarr) - 1], ':'));
|
247 |
+
|
248 |
+
$catPath = $this->getCatPath($res);
|
249 |
+
|
250 |
+
$query = $res->getOriginalQuestionAsked();
|
251 |
+
$allAttributeValues = null;
|
252 |
+
$allAttributes = unserialize(Mage::app()->getCache()->load($catPath));
|
253 |
+
if ($allAttributes){
|
254 |
+
$allAttributeValues = $allAttributes[$attribute];
|
255 |
+
}
|
256 |
+
|
257 |
+
$attributeValues = $res->getDetailedAttributeValuesFull($attribute);
|
258 |
+
$attributeCommonValues = $res->getDetailedCommonAttributeValuesFull($attribute);
|
259 |
+
|
260 |
+
$attributeValues = array_merge($attributeValues, $attributeCommonValues);
|
261 |
+
$attributeValuesKeys = array();
|
262 |
+
foreach ($attributeValues as $attributeValue){
|
263 |
+
$attributeValuesKeys[] = $attributeValue->getNodeString();
|
264 |
+
}
|
265 |
+
|
266 |
+
if ($allAttributeValues){
|
267 |
+
foreach ($allAttributeValues as $allAttributeValue) {
|
268 |
+
$isSelectedValue = false;
|
269 |
+
if (in_array($allAttributeValue['ns'], $attributeValuesKeys)){
|
270 |
+
foreach ($attributeValues as $attributeValue){
|
271 |
+
if (($allAttributeValue['ds'] == $attributeValue->getDisplayName())){
|
272 |
+
$eapathseoarrcopy = $eapathseoarr;
|
273 |
+
for($i = 0; sizeof($eapathseoarrcopy) > $i; $i++){
|
274 |
+
if (strpos($eapathseoarrcopy[$i], ':') > 0){
|
275 |
+
|
276 |
+
$eapath = $eapathseoarrcopy[$i];
|
277 |
+
$eapatharrsize = sizeof(explode (';', $eapath));
|
278 |
+
if ($eapatharrsize > 1){ // multi select
|
279 |
+
for ($j = 0; $eapatharrsize > $j; $j++){
|
280 |
+
$eapatharr = explode (';', $eapath);
|
281 |
+
$eaval = $eapatharr[$j];
|
282 |
+
if ($eaval == $attributeValue->getNodeString()){
|
283 |
+
$isSelectedValue = true;
|
284 |
+
unset($eapatharr[$j]);
|
285 |
+
$eapathseoarrcopy[$i] = implode(';', $eapatharr);
|
286 |
+
$removepath = implode('/', $eapathseoarrcopy);
|
287 |
+
}
|
288 |
+
}
|
289 |
+
}else{
|
290 |
+
if ($eapathseoarrcopy[$i] == $attributeValue->getNodeString()){
|
291 |
+
$isSelectedValue = true;
|
292 |
+
unset($eapathseoarrcopy[$i]);
|
293 |
+
$removepath = implode('/', $eapathseoarrcopy);
|
294 |
+
}
|
295 |
+
}
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
if (!(strpos($allAttributeValue['ns'], $currentAttribute . ':') === false)){
|
300 |
+
$data[] = array(
|
301 |
+
'label' => Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()),
|
302 |
+
'value' => $allAttributeValue['ns'],
|
303 |
+
'count' => $allAttributeValue['pc'],
|
304 |
+
'ea_path' => $eapathseo,
|
305 |
+
'ea_a' => $allAttributeValue['ns'],
|
306 |
+
'ea_bc' => $isSelectedValue ? $removepath : '',
|
307 |
+
'isDisabled' => false,
|
308 |
+
'isChecked' => $isSelectedValue ? true : false,
|
309 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
310 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
311 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
312 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
313 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
314 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
315 |
+
// 'imageURL' => $this->getImageURL($attribute, $attributeValue->getDisplayName())
|
316 |
+
);
|
317 |
+
} else {
|
318 |
+
$data[] = array(
|
319 |
+
'label' => Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()),
|
320 |
+
'value' => $attributeValue->getNodeString(),
|
321 |
+
'count' => $attributeValue->getProductCount(),
|
322 |
+
'ea_path' => $eapathseo,
|
323 |
+
'ea_a' => $attributeValue->getNodeString(),
|
324 |
+
'ea_bc' => $isSelectedValue ? $removepath : '',
|
325 |
+
'isDisabled' => false,
|
326 |
+
'isChecked' => $isSelectedValue ? true : false,
|
327 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
328 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
329 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
330 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
331 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
332 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
333 |
+
// 'imageURL' => $this->getImageURL($attribute, $attributeValue->getDisplayName())
|
334 |
+
);
|
335 |
+
}
|
336 |
+
}
|
337 |
+
}
|
338 |
+
} else {
|
339 |
+
if (!(strpos($allAttributeValue['ns'], $currentAttribute . ':') === false)){
|
340 |
+
$data[] = array(
|
341 |
+
'label' => $attributeValue->getValueType() == 2 ? Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()) : Mage::helper('core')->htmlEscape($allAttributeValue['ds']),
|
342 |
+
'value' => $allAttributeValue['ns'],
|
343 |
+
'count' => $allAttributeValue['pc'],
|
344 |
+
'ea_path' => $eapathseo,
|
345 |
+
'ea_a' => $allAttributeValue['ns'],
|
346 |
+
'isDisabled' => false,
|
347 |
+
'isChecked' => false,
|
348 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
349 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
350 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
351 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
352 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
353 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
354 |
+
// 'imageURL' => $this->getImageURL($attribute, $allAttributeValue['ds'])
|
355 |
+
);
|
356 |
+
}
|
357 |
+
else {
|
358 |
+
$data[] = array(
|
359 |
+
'label' => $attributeValue->getValueType() == 2 ? Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()) : Mage::helper('core')->htmlEscape($allAttributeValue['ds']),
|
360 |
+
'value' => $allAttributeValue['ns'],
|
361 |
+
'count' => $allAttributeValue['pc'],
|
362 |
+
'ea_path' => $eapathseo,
|
363 |
+
'ea_a' => $allAttributeValue['ns'],
|
364 |
+
'isDisabled' => true,
|
365 |
+
'isChecked' => false,
|
366 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
367 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
368 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
369 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
370 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
371 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
372 |
+
// 'imageURL' => $this->getImageURL($attribute, $allAttributeValue['ds'])
|
373 |
+
);
|
374 |
+
}
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
$tags = array(
|
380 |
+
Mage_Eav_Model_Entity_Attribute::CACHE_TAG.':'.$attribute
|
381 |
+
);
|
382 |
+
|
383 |
+
$tags = $this->getLayer()->getStateTags($tags);
|
384 |
+
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
|
385 |
+
}
|
386 |
+
return $data;
|
387 |
+
} else {
|
388 |
+
return parent::_getItemsData();
|
389 |
+
}
|
390 |
+
|
391 |
+
}
|
392 |
+
|
393 |
+
private function getImageURL($attType, $attVal){
|
394 |
+
$imageURL = Mage::getBaseDir('media'). '/catalog/images/' . urlencode(strtolower($attType)) . '/' . urlencode(strtolower($attVal)) . '.jpg';
|
395 |
+
if ((bool)@getimagesize($imageURL) === true){
|
396 |
+
return $imageURL;
|
397 |
+
} else {
|
398 |
+
return "";
|
399 |
+
}
|
400 |
+
}
|
401 |
+
|
402 |
+
private function getCatPath($res){
|
403 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
404 |
+
$eapath = $searchPath[count($searchPath) - 1]->getPath();
|
405 |
+
|
406 |
+
$eapatharr = explode('////', $eapath);
|
407 |
+
$catPath = '';
|
408 |
+
foreach ($eapatharr as $eapath1) {
|
409 |
+
if (!(strpos($eapath1, 'AttribSelect', 0) === 0) && !(strpos($eapath1, '=') > 0)){
|
410 |
+
$catPath = strlen($catPath) > 0 ? $catPath . '-'. $eapath1 : $eapath1;
|
411 |
+
}
|
412 |
+
}
|
413 |
+
return $catPath;
|
414 |
+
}
|
415 |
+
|
416 |
+
}
|
app/code/local/EasyAsk/Search/Model/Catalog/Layer/Filter/Attribute.php.bak
ADDED
@@ -0,0 +1,417 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EasyAsk_Search_Model_Catalog_Layer_Filter_Attribute extends Mage_Catalog_Model_Layer_Filter_Attribute
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Initialize filter items
|
8 |
+
*
|
9 |
+
* @return Mage_Catalog_Model_Layer_Filter_Abstract
|
10 |
+
*/
|
11 |
+
protected function _initItems()
|
12 |
+
{
|
13 |
+
$res = Mage::registry('ea_result');
|
14 |
+
if ($res != null){
|
15 |
+
$data = $this->_getItemsData();
|
16 |
+
$items=array();
|
17 |
+
if ($data != null){
|
18 |
+
foreach ($data as $itemData) {
|
19 |
+
$items[] = $this->_createItem(
|
20 |
+
$itemData['label'],
|
21 |
+
$itemData['value'],
|
22 |
+
$itemData['count'],
|
23 |
+
isset($itemData['ea_path'])?$itemData['ea_path']:'',
|
24 |
+
isset($itemData['ea_c'])?$itemData['ea_c']:'',
|
25 |
+
isset($itemData['ea_a'])?$itemData['ea_a']:'',
|
26 |
+
isset($itemData['ea_bc'])?$itemData['ea_bc']:'',
|
27 |
+
isset($itemData['isDisabled'])?$itemData['isDisabled']:'',
|
28 |
+
isset($itemData['isChecked'])?$itemData['isChecked']:'',
|
29 |
+
isset($itemData['minValue'])?$itemData['minValue']:'',
|
30 |
+
isset($itemData['maxValue'])?$itemData['maxValue']:'',
|
31 |
+
isset($itemData['minRangeValue'])?$itemData['minRangeValue']:'',
|
32 |
+
isset($itemData['maxRangeValue'])?$itemData['maxRangeValue']:'',
|
33 |
+
isset($itemData['rangeRound'])?$itemData['rangeRound']:'',
|
34 |
+
isset($itemData['ea_seoAttr'])?$itemData['ea_seoAttr']:'',
|
35 |
+
isset($itemData['imageURL'])?$itemData['imageURL']:''
|
36 |
+
);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
$this->_items = $items;
|
40 |
+
return $this;
|
41 |
+
} else {
|
42 |
+
return parent::_initItems();
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Create filter item object
|
49 |
+
*
|
50 |
+
* @param string $label
|
51 |
+
* @param mixed $value
|
52 |
+
* @param int $count
|
53 |
+
* @return Mage_Catalog_Model_Layer_Filter_Item
|
54 |
+
*/
|
55 |
+
protected function _createItem($label, $value, $count=0, $eapath='', $eacat='', $eaattrib='', $eabc='', $isDisabled='', $isChecked=false,
|
56 |
+
$minValue='', $maxValue='', $minRangeValue='', $maxRangeValue='', $rangeRound='', $eaSeoAttr='', $imageURL='')
|
57 |
+
{
|
58 |
+
$res = Mage::registry('ea_result');
|
59 |
+
if ($res != null){
|
60 |
+
return Mage::getModel('catalog/layer_filter_item')
|
61 |
+
->setFilter($this)
|
62 |
+
->setLabel($label)
|
63 |
+
->setValue($value)
|
64 |
+
->setCount($count)
|
65 |
+
->setEapath($eapath)
|
66 |
+
->setEacat($eacat)
|
67 |
+
->setEaattrib($eaattrib)
|
68 |
+
->setEabc($eabc)
|
69 |
+
->setIsDisabled($isDisabled)
|
70 |
+
->setIsChecked($isChecked)
|
71 |
+
->setMinValue($minValue)
|
72 |
+
->setMaxValue($maxValue)
|
73 |
+
->setMinRangeValue($minRangeValue)
|
74 |
+
->setMaxRangeValue($maxRangeValue)
|
75 |
+
->setRangeRound($rangeRound)
|
76 |
+
->setEaSeoAttr($eaSeoAttr)
|
77 |
+
->setImageURL($imageURL);
|
78 |
+
} else {
|
79 |
+
return parent::_createItem($label, $value, $count);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Set attribute model to filter
|
85 |
+
*
|
86 |
+
* @param Mage_Eav_Model_Entity_Attribute $attribute
|
87 |
+
* @return Mage_Catalog_Model_Layer_Filter_Abstract
|
88 |
+
*/
|
89 |
+
public function setAttributeModel($attribute)
|
90 |
+
{
|
91 |
+
$res = Mage::registry('ea_result');
|
92 |
+
if ($res != null){
|
93 |
+
$this->setRequestVar($attribute);
|
94 |
+
$this->setData('attribute_model', $attribute);
|
95 |
+
return $this;
|
96 |
+
} else {
|
97 |
+
return parent::setAttributeModel($attribute);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Get filter text label
|
103 |
+
*
|
104 |
+
* @return string
|
105 |
+
*/
|
106 |
+
public function getName()
|
107 |
+
{
|
108 |
+
$res = Mage::registry('ea_result');
|
109 |
+
if ($res != null){
|
110 |
+
return strpos($this->getAttributeModel(), '=') > 0 ? substr($this->getAttributeModel(), 0, strpos($this->getAttributeModel(), '=')) : $this->getAttributeModel();
|
111 |
+
} else {
|
112 |
+
return $this->getAttributeModel()->getStoreLabel();
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Retrieve Attribute code
|
118 |
+
*
|
119 |
+
* @return int
|
120 |
+
*/
|
121 |
+
public function getAttributeCode()
|
122 |
+
{
|
123 |
+
$attributeCode = $this->_getData('attribute_code');
|
124 |
+
return $attributeCode;
|
125 |
+
}
|
126 |
+
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Set Attribute code
|
130 |
+
*
|
131 |
+
* @param int $attributeCode
|
132 |
+
* @return Mage_Catalog_Model_Layer_Filter_Abstract
|
133 |
+
*/
|
134 |
+
public function setAttributeCode($attributeCode)
|
135 |
+
{
|
136 |
+
return $this->setData('attribute_code', $attributeCode);
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Get option text from frontend model by option id
|
141 |
+
*
|
142 |
+
* @param int $optionId
|
143 |
+
* @return unknown
|
144 |
+
*/
|
145 |
+
protected function _getOptionText($optionId)
|
146 |
+
{
|
147 |
+
$res = Mage::registry('ea_result');
|
148 |
+
if ($res != null){
|
149 |
+
return $this->getAttributeModel();
|
150 |
+
} else {
|
151 |
+
return parent::_getOptionText($optionId);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Apply attribute option filter to product collection
|
157 |
+
*
|
158 |
+
* @param Zend_Controller_Request_Abstract $request
|
159 |
+
* @param Varien_Object $filterBlock
|
160 |
+
* @return Mage_Catalog_Model_Layer_Filter_Attribute
|
161 |
+
*/
|
162 |
+
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
|
163 |
+
{
|
164 |
+
$res = Mage::registry('ea_result');
|
165 |
+
if ($res != null){
|
166 |
+
if ($this->getAttributeCode() == '1'){
|
167 |
+
|
168 |
+
$text = $this->_getOptionText(null);
|
169 |
+
|
170 |
+
if ($text) {
|
171 |
+
// $this->_getResource()->applyFilterToCollection($this, $filter);
|
172 |
+
|
173 |
+
//Get the current path and exclude the selected attribute form the path
|
174 |
+
$removepath = '';
|
175 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
176 |
+
$eapathseo = $searchPath[count($searchPath) - 1]->getSEOPath();
|
177 |
+
$eavaluepath = $searchPath[count($searchPath) - 1]->getPath();
|
178 |
+
|
179 |
+
$eapathseoarr = explode('/', $eapathseo);
|
180 |
+
$eavaluepatharr = explode('////', $eavaluepath);
|
181 |
+
for($i = 0; sizeof($eapathseoarr) > $i; $i++){
|
182 |
+
if (strpos($eapathseoarr[$i], ':') > 0){
|
183 |
+
$eavalue = substr($eavaluepatharr[$i + 1], 13);
|
184 |
+
$eapath = $eapathseoarr[$i];
|
185 |
+
if (strcmp($eavalue, $text) == 0){
|
186 |
+
$eapatharrsize = sizeof(explode (';', $eapath));
|
187 |
+
if ($eapatharrsize > 1){ // multi select
|
188 |
+
unset($eapathseoarr[$i]);
|
189 |
+
$removepath = implode('/', $eapathseoarr);
|
190 |
+
$filter = '';
|
191 |
+
for ($j = 0; $eapatharrsize > $j; $j++){
|
192 |
+
$eapatharr = explode (';;;;', $eavalue);
|
193 |
+
$eaval = $eapatharr[$j];
|
194 |
+
if (strpos($eaval, '=') !== false){
|
195 |
+
$filterSub = substr($eaval, strpos($eaval, '=') + 1);
|
196 |
+
}
|
197 |
+
$filter = $filter . '<div>' . str_replace("'", "", $filterSub) . '</div>';
|
198 |
+
}
|
199 |
+
$this->getLayer()->getState()->addFilter($this->_createItem($filter, $filter, 0, '', '', '', $removepath));
|
200 |
+
}else{
|
201 |
+
unset($eapathseoarr[$i]);
|
202 |
+
$removepath = implode('/', $eapathseoarr);
|
203 |
+
// if (strpos($text, '=') !== false){
|
204 |
+
// $filter = substr($text, strpos($text, '=') + 1);
|
205 |
+
// }
|
206 |
+
$filter = $searchPath[$i + 1]->getValue();
|
207 |
+
$this->getLayer()->getState()->addFilter($this->_createItem($filter, $filter, 0, '', '', '', $removepath));
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
$this->_items = array();
|
215 |
+
}
|
216 |
+
}
|
217 |
+
return $this;
|
218 |
+
} else {
|
219 |
+
return parent::apply($request, $filterBlock);
|
220 |
+
}
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Get data array for building attribute filter items
|
226 |
+
*
|
227 |
+
* @return array
|
228 |
+
*/
|
229 |
+
protected function _getItemsData()
|
230 |
+
{
|
231 |
+
$res = Mage::registry('ea_result');
|
232 |
+
|
233 |
+
if ($res != null){
|
234 |
+
$attribute = $this->getAttributeModel();
|
235 |
+
echo "attribute is $attribute";
|
236 |
+
$this->_requestVar = $attribute;
|
237 |
+
|
238 |
+
$key = $this->getLayer()->getStateKey().'_'.$this->_requestVar;
|
239 |
+
$data = $this->getLayer()->getAggregator()->getCacheData($key);
|
240 |
+
|
241 |
+
if ($data === null) {
|
242 |
+
|
243 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
244 |
+
$eapathseo = $searchPath[count($searchPath) - 1]->getSEOPath();
|
245 |
+
|
246 |
+
$eapathseoarr = explode('/', $eapathseo);
|
247 |
+
$currentAttribute = substr($eapathseoarr[count($eapathseoarr) - 1], 0, strpos($eapathseoarr[count($eapathseoarr) - 1], ':'));
|
248 |
+
|
249 |
+
$catPath = $this->getCatPath($res);
|
250 |
+
|
251 |
+
$query = $res->getOriginalQuestionAsked();
|
252 |
+
$allAttributeValues = null;
|
253 |
+
$allAttributes = unserialize(Mage::app()->getCache()->load($catPath));
|
254 |
+
if ($allAttributes){
|
255 |
+
$allAttributeValues = $allAttributes[$attribute];
|
256 |
+
}
|
257 |
+
|
258 |
+
$attributeValues = $res->getDetailedAttributeValuesFull($attribute);
|
259 |
+
$attributeCommonValues = $res->getDetailedCommonAttributeValuesFull($attribute);
|
260 |
+
|
261 |
+
$attributeValues = array_merge($attributeValues, $attributeCommonValues);
|
262 |
+
$attributeValuesKeys = array();
|
263 |
+
foreach ($attributeValues as $attributeValue){
|
264 |
+
$attributeValuesKeys[] = $attributeValue->getNodeString();
|
265 |
+
}
|
266 |
+
|
267 |
+
if ($allAttributeValues){
|
268 |
+
foreach ($allAttributeValues as $allAttributeValue) {
|
269 |
+
$isSelectedValue = false;
|
270 |
+
if (in_array($allAttributeValue['ns'], $attributeValuesKeys)){
|
271 |
+
foreach ($attributeValues as $attributeValue){
|
272 |
+
if (($allAttributeValue['ds'] == $attributeValue->getDisplayName())){
|
273 |
+
$eapathseoarrcopy = $eapathseoarr;
|
274 |
+
for($i = 0; sizeof($eapathseoarrcopy) > $i; $i++){
|
275 |
+
if (strpos($eapathseoarrcopy[$i], ':') > 0){
|
276 |
+
|
277 |
+
$eapath = $eapathseoarrcopy[$i];
|
278 |
+
$eapatharrsize = sizeof(explode (';', $eapath));
|
279 |
+
if ($eapatharrsize > 1){ // multi select
|
280 |
+
for ($j = 0; $eapatharrsize > $j; $j++){
|
281 |
+
$eapatharr = explode (';', $eapath);
|
282 |
+
$eaval = $eapatharr[$j];
|
283 |
+
if ($eaval == $attributeValue->getNodeString()){
|
284 |
+
$isSelectedValue = true;
|
285 |
+
unset($eapatharr[$j]);
|
286 |
+
$eapathseoarrcopy[$i] = implode(';', $eapatharr);
|
287 |
+
$removepath = implode('/', $eapathseoarrcopy);
|
288 |
+
}
|
289 |
+
}
|
290 |
+
}else{
|
291 |
+
if ($eapathseoarrcopy[$i] == $attributeValue->getNodeString()){
|
292 |
+
$isSelectedValue = true;
|
293 |
+
unset($eapathseoarrcopy[$i]);
|
294 |
+
$removepath = implode('/', $eapathseoarrcopy);
|
295 |
+
}
|
296 |
+
}
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
if (!(strpos($allAttributeValue['ns'], $currentAttribute . ':') === false)){
|
301 |
+
$data[] = array(
|
302 |
+
'label' => Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()),
|
303 |
+
'value' => $allAttributeValue['ns'],
|
304 |
+
'count' => $allAttributeValue['pc'],
|
305 |
+
'ea_path' => $eapathseo,
|
306 |
+
'ea_a' => $allAttributeValue['ns'],
|
307 |
+
'ea_bc' => $isSelectedValue ? $removepath : '',
|
308 |
+
'isDisabled' => false,
|
309 |
+
'isChecked' => $isSelectedValue ? true : false,
|
310 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
311 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
312 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
313 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
314 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
315 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
316 |
+
// 'imageURL' => $this->getImageURL($attribute, $attributeValue->getDisplayName())
|
317 |
+
);
|
318 |
+
} else {
|
319 |
+
$data[] = array(
|
320 |
+
'label' => Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()),
|
321 |
+
'value' => $attributeValue->getNodeString(),
|
322 |
+
'count' => $attributeValue->getProductCount(),
|
323 |
+
'ea_path' => $eapathseo,
|
324 |
+
'ea_a' => $attributeValue->getNodeString(),
|
325 |
+
'ea_bc' => $isSelectedValue ? $removepath : '',
|
326 |
+
'isDisabled' => false,
|
327 |
+
'isChecked' => $isSelectedValue ? true : false,
|
328 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
329 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
330 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
331 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
332 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
333 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
334 |
+
// 'imageURL' => $this->getImageURL($attribute, $attributeValue->getDisplayName())
|
335 |
+
);
|
336 |
+
}
|
337 |
+
}
|
338 |
+
}
|
339 |
+
} else {
|
340 |
+
if (!(strpos($allAttributeValue['ns'], $currentAttribute . ':') === false)){
|
341 |
+
$data[] = array(
|
342 |
+
'label' => $attributeValue->getValueType() == 2 ? Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()) : Mage::helper('core')->htmlEscape($allAttributeValue['ds']),
|
343 |
+
'value' => $allAttributeValue['ns'],
|
344 |
+
'count' => $allAttributeValue['pc'],
|
345 |
+
'ea_path' => $eapathseo,
|
346 |
+
'ea_a' => $allAttributeValue['ns'],
|
347 |
+
'isDisabled' => false,
|
348 |
+
'isChecked' => false,
|
349 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
350 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
351 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
352 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
353 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
354 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
355 |
+
// 'imageURL' => $this->getImageURL($attribute, $allAttributeValue['ds'])
|
356 |
+
);
|
357 |
+
}
|
358 |
+
else {
|
359 |
+
$data[] = array(
|
360 |
+
'label' => $attributeValue->getValueType() == 2 ? Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()) : Mage::helper('core')->htmlEscape($allAttributeValue['ds']),
|
361 |
+
'value' => $allAttributeValue['ns'],
|
362 |
+
'count' => $allAttributeValue['pc'],
|
363 |
+
'ea_path' => $eapathseo,
|
364 |
+
'ea_a' => $allAttributeValue['ns'],
|
365 |
+
'isDisabled' => true,
|
366 |
+
'isChecked' => false,
|
367 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
368 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
369 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
370 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
371 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
372 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
373 |
+
// 'imageURL' => $this->getImageURL($attribute, $allAttributeValue['ds'])
|
374 |
+
);
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
$tags = array(
|
381 |
+
Mage_Eav_Model_Entity_Attribute::CACHE_TAG.':'.$attribute
|
382 |
+
);
|
383 |
+
|
384 |
+
$tags = $this->getLayer()->getStateTags($tags);
|
385 |
+
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
|
386 |
+
}
|
387 |
+
return $data;
|
388 |
+
} else {
|
389 |
+
return parent::_getItemsData();
|
390 |
+
}
|
391 |
+
|
392 |
+
}
|
393 |
+
|
394 |
+
private function getImageURL($attType, $attVal){
|
395 |
+
$imageURL = Mage::getBaseDir('media'). '/catalog/images/' . urlencode(strtolower($attType)) . '/' . urlencode(strtolower($attVal)) . '.jpg';
|
396 |
+
if ((bool)@getimagesize($imageURL) === true){
|
397 |
+
return $imageURL;
|
398 |
+
} else {
|
399 |
+
return "";
|
400 |
+
}
|
401 |
+
}
|
402 |
+
|
403 |
+
private function getCatPath($res){
|
404 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
405 |
+
$eapath = $searchPath[count($searchPath) - 1]->getPath();
|
406 |
+
|
407 |
+
$eapatharr = explode('////', $eapath);
|
408 |
+
$catPath = '';
|
409 |
+
foreach ($eapatharr as $eapath1) {
|
410 |
+
if (!(strpos($eapath1, 'AttribSelect', 0) === 0) && !(strpos($eapath1, '=') > 0)){
|
411 |
+
$catPath = strlen($catPath) > 0 ? $catPath . '-'. $eapath1 : $eapath1;
|
412 |
+
}
|
413 |
+
}
|
414 |
+
return $catPath;
|
415 |
+
}
|
416 |
+
|
417 |
+
}
|
app/code/local/EasyAsk/Search/Model/Catalog/Layer/Filter/Category.php
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EasyAsk_Search_Model_Catalog_Layer_Filter_Category extends Mage_Catalog_Model_Layer_Filter_Category
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Initialize filter items
|
8 |
+
*
|
9 |
+
* @return Mage_Catalog_Model_Layer_Filter_Abstract
|
10 |
+
*/
|
11 |
+
protected function _initItems()
|
12 |
+
{
|
13 |
+
$res = Mage::registry('ea_result');
|
14 |
+
if ($res != null){
|
15 |
+
$data = $this->_getItemsData();
|
16 |
+
$items=array();
|
17 |
+
if ($data != null){
|
18 |
+
foreach ($data as $itemData) {
|
19 |
+
$items[] = $this->_createItem(
|
20 |
+
$itemData['label'],
|
21 |
+
$itemData['value'],
|
22 |
+
$itemData['count'],
|
23 |
+
isset($itemData['ea_path'])?$itemData['ea_path']:'',
|
24 |
+
isset($itemData['ea_c'])?$itemData['ea_c']:'',
|
25 |
+
isset($itemData['ea_a'])?$itemData['ea_a']:'',
|
26 |
+
isset($itemData['ea_bc'])?$itemData['ea_bc']:''
|
27 |
+
);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
$this->_items = $items;
|
31 |
+
return $this;
|
32 |
+
} else {
|
33 |
+
return parent::_initItems();
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Create filter item object
|
40 |
+
*
|
41 |
+
* @param string $label
|
42 |
+
* @param mixed $value
|
43 |
+
* @param int $count
|
44 |
+
* @return Mage_Catalog_Model_Layer_Filter_Item
|
45 |
+
*/
|
46 |
+
protected function _createItem($label, $value, $count=0, $eapath='', $eacat='', $eaattrib='', $eabc='')
|
47 |
+
{
|
48 |
+
$res = Mage::registry('ea_result');
|
49 |
+
if ($res != null){
|
50 |
+
return Mage::getModel('catalog/layer_filter_item')
|
51 |
+
->setFilter($this)
|
52 |
+
->setLabel($label)
|
53 |
+
->setValue($value)
|
54 |
+
->setCount($count)
|
55 |
+
->setEapath($eapath)
|
56 |
+
->setEacat($eacat)
|
57 |
+
->setEaattrib($eaattrib)
|
58 |
+
->setEabc($eabc);
|
59 |
+
} else {
|
60 |
+
return parent::_createItem($label, $value, $count);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Apply category filter to layer
|
66 |
+
*
|
67 |
+
* @param Zend_Controller_Request_Abstract $request
|
68 |
+
* @param Mage_Core_Block_Abstract $filterBlock
|
69 |
+
* @return Mage_Catalog_Model_Layer_Filter_Category
|
70 |
+
*/
|
71 |
+
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
|
72 |
+
{
|
73 |
+
|
74 |
+
$res = Mage::registry('ea_result');
|
75 |
+
|
76 |
+
if ($res != null){
|
77 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
78 |
+
$eapath = $searchPath[count($searchPath) - 1]->getSEOPath();
|
79 |
+
$eavaluepath = $searchPath[count($searchPath) - 1]->getPath();
|
80 |
+
|
81 |
+
$eapatharr = explode('/', $eapath);
|
82 |
+
$eavaluepatharr = explode('////', $eavaluepath);
|
83 |
+
|
84 |
+
for($i = 0; sizeof($eapatharr) > $i; $i++){
|
85 |
+
if (!(strpos($eapatharr[$i], '-') === 0 || strpos($eapatharr[$i], ':') > 0)){
|
86 |
+
if ($eapatharr[$i]){
|
87 |
+
$copyarray = $this->arrayCopy($eapatharr);
|
88 |
+
$filter = $eavaluepatharr[$i + 1];
|
89 |
+
unset($copyarray[$i]);
|
90 |
+
for ($j = $i + 1; sizeof($copyarray) >= $j; $j++){
|
91 |
+
if (!(strpos($copyarray[$j], '-') === 0 || strpos($copyarray[$j], ':') > 0)){
|
92 |
+
unset($copyarray[$j]);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
$removepath = implode('/', $copyarray);
|
96 |
+
$this->getLayer()->getState()->addFilter(
|
97 |
+
$this->_createItem($filter, $filter, 0, '','','', $removepath));
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
return $this;
|
103 |
+
}else{
|
104 |
+
return parent::apply($request, $filterBlock);
|
105 |
+
}
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Get data array for building category filter items
|
111 |
+
*
|
112 |
+
* @return array
|
113 |
+
*/
|
114 |
+
protected function _getItemsData()
|
115 |
+
{
|
116 |
+
$res = Mage::registry('ea_result');
|
117 |
+
if ($res != null){
|
118 |
+
$key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
|
119 |
+
$data = $this->getLayer()->getAggregator()->getCacheData($key);
|
120 |
+
|
121 |
+
if ($data === null) {
|
122 |
+
$res = Mage::registry('ea_result');
|
123 |
+
|
124 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
125 |
+
$eapath = $searchPath[count($searchPath) - 1]->getSEOPath();
|
126 |
+
|
127 |
+
$categories = array();
|
128 |
+
if ($res->getInitDisplayLimitForCategories() > 0){
|
129 |
+
$categories = $res->getDetailedCategories(1);
|
130 |
+
foreach ($res->getDetailedCategoriesFull() as $cat){
|
131 |
+
$categories [] = $cat;
|
132 |
+
}
|
133 |
+
} else {
|
134 |
+
$categories = $res->getDetailedCategoriesFull();
|
135 |
+
}
|
136 |
+
|
137 |
+
foreach ($categories as $category) {
|
138 |
+
// if ($category->getProductCount()) {
|
139 |
+
$catids = $category->getIDs();
|
140 |
+
$data[] = array(
|
141 |
+
'label' => Mage::helper('core')->htmlEscape($category->getName()),
|
142 |
+
'value' => $catids[0],
|
143 |
+
'count' => $category->getProductCount(),
|
144 |
+
'ea_c' => $category->getNodeString(),
|
145 |
+
'ea_path' => $eapath
|
146 |
+
);
|
147 |
+
// }
|
148 |
+
}
|
149 |
+
|
150 |
+
$tags = $this->getLayer()->getStateTags();
|
151 |
+
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
|
152 |
+
}
|
153 |
+
return $data;
|
154 |
+
} else {
|
155 |
+
return parent::_getItemsData();
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
private function arrayCopy( array $array ) {
|
160 |
+
$result = array();
|
161 |
+
foreach( $array as $key => $val ) {
|
162 |
+
if( is_array( $val ) ) {
|
163 |
+
$result[$key] = arrayCopy( $val );
|
164 |
+
} elseif ( is_object( $val ) ) {
|
165 |
+
$result[$key] = clone $val;
|
166 |
+
} else {
|
167 |
+
$result[$key] = $val;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
return $result;
|
171 |
+
}
|
172 |
+
|
173 |
+
}
|
app/code/local/EasyAsk/Search/Model/Catalog/Layer/Filter/Item.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Model_Catalog_Layer_Filter_Item extends Mage_Catalog_Model_Layer_Filter_Item {
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Initialize filter items
|
6 |
+
*
|
7 |
+
* @return Mage_Catalog_Model_Layer_Filter_Abstract
|
8 |
+
*/
|
9 |
+
protected function _initItems() {
|
10 |
+
$res = Mage::registry('ea_result');
|
11 |
+
if ($res != null){
|
12 |
+
$data = $this->_getItemsData ();
|
13 |
+
$items = array ();
|
14 |
+
if ($data != null) {
|
15 |
+
foreach ( $data as $itemData ) {
|
16 |
+
$items [] = $this->_createItem ( $itemData ['label'], $itemData ['value'], $itemData ['count'], isset ( $itemData ['ea_path'] ) ? $itemData ['ea_path'] : '', isset ( $itemData ['ea_c'] ) ? $itemData ['ea_c'] : '', isset ( $itemData ['ea_a'] ) ? $itemData ['ea_a'] : '', isset ( $itemData ['ea_bc'] ) ? $itemData ['ea_bc'] : '' );
|
17 |
+
}
|
18 |
+
}
|
19 |
+
$this->_items = $items;
|
20 |
+
return $this;
|
21 |
+
} else {
|
22 |
+
return parent::_initItems();
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Create filter item object
|
28 |
+
*
|
29 |
+
* @param string $label
|
30 |
+
* @param mixed $value
|
31 |
+
* @param int $count
|
32 |
+
* @return Mage_Catalog_Model_Layer_Filter_Item
|
33 |
+
*/
|
34 |
+
protected function _createItem($label, $value, $count = 0, $eapath = '', $eacat = '', $eaattrib = '', $eabc = '') {
|
35 |
+
$res = Mage::registry('ea_result');
|
36 |
+
if ($res != null){
|
37 |
+
return Mage::getModel ( 'catalog/layer_filter_item' )->setFilter ( $this )->setLabel ( $label )->setValue ( $value )->setCount ( $count )->setEapath ( $eapath )->setEacat ( $eacat )->setEaattrib ( $eaattrib )->setEabc ( $eabc );
|
38 |
+
} else {
|
39 |
+
return parent::_createItem($label, $value, $count);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Get filter item url
|
45 |
+
*
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
public function getUrl() {
|
49 |
+
$res = Mage::registry ( 'ea_result' );
|
50 |
+
|
51 |
+
if ($res != null) {
|
52 |
+
if (strlen ( $this->getEacat () ) > 0 && !(strpos ( $this->getEapath() , '-' ) === 0)) {
|
53 |
+
// Category handling
|
54 |
+
$catPath = $this->getEacat ();
|
55 |
+
// check for any attributes selected
|
56 |
+
$pathArr = explode ( '/', $this->getEapath () );
|
57 |
+
$attrArray = array ();
|
58 |
+
for($i = 0; $i < sizeof ( $pathArr ); $i ++) {
|
59 |
+
if (strpos ( $pathArr [$i], ":" ) > 0) {
|
60 |
+
$attrArray [] = $pathArr [$i];
|
61 |
+
}
|
62 |
+
}
|
63 |
+
$param = '';
|
64 |
+
if (sizeof ( $attrArray ) > 0) {
|
65 |
+
for($j = 0; $j < sizeof ( $attrArray ); $j ++) {
|
66 |
+
if ($j == 0) {
|
67 |
+
$param = $attrArray [$j];
|
68 |
+
} else {
|
69 |
+
$param = $param . '&' . $attrArray [$j];
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
return Mage::getBaseUrl () . str_replace ( '_', '/', $catPath ) . (strlen ( $param ) === 0 ? '' : '?ea_a=' . $param);
|
74 |
+
} else {
|
75 |
+
$query = array (
|
76 |
+
$this->getFilter ()->getRequestVar () => $this->getValue (),
|
77 |
+
Mage::getBlockSingleton ( 'page/html_pager' )->getPageVarName () => null, // exclude current page from urls
|
78 |
+
'ea_path' => $this->getEapath (),
|
79 |
+
'ea_c' => $this->getEacat (),
|
80 |
+
'ea_a' => $this->getEaattrib (),
|
81 |
+
'ea_bc' => ''
|
82 |
+
);
|
83 |
+
return Mage::getUrl ( '*/*/*', array (
|
84 |
+
'_current' => true,
|
85 |
+
'_use_rewrite' => true,
|
86 |
+
'_query' => $query
|
87 |
+
) );
|
88 |
+
}
|
89 |
+
} else {
|
90 |
+
return parent::getUrl ();
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Get url for remove item from filter
|
96 |
+
*
|
97 |
+
* @return string
|
98 |
+
*/
|
99 |
+
public function getRemoveUrl() {
|
100 |
+
$res = Mage::registry ( 'ea_result' );
|
101 |
+
|
102 |
+
if ($res != null) {
|
103 |
+
if (strpos ( $this->getEabc (), '-' ) === 0) {
|
104 |
+
|
105 |
+
$query = array (
|
106 |
+
$this->getFilter ()->getRequestVar () => $this->getFilter ()->getResetValue (),
|
107 |
+
Mage::getBlockSingleton ( 'page/html_pager' )->getPageVarName () => null, // exclude current page from urls
|
108 |
+
'ea_path' => '',
|
109 |
+
'ea_c' => '',
|
110 |
+
'ea_a' => '',
|
111 |
+
'ea_bc' => $this->getEabc ()
|
112 |
+
);
|
113 |
+
|
114 |
+
return Mage::getUrl ( '*/*/*', array (
|
115 |
+
'_current' => true,
|
116 |
+
'_use_rewrite' => true,
|
117 |
+
'_query' => $query
|
118 |
+
) );
|
119 |
+
} else {
|
120 |
+
$remPathArr = explode ( '/', $this->getEabc () );
|
121 |
+
$catArray = array ();
|
122 |
+
$attrArray = array ();
|
123 |
+
|
124 |
+
for($i = 0; $i < sizeof ( $remPathArr ); $i ++) {
|
125 |
+
if (strpos ( $remPathArr [$i], ":" ) > 0) {
|
126 |
+
$attrArray [] = $remPathArr [$i];
|
127 |
+
} else {
|
128 |
+
$catArray [] = $remPathArr [$i];
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
$catPath = '';
|
133 |
+
$param = '';
|
134 |
+
if (sizeof ( $catArray ) > 0) {
|
135 |
+
$catPath = $catArray [sizeof ( $catArray ) - 1];
|
136 |
+
if (!strpos($catPath, '_')){
|
137 |
+
$catPath = implode('/', $catArray);
|
138 |
+
}
|
139 |
+
}
|
140 |
+
if (sizeof ( $attrArray ) > 0) {
|
141 |
+
for($j = 0; $j < sizeof ( $attrArray ); $j ++) {
|
142 |
+
if ($j == 0) {
|
143 |
+
$param = $attrArray [$j];
|
144 |
+
} else {
|
145 |
+
$param = $param . '&' . $attrArray [$j];
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
return sizeof ( $catArray ) == 0 ? Mage::getBaseUrl () : Mage::getBaseUrl () . str_replace ( '_', '/', $catPath ) . (strlen ( $param ) === 0 ? '' : '?ea_a=' . $param);
|
151 |
+
}
|
152 |
+
} else {
|
153 |
+
return parent::getRemoveUrl ();
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
app/code/local/EasyAsk/Search/Model/Catalog/Layer/Filter/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Model/Catalog/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Model/CatalogSearch/Layer.php
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Model_CatalogSearch_Layer extends Mage_CatalogSearch_Model_Layer {
|
3 |
+
|
4 |
+
public function getFilterableAttributes()
|
5 |
+
{
|
6 |
+
|
7 |
+
$res = Mage::registry('ea_result');
|
8 |
+
if ($res != null){
|
9 |
+
|
10 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
11 |
+
$eapath = $searchPath[count($searchPath) - 1]->getPath();
|
12 |
+
|
13 |
+
$originalAttributes = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked() . '_original'));
|
14 |
+
|
15 |
+
if (!$originalAttributes){ // In rare cases we may get a search result without a question. This may happen when the user
|
16 |
+
//selects a category from SAYT. In this case the original Attributes are from the cache for the category selected
|
17 |
+
$eapathseo = $searchPath[count($searchPath) - 1]->getSEOPath();
|
18 |
+
|
19 |
+
$eapathseoarr = explode('/', $eapathseo);
|
20 |
+
|
21 |
+
$catPath = '';
|
22 |
+
foreach ($eapathseoarr as $eapathseo1) {
|
23 |
+
if (!(strpos($eapathseo1, '-', 0) === 0) && !(strpos($eapathseo1, ':') > 0)){
|
24 |
+
$catPath = strlen($catPath) > 0 ? $catPath . '-'. $eapathseo1 : $eapathseo1;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
if (strlen($catPath) > 0){
|
29 |
+
$originalAttributes = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked() . '-'.$catPath));
|
30 |
+
} else {
|
31 |
+
$originalAttributes = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked()));
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
$collection = null;
|
36 |
+
|
37 |
+
$currentAttribute = '';
|
38 |
+
$eapatharr = explode('////', $eapath);
|
39 |
+
if (strpos($eapatharr[count($eapatharr) - 1], 'AttribSelect') !== false){
|
40 |
+
$currentAttributePath = substr($eapatharr[count($eapatharr) - 1], 13);
|
41 |
+
$currentAttribute = substr($currentAttributePath, 0, strpos($currentAttributePath, '='));
|
42 |
+
}
|
43 |
+
|
44 |
+
// $currentAttribute = substr($eapatharr[count($eapatharr) - 1], 0, strpos($eapatharr[count($eapatharr) - 1], ':'));
|
45 |
+
|
46 |
+
$originalAttribNames = array();
|
47 |
+
if ($originalAttributes){
|
48 |
+
$originalAttribNames = array_keys($originalAttributes);
|
49 |
+
}
|
50 |
+
|
51 |
+
if (Mage::getStoreConfig('catalog/layered_navigation/ea_multiselect') == 1){
|
52 |
+
$commonAttribs = $res->getCommonAttributeNames(true);
|
53 |
+
foreach ($commonAttribs as $commonAttrib){
|
54 |
+
if (($commonAttrib == $currentAttribute) ){
|
55 |
+
$collection[]= $commonAttrib;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
$attribs = $res->getAttributeNamesFull();
|
61 |
+
foreach ($attribs as $attrib){
|
62 |
+
// if (in_array($attrib, $originalAttribNames)){
|
63 |
+
$collection[] = $attrib;
|
64 |
+
// }
|
65 |
+
}
|
66 |
+
|
67 |
+
$isDispLimited = $res->isInitialDispLimitedForAttrNames();
|
68 |
+
$attribCollection = array();
|
69 |
+
if ($collection){
|
70 |
+
if ($isDispLimited){
|
71 |
+
$initialdisparray = unserialize(Mage::app()->getCache()->load($res->getOriginalQuestionAsked() . '_initial'));
|
72 |
+
// If the initial display is limited then expand the number of attributes specified
|
73 |
+
if (!$initialdisparray){
|
74 |
+
$initialdisparray = $res->getInitialDisplayList(1);
|
75 |
+
}
|
76 |
+
foreach ($collection as $item){
|
77 |
+
$initDispLimited = $res->getInitialDispLimitForAttrValues($item) > 0 ? $res->getInitialDispLimitForAttrValues($item) : ($originalAttributes[$item][0]['id'] > 0 ? $originalAttributes[$item][0]['id'] : 0);
|
78 |
+
if (in_array($item, $initialdisparray)){
|
79 |
+
$attrib = array(
|
80 |
+
'name' => $item,
|
81 |
+
'expand' => true,
|
82 |
+
'dispLimited' => $initDispLimited,
|
83 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
84 |
+
);
|
85 |
+
}else{
|
86 |
+
$attrib = array(
|
87 |
+
'name' => $item,
|
88 |
+
'expand' => false,
|
89 |
+
'dispLimited' => $initDispLimited,
|
90 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
91 |
+
);
|
92 |
+
}
|
93 |
+
$attribCollection[] = $attrib;
|
94 |
+
}
|
95 |
+
|
96 |
+
}else{
|
97 |
+
// If the initial display is not limited then by default expand the first 3 attributes
|
98 |
+
$i = 0;
|
99 |
+
|
100 |
+
foreach ($collection as $item){
|
101 |
+
$initDispLimited = $res->getInitialDispLimitForAttrValues($item) > 0 ? $res->getInitialDispLimitForAttrValues($item) : (in_array($item, $originalAttribNames) ? $originalAttributes[$item][0]['id'] : 0);
|
102 |
+
if ($i < 3){
|
103 |
+
$attrib = array(
|
104 |
+
'name' => $item,
|
105 |
+
'expand' => true,
|
106 |
+
'dispLimited' => $initDispLimited,
|
107 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
108 |
+
);
|
109 |
+
} else {
|
110 |
+
$attrib = array(
|
111 |
+
'name' => $item,
|
112 |
+
'expand' => false,
|
113 |
+
'dispLimited' => $initDispLimited,
|
114 |
+
'isRangeFilter' => $res->isRangeFilter($item)
|
115 |
+
);
|
116 |
+
|
117 |
+
}
|
118 |
+
$i++;
|
119 |
+
$attribCollection[] = $attrib;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
return $attribCollection;
|
124 |
+
}
|
125 |
+
|
126 |
+
return parent::getFilterableAttributes();
|
127 |
+
}
|
128 |
+
|
129 |
+
public function getStateAttributes()
|
130 |
+
{
|
131 |
+
|
132 |
+
$res = Mage::registry('ea_result');
|
133 |
+
if ($res != null){
|
134 |
+
|
135 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
136 |
+
$eapath = $searchPath[count($searchPath) - 1]->getPath();
|
137 |
+
|
138 |
+
$eapatharr = explode('////', $eapath);
|
139 |
+
$attrarray = array();
|
140 |
+
foreach ($eapatharr as $attrpath){
|
141 |
+
if (strpos($attrpath, 'AttribSelect') !== false){
|
142 |
+
$attribsel = substr($attrpath, 13);
|
143 |
+
$attrarray[] = $attribsel;//substr($attribsel, 0, strpos($attribsel, '='));
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
return $attrarray;
|
148 |
+
}
|
149 |
+
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Prepare product collection
|
154 |
+
*
|
155 |
+
* @param Mage_Catalog_Model_Resource_Eav_Resource_Product_Collection $collection
|
156 |
+
* @return Mage_Catalog_Model_Layer
|
157 |
+
*/
|
158 |
+
public function prepareProductCollection($collection)
|
159 |
+
{
|
160 |
+
$res = Mage::registry('ea_result');
|
161 |
+
if ($res != null){
|
162 |
+
|
163 |
+
}else{
|
164 |
+
return parent::prepareProductCollection($collection);
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
}
|
app/code/local/EasyAsk/Search/Model/CatalogSearch/Layer/Filter/Attribute.php
ADDED
@@ -0,0 +1,397 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Model_CatalogSearch_Layer_Filter_Attribute extends EasyAsk_Search_Model_Catalog_Layer_Filter_Attribute {
|
3 |
+
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Initialize filter items
|
7 |
+
*
|
8 |
+
* @return Mage_Catalog_Model_Layer_Filter_Abstract
|
9 |
+
*/
|
10 |
+
protected function _initItems()
|
11 |
+
{
|
12 |
+
$data = $this->_getItemsData();
|
13 |
+
$items=array();
|
14 |
+
if ($data != null){
|
15 |
+
foreach ($data as $itemData) {
|
16 |
+
$items[] = $this->_createItem(
|
17 |
+
$itemData['label'],
|
18 |
+
$itemData['value'],
|
19 |
+
$itemData['count'],
|
20 |
+
isset($itemData['ea_path'])?$itemData['ea_path']:'',
|
21 |
+
isset($itemData['ea_c'])?$itemData['ea_c']:'',
|
22 |
+
isset($itemData['ea_a'])?$itemData['ea_a']:'',
|
23 |
+
isset($itemData['ea_bc'])?$itemData['ea_bc']:'',
|
24 |
+
isset($itemData['isDisabled'])?$itemData['isDisabled']:'',
|
25 |
+
isset($itemData['isChecked'])?$itemData['isChecked']:'',
|
26 |
+
isset($itemData['minValue'])?$itemData['minValue']:'',
|
27 |
+
isset($itemData['maxValue'])?$itemData['maxValue']:'',
|
28 |
+
isset($itemData['minRangeValue'])?$itemData['minRangeValue']:'',
|
29 |
+
isset($itemData['maxRangeValue'])?$itemData['maxRangeValue']:'',
|
30 |
+
isset($itemData['rangeRound'])?$itemData['rangeRound']:'',
|
31 |
+
isset($itemData['ea_seoAttr'])?$itemData['ea_seoAttr']:'',
|
32 |
+
isset($itemData['imageURL'])?$itemData['imageURL']:''
|
33 |
+
);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
$this->_items = $items;
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Create filter item object
|
43 |
+
*
|
44 |
+
* @param string $label
|
45 |
+
* @param mixed $value
|
46 |
+
* @param int $count
|
47 |
+
* @return Mage_Catalog_Model_Layer_Filter_Item
|
48 |
+
*/
|
49 |
+
protected function _createItem($label, $value, $count=0, $eapath='', $eacat='', $eaattrib='', $eabc='', $isDisabled='', $isChecked=false,
|
50 |
+
$minValue='', $maxValue='', $minRangeValue='', $maxRangeValue='', $rangeRound='', $eaSeoAttr='', $imageURL='')
|
51 |
+
{
|
52 |
+
return Mage::getModel('catalog/layer_filter_item')
|
53 |
+
->setFilter($this)
|
54 |
+
->setLabel($label)
|
55 |
+
->setValue($value)
|
56 |
+
->setCount($count)
|
57 |
+
->setEapath($eapath)
|
58 |
+
->setEacat($eacat)
|
59 |
+
->setEaattrib($eaattrib)
|
60 |
+
->setEabc($eabc)
|
61 |
+
->setIsDisabled($isDisabled)
|
62 |
+
->setIsChecked($isChecked)
|
63 |
+
->setMinValue($minValue)
|
64 |
+
->setMaxValue($maxValue)
|
65 |
+
->setMinRangeValue($minRangeValue)
|
66 |
+
->setMaxRangeValue($maxRangeValue)
|
67 |
+
->setRangeRound($rangeRound)
|
68 |
+
->setEaSeoAttr($eaSeoAttr)
|
69 |
+
->setImageURL($imageURL);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Set attribute model to filter
|
74 |
+
*
|
75 |
+
* @param Mage_Eav_Model_Entity_Attribute $attribute
|
76 |
+
* @return Mage_Catalog_Model_Layer_Filter_Abstract
|
77 |
+
*/
|
78 |
+
public function setAttributeModel($attribute)
|
79 |
+
{
|
80 |
+
$this->setRequestVar($attribute);
|
81 |
+
$this->setData('attribute_model', $attribute);
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Get filter text label
|
87 |
+
*
|
88 |
+
* @return string
|
89 |
+
*/
|
90 |
+
public function getName()
|
91 |
+
{
|
92 |
+
$res = Mage::registry('ea_result');
|
93 |
+
if ($res != null){
|
94 |
+
return strpos($this->getAttributeModel(), '=') > 0 ? substr($this->getAttributeModel(), 0, strpos($this->getAttributeModel(), '=')) : $this->getAttributeModel();
|
95 |
+
} else {
|
96 |
+
return $this->getAttributeModel()->getStoreLabel();
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Retrieve Attribute code
|
102 |
+
*
|
103 |
+
* @return int
|
104 |
+
*/
|
105 |
+
public function getAttributeCode()
|
106 |
+
{
|
107 |
+
$attributeCode = $this->_getData('attribute_code');
|
108 |
+
return $attributeCode;
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Set Attribute code
|
114 |
+
*
|
115 |
+
* @param int $attributeCode
|
116 |
+
* @return Mage_Catalog_Model_Layer_Filter_Abstract
|
117 |
+
*/
|
118 |
+
public function setAttributeCode($attributeCode)
|
119 |
+
{
|
120 |
+
return $this->setData('attribute_code', $attributeCode);
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Get option text from frontend model by option id
|
125 |
+
*
|
126 |
+
* @param int $optionId
|
127 |
+
* @return unknown
|
128 |
+
*/
|
129 |
+
protected function _getOptionText($optionId)
|
130 |
+
{
|
131 |
+
$res = Mage::registry('ea_result');
|
132 |
+
if ($res != null){
|
133 |
+
return $this->getAttributeModel();
|
134 |
+
} else {
|
135 |
+
return parent::_getOptionText($optionId);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Apply attribute option filter to product collection
|
141 |
+
*
|
142 |
+
* @param Zend_Controller_Request_Abstract $request
|
143 |
+
* @param Varien_Object $filterBlock
|
144 |
+
* @return Mage_Catalog_Model_Layer_Filter_Attribute
|
145 |
+
*/
|
146 |
+
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
|
147 |
+
{
|
148 |
+
$res = Mage::registry('ea_result');
|
149 |
+
if ($res != null){
|
150 |
+
if ($this->getAttributeCode() == '1'){
|
151 |
+
|
152 |
+
$text = $this->_getOptionText(null);
|
153 |
+
|
154 |
+
if ($text) {
|
155 |
+
// $this->_getResource()->applyFilterToCollection($this, $filter);
|
156 |
+
|
157 |
+
//Get the current path and exclude the selected attribute form the path
|
158 |
+
$removepath = '';
|
159 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
160 |
+
$eapathseo = $searchPath[count($searchPath) - 1]->getSEOPath();
|
161 |
+
$eavaluepath = $searchPath[count($searchPath) - 1]->getPath();
|
162 |
+
|
163 |
+
$eapathseoarr = explode('/', $eapathseo);
|
164 |
+
$eavaluepatharr = explode('////', $eavaluepath);
|
165 |
+
for($i = 0; sizeof($eapathseoarr) > $i; $i++){
|
166 |
+
if (strpos($eapathseoarr[$i], ':') > 0){
|
167 |
+
$eavalue = substr($eavaluepatharr[$i + 1], 13);
|
168 |
+
$eapath = $eapathseoarr[$i];
|
169 |
+
if (strcmp($eavalue, $text) == 0){
|
170 |
+
$eapatharrsize = sizeof(explode (';', $eapath));
|
171 |
+
if ($eapatharrsize > 1){ // multi select
|
172 |
+
unset($eapathseoarr[$i]);
|
173 |
+
$removepath = implode('/', $eapathseoarr);
|
174 |
+
$filter = '';
|
175 |
+
for ($j = 0; $eapatharrsize > $j; $j++){
|
176 |
+
$eapatharr = explode (';;;;', $eavalue);
|
177 |
+
$eaval = $eapatharr[$j];
|
178 |
+
if (strpos($eaval, '=') !== false){
|
179 |
+
$filterSub = substr($eaval, strpos($eaval, '=') + 1);
|
180 |
+
}
|
181 |
+
$filter = $filter . '<div>' . str_replace("'", "", $filterSub) . '</div>';
|
182 |
+
}
|
183 |
+
$this->getLayer()->getState()->addFilter($this->_createItem($filter, $filter, 0, '', '', '', $removepath));
|
184 |
+
}else{
|
185 |
+
unset($eapathseoarr[$i]);
|
186 |
+
$removepath = implode('/', $eapathseoarr);
|
187 |
+
// if (strpos($text, '=') !== false){
|
188 |
+
// $filter = substr($text, strpos($text, '=') + 1);
|
189 |
+
// }
|
190 |
+
$filter = $searchPath[$i + 1]->getValue();
|
191 |
+
$this->getLayer()->getState()->addFilter($this->_createItem($filter, $filter, 0, '', '', '', $removepath));
|
192 |
+
}
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
$this->_items = array();
|
199 |
+
}
|
200 |
+
}
|
201 |
+
return $this;
|
202 |
+
} else {
|
203 |
+
return parent::apply($request, $filterBlock);
|
204 |
+
}
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Get data array for building attribute filter items
|
210 |
+
*
|
211 |
+
* @return array
|
212 |
+
*/
|
213 |
+
protected function _getItemsData()
|
214 |
+
{
|
215 |
+
$res = Mage::registry('ea_result');
|
216 |
+
|
217 |
+
if ($res != null){
|
218 |
+
$attribute = $this->getAttributeModel();
|
219 |
+
echo "attribute is $attribute";
|
220 |
+
$this->_requestVar = $attribute;
|
221 |
+
|
222 |
+
$key = $this->getLayer()->getStateKey().'_'.$this->_requestVar;
|
223 |
+
$data = $this->getLayer()->getAggregator()->getCacheData($key);
|
224 |
+
|
225 |
+
if ($data === null) {
|
226 |
+
|
227 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
228 |
+
$eapathseo = $searchPath[count($searchPath) - 1]->getSEOPath();
|
229 |
+
|
230 |
+
$eapathseoarr = explode('/', $eapathseo);
|
231 |
+
$currentAttribute = substr($eapathseoarr[count($eapathseoarr) - 1], 0, strpos($eapathseoarr[count($eapathseoarr) - 1], ':'));
|
232 |
+
|
233 |
+
$catPath = '';
|
234 |
+
foreach ($eapathseoarr as $eapathseo1) {
|
235 |
+
if (!(strpos($eapathseo1, '-', 0) === 0) && !(strpos($eapathseo1, ':') > 0)){
|
236 |
+
$catPath = strlen($catPath) > 0 ? $catPath . '-'. $eapathseo1 : $eapathseo1;
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
//$query = strlen($res->getOriginalQuestionAsked()) > 0 ? $res->getOriginalQuestionAsked() : substr($searchPath[1]->getSEOPath(), 1);
|
241 |
+
$query = $res->getOriginalQuestionAsked();
|
242 |
+
$allAttributeValues = null;
|
243 |
+
if (strlen($catPath) > 0){
|
244 |
+
$allAttributes = unserialize(Mage::app()->getCache()->load($query. '-'.$catPath));
|
245 |
+
} else {
|
246 |
+
$allAttributes = unserialize(Mage::app()->getCache()->load($query));
|
247 |
+
}
|
248 |
+
if ($allAttributes){
|
249 |
+
$allAttributeValues = $allAttributes[$attribute];
|
250 |
+
}
|
251 |
+
|
252 |
+
$attributeValues = $res->getDetailedAttributeValuesFull($attribute);
|
253 |
+
$attributeCommonValues = $res->getDetailedCommonAttributeValuesFull($attribute);
|
254 |
+
|
255 |
+
$attributeValues = array_merge($attributeValues, $attributeCommonValues);
|
256 |
+
$attributeValuesKeys = array();
|
257 |
+
foreach ($attributeValues as $attributeValue){
|
258 |
+
$attributeValuesKeys[] = $attributeValue->getNodeString();
|
259 |
+
}
|
260 |
+
|
261 |
+
if ($allAttributeValues){
|
262 |
+
foreach ($allAttributeValues as $allAttributeValue) {
|
263 |
+
$isSelectedValue = false;
|
264 |
+
if (in_array($allAttributeValue['ns'], $attributeValuesKeys)){
|
265 |
+
foreach ($attributeValues as $attributeValue){
|
266 |
+
if (($allAttributeValue['ds'] == $attributeValue->getDisplayName())){
|
267 |
+
$eapathseoarrcopy = $eapathseoarr;
|
268 |
+
for($i = 0; sizeof($eapathseoarrcopy) > $i; $i++){
|
269 |
+
if (strpos($eapathseoarrcopy[$i], ':') > 0){
|
270 |
+
|
271 |
+
$eapath = $eapathseoarrcopy[$i];
|
272 |
+
$eapatharrsize = sizeof(explode (';', $eapath));
|
273 |
+
if ($eapatharrsize > 1){ // multi select
|
274 |
+
for ($j = 0; $eapatharrsize > $j; $j++){
|
275 |
+
$eapatharr = explode (';', $eapath);
|
276 |
+
$eaval = $eapatharr[$j];
|
277 |
+
if ($eaval == $attributeValue->getNodeString()){
|
278 |
+
$isSelectedValue = true;
|
279 |
+
unset($eapatharr[$j]);
|
280 |
+
$eapathseoarrcopy[$i] = implode(';', $eapatharr);
|
281 |
+
$removepath = implode('/', $eapathseoarrcopy);
|
282 |
+
}
|
283 |
+
}
|
284 |
+
}else{
|
285 |
+
if ($eapathseoarrcopy[$i] == $attributeValue->getNodeString()){
|
286 |
+
$isSelectedValue = true;
|
287 |
+
unset($eapathseoarrcopy[$i]);
|
288 |
+
$removepath = implode('/', $eapathseoarrcopy);
|
289 |
+
}
|
290 |
+
}
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
+
if (!(strpos($allAttributeValue['ns'], $currentAttribute . ':') === false)){
|
295 |
+
$data[] = array(
|
296 |
+
'label' => Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()),
|
297 |
+
'value' => $allAttributeValue['ns'],
|
298 |
+
'count' => $allAttributeValue['pc'],
|
299 |
+
'ea_path' => $eapathseo,
|
300 |
+
'ea_a' => $allAttributeValue['ns'],
|
301 |
+
'ea_bc' => $isSelectedValue ? $removepath : '',
|
302 |
+
'isDisabled' => false,
|
303 |
+
'isChecked' => $isSelectedValue ? true : false,
|
304 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
305 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
306 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
307 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
308 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
309 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
310 |
+
// 'imageURL' => $this->getImageURL($attribute, $attributeValue->getDisplayName())
|
311 |
+
);
|
312 |
+
} else {
|
313 |
+
$data[] = array(
|
314 |
+
'label' => Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()),
|
315 |
+
'value' => $attributeValue->getNodeString(),
|
316 |
+
'count' => $attributeValue->getProductCount(),
|
317 |
+
'ea_path' => $eapathseo,
|
318 |
+
'ea_a' => $attributeValue->getNodeString(),
|
319 |
+
'ea_bc' => $isSelectedValue ? $removepath : '',
|
320 |
+
'isDisabled' => false,
|
321 |
+
'isChecked' => $isSelectedValue ? true : false,
|
322 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
323 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
324 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
325 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
326 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
327 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
328 |
+
// 'imageURL' => $this->getImageURL($attribute, $attributeValue->getDisplayName())
|
329 |
+
);
|
330 |
+
}
|
331 |
+
}
|
332 |
+
}
|
333 |
+
} else {
|
334 |
+
if (!(strpos($allAttributeValue['ns'], $currentAttribute . ':') === false)){
|
335 |
+
$data[] = array(
|
336 |
+
'label' => $attributeValue->getValueType() == 2 ? Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()) : Mage::helper('core')->htmlEscape($allAttributeValue['ds']),
|
337 |
+
'value' => $allAttributeValue['ns'],
|
338 |
+
'count' => $allAttributeValue['pc'],
|
339 |
+
'ea_path' => $eapathseo,
|
340 |
+
'ea_a' => $allAttributeValue['ns'],
|
341 |
+
'isDisabled' => false,
|
342 |
+
'isChecked' => false,
|
343 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
344 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
345 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
346 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
347 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
348 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
349 |
+
// 'imageURL' => $this->getImageURL($attribute, $allAttributeValue['ds'])
|
350 |
+
);
|
351 |
+
}
|
352 |
+
else {
|
353 |
+
$data[] = array(
|
354 |
+
'label' => $attributeValue->getValueType() == 2 ? Mage::helper('core')->htmlEscape($attributeValue->getDisplayName()) : Mage::helper('core')->htmlEscape($allAttributeValue['ds']),
|
355 |
+
'value' => $allAttributeValue['ns'],
|
356 |
+
'count' => $allAttributeValue['pc'],
|
357 |
+
'ea_path' => $eapathseo,
|
358 |
+
'ea_a' => $allAttributeValue['ns'],
|
359 |
+
'isDisabled' => true,
|
360 |
+
'isChecked' => false,
|
361 |
+
'minValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinValue() : '',
|
362 |
+
'maxValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxValue() : '',
|
363 |
+
'minRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMinRangeValue() : '',
|
364 |
+
'maxRangeValue' => $attributeValue->getValueType() == 2 ? $attributeValue->getMaxRangeValue() : '',
|
365 |
+
'rangeRound' => $attributeValue->getValueType() == 2 ? $attributeValue->getRangeRound() : '',
|
366 |
+
'ea_seoAttr' => $attributeValue->getValueType() == 2 ? substr($attributeValue->getNodeString(), 0, strpos($attributeValue->getNodeString(), ':')) : ''//,
|
367 |
+
// 'imageURL' => $this->getImageURL($attribute, $allAttributeValue['ds'])
|
368 |
+
);
|
369 |
+
}
|
370 |
+
}
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
+
$tags = array(
|
375 |
+
Mage_Eav_Model_Entity_Attribute::CACHE_TAG.':'.$attribute
|
376 |
+
);
|
377 |
+
|
378 |
+
$tags = $this->getLayer()->getStateTags($tags);
|
379 |
+
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
|
380 |
+
}
|
381 |
+
return $data;
|
382 |
+
} else {
|
383 |
+
return parent::_getItemsData();
|
384 |
+
}
|
385 |
+
|
386 |
+
}
|
387 |
+
|
388 |
+
private function getImageURL($attType, $attVal){
|
389 |
+
$imageURL = Mage::getBaseDir('media'). '/catalog/images/' . urlencode(strtolower($attType)) . '/' . urlencode(strtolower($attVal)) . '.jpg';
|
390 |
+
if ((bool)@getimagesize($imageURL) === true){
|
391 |
+
return $imageURL;
|
392 |
+
} else {
|
393 |
+
return "";
|
394 |
+
}
|
395 |
+
}
|
396 |
+
|
397 |
+
}
|
app/code/local/EasyAsk/Search/Model/CatalogSearch/Layer/Filter/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Model/CatalogSearch/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Model/Observer.php
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EasyAsk_Search_Model_Observer extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected $_helper = null;
|
6 |
+
|
7 |
+
public function getHelper() {
|
8 |
+
if ($this->_helper === null) {
|
9 |
+
$this->_helper = Mage::helper('easyask_search');
|
10 |
+
}
|
11 |
+
return $this->_helper;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function catalogControllerCategoryInitAfter (Varien_Event_Observer $observer)
|
15 |
+
{
|
16 |
+
$searchEngine = Mage::getStoreConfig('catalog/search/engine');
|
17 |
+
$useEA = Mage::getStoreConfig('catalog/navigation/use_easyask');
|
18 |
+
if (strcasecmp($searchEngine, 'easyask_search/engine') === 0 && $useEA) {
|
19 |
+
|
20 |
+
$category = $observer->getCategory();
|
21 |
+
|
22 |
+
if ($category instanceof Mage_Catalog_Model_Category) {
|
23 |
+
$url = $category->getUrl();
|
24 |
+
} else {
|
25 |
+
$url = $this->_getCategoryInstance()
|
26 |
+
->setData($category->getData())
|
27 |
+
->getUrl();
|
28 |
+
}
|
29 |
+
|
30 |
+
$eacat = str_replace('/', '_', substr($url, strlen(Mage::getBaseUrl())));
|
31 |
+
$eapath = '';
|
32 |
+
$groupId = "";
|
33 |
+
$login = Mage::getSingleton( 'customer/session' )->isLoggedIn(); //Check if User is Logged In
|
34 |
+
if($login){
|
35 |
+
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); //Get Customers Group ID
|
36 |
+
}
|
37 |
+
|
38 |
+
$cache = Mage::app()->getCache();
|
39 |
+
|
40 |
+
$mode = $this->getRequest($observer)->getParam('mode', 'grid');
|
41 |
+
$limit = $this->getRequest($observer)->getParam('limit', 0);
|
42 |
+
$order = $this->getRequest($observer)->getParam('order', 'relevance');
|
43 |
+
$dir = $this->getRequest($observer)->getParam('dir', 'asc');
|
44 |
+
$page = $this->getRequest($observer)->getParam('p');
|
45 |
+
$attribSel = $this->getRequest($observer)->getParam('ea_a', '');
|
46 |
+
$eapath = $this->getRequest($observer)->getParam('ea_path', '');
|
47 |
+
|
48 |
+
$event_data_array = array();
|
49 |
+
$varien_object = new Varien_Object($event_data_array);
|
50 |
+
Mage::dispatchEvent('catalog_controller_sortmap_update_set', array('varien_obj'=>$varien_object));
|
51 |
+
|
52 |
+
$attributeToColumn = $varien_object->getSortArray();
|
53 |
+
|
54 |
+
$attributes = Mage::getModel('catalog/config')->getAttributesUsedForSortBy();
|
55 |
+
foreach ($attributes as $attribute) {
|
56 |
+
$attrCode = $attribute->getAttributeCode();
|
57 |
+
$eaAttrCode = ucwords(preg_replace('/_/', ' ', $attribute->getAttributeCode()));
|
58 |
+
if ($attrCode == 'name') {
|
59 |
+
$eaAttrCode = 'Product ' . $eaAttrCode;
|
60 |
+
}
|
61 |
+
$attributeToColumn[$attrCode] = $eaAttrCode;
|
62 |
+
}
|
63 |
+
|
64 |
+
if ($limit !== 'all' && $limit == 0){
|
65 |
+
$limit = Mage::getSingleton('catalog/session')->getLimitPage();
|
66 |
+
}
|
67 |
+
|
68 |
+
$rpp = 0;
|
69 |
+
if ($mode == 'grid'){
|
70 |
+
$rpp = ($limit == 0) ? Mage::getStoreConfig('catalog/frontend/grid_per_page') : $limit;
|
71 |
+
} else {
|
72 |
+
$rpp = ($limit == 0) ? Mage::getStoreConfig('catalog/frontend/list_per_page') : $limit;
|
73 |
+
}
|
74 |
+
|
75 |
+
Varien_Profiler::start('EASYASK::categoryrequest1');
|
76 |
+
|
77 |
+
$eahostname = Mage::getStoreConfig('catalog/search/ea_server_hostname');
|
78 |
+
$eaport = Mage::getStoreConfig('catalog/search/ea_server_port');
|
79 |
+
$eadictionary = Mage::getStoreConfig('catalog/search/ea_dictionary');
|
80 |
+
|
81 |
+
if ($eahostname == '' || $eadictionary == ''){
|
82 |
+
throw new Exception("To use easyask search engine you need to specify the host name, port and dictionary in catalog search configuration screen in admin console.");
|
83 |
+
}
|
84 |
+
|
85 |
+
$ea = EasyAsk_Impl_RemoteFactory::create($eahostname, $eaport, $eadictionary);
|
86 |
+
|
87 |
+
$opts = $ea->getOptions();
|
88 |
+
$opts->setResultsPerPage($rpp);
|
89 |
+
$opts->setGrouping("");
|
90 |
+
// $opts->setToplevelProducts(true);
|
91 |
+
$opts->setNavigateHierarchy(false);
|
92 |
+
$opts->setSubCategories(false);
|
93 |
+
$opts->setGroupId($groupId);
|
94 |
+
$opts->setCustomerId("");
|
95 |
+
//$opts->setCallOutParam("&eap_PriceCode=1");
|
96 |
+
|
97 |
+
// Set sort field and direction
|
98 |
+
if ($order != 'relevance') {
|
99 |
+
$opts->setSortOrder($attributeToColumn[$order] . ',' . ($dir == 'asc' ? 't' : 'f'));
|
100 |
+
}
|
101 |
+
|
102 |
+
if ($page){
|
103 |
+
$res = $ea->userGoToPage($eapath, $page);
|
104 |
+
}
|
105 |
+
else if (strlen($attribSel) > 0){
|
106 |
+
$attrtype = substr($attribSel, 0, strpos($attribSel, ':'));
|
107 |
+
$eapatharr = explode('/', $eapath);
|
108 |
+
|
109 |
+
for($i = 0; sizeof($eapatharr) > $i; $i++){
|
110 |
+
if (!(strpos($eapatharr[$i], $attrtype . ':') === false)){
|
111 |
+
$attribSel = $eapatharr[$i] . ';' . $attribSel;
|
112 |
+
unset($eapatharr[$i]);
|
113 |
+
}
|
114 |
+
$eapath = implode('/', $eapatharr);
|
115 |
+
}
|
116 |
+
|
117 |
+
$res = $ea->userAttributeClick(strlen($eapath) > 0 ? $eapath : '/' . $eacat, $attribSel);
|
118 |
+
|
119 |
+
$catPath = $this->getCatPath($res);
|
120 |
+
$queryText = $res->getOriginalQuestionAsked();
|
121 |
+
|
122 |
+
$this->getHelper()->updateCachedAttributes($catPath,$res->getAttributeNamesFull(), $res, $cache);
|
123 |
+
$this->getHelper()->updateCachedAttributes($catPath,$res->getCommonAttributeNames(true), $res, $cache);
|
124 |
+
}
|
125 |
+
else {
|
126 |
+
$res = $ea->userCategoryClick($eapath, $eacat);
|
127 |
+
|
128 |
+
$catPath = $this->getCatPath($res);
|
129 |
+
|
130 |
+
$this->getHelper()->cacheAttributes($catPath, $res, $cache);
|
131 |
+
}
|
132 |
+
|
133 |
+
Varien_Profiler::stop('EASYASK::categoryrequest1');
|
134 |
+
/*if ($res->getFirstItem() == -1){
|
135 |
+
return parent::catalogControllerCategoryInitAfter($observer);
|
136 |
+
}*/
|
137 |
+
|
138 |
+
if($res->getReturnCode() == -1){
|
139 |
+
Mage::helper('catalogsearch')->setNoteMessages(array($res->getErrorMsg()));
|
140 |
+
}else{
|
141 |
+
Varien_Profiler::start('EASYASK::categoryrequest2');
|
142 |
+
|
143 |
+
// Let us first search for shoes. All Products is the top level category.
|
144 |
+
$path = $res->getCatPath();
|
145 |
+
|
146 |
+
$commentary = $res->getCommentary();
|
147 |
+
$originalQuestion = $res->getOriginalQuestion();
|
148 |
+
|
149 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
150 |
+
|
151 |
+
if (($res->getReturnCode() == -1) && (count($searchPath) === 0)){
|
152 |
+
throw new Exception("The easyask search engine is not configured properly. To use easyask search engine you need to specify the host name, port and dictionary in catalog search configuration screen in admin console.");
|
153 |
+
}
|
154 |
+
|
155 |
+
$realSearchQuery = isset($searchPath[1]) ? $searchPath[1]->getValue() : $originalQuestion;
|
156 |
+
|
157 |
+
Mage::register('ea_result', $res);
|
158 |
+
|
159 |
+
if (strpos($commentary, 'Ignored:') !== false || strpos($commentary, 'Corrected Word:') !== false) {
|
160 |
+
Mage::helper('catalogsearch')->setNoteMessages(array(
|
161 |
+
sprintf("We found no results for '%s' but you may find the following results relevant:", $originalQuestion)
|
162 |
+
));
|
163 |
+
}
|
164 |
+
|
165 |
+
Varien_Profiler::stop('EASYASK::categoryrequest2');
|
166 |
+
|
167 |
+
}
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
public function getRequest($observer) {
|
174 |
+
return $observer->getControllerAction()->getRequest();
|
175 |
+
}
|
176 |
+
|
177 |
+
private function getCatPath($res){
|
178 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
179 |
+
$eapath = $searchPath[count($searchPath) - 1]->getPath();
|
180 |
+
|
181 |
+
$eapatharr = explode('////', $eapath);
|
182 |
+
$catPath = '';
|
183 |
+
foreach ($eapatharr as $eapath1) {
|
184 |
+
if (!(strpos($eapath1, 'AttribSelect', 0) === 0) && !(strpos($eapath1, '=') > 0)){
|
185 |
+
$catPath = strlen($catPath) > 0 ? $catPath . '-'. $eapath1 : $eapath1;
|
186 |
+
}
|
187 |
+
}
|
188 |
+
return $catPath;
|
189 |
+
}
|
190 |
+
}
|
app/code/local/EasyAsk/Search/Model/Resource/Catalog/Product/Collection.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Model_Resource_Catalog_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection{
|
3 |
+
public function getSize()
|
4 |
+
{
|
5 |
+
$res = Mage::registry('ea_result');
|
6 |
+
if ($res != null){
|
7 |
+
$size = $res->getResultCount();
|
8 |
+
return $size != -1? $size : 0;
|
9 |
+
}else{
|
10 |
+
return parent::getSize();
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
14 |
+
public function setIsLoaded($flag = true)
|
15 |
+
{
|
16 |
+
return $this->isLoaded();
|
17 |
+
}
|
18 |
+
}
|
app/code/local/EasyAsk/Search/Model/Resource/Catalog/Product/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Model/Resource/CatalogSearch/Fulltext/Collection.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_Model_Resource_CatalogSearch_Fulltext_Collection extends Mage_CatalogSearch_Model_Resource_Fulltext_Collection{
|
3 |
+
/**
|
4 |
+
* Loading state flag
|
5 |
+
*
|
6 |
+
* @var bool
|
7 |
+
*/
|
8 |
+
protected $_isCollectionLoaded;
|
9 |
+
/**
|
10 |
+
* Retireve count of collection loaded items
|
11 |
+
*
|
12 |
+
* @return int
|
13 |
+
*/
|
14 |
+
|
15 |
+
function count(){
|
16 |
+
return count($this->_items);
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Implementation of IteratorAggregate::getIterator()
|
21 |
+
*/
|
22 |
+
public function getIterator()
|
23 |
+
{
|
24 |
+
return new ArrayIterator($this->_items);
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getSize()
|
28 |
+
{
|
29 |
+
$res = Mage::registry('ea_result');
|
30 |
+
if ($res != null){
|
31 |
+
$size = $res->getResultCount();
|
32 |
+
return $size != -1? $size : 0;
|
33 |
+
}else{
|
34 |
+
return parent::getSize();
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
public function addCountToCategories($categoryCollection)
|
39 |
+
{
|
40 |
+
|
41 |
+
$res = Mage::registry('ea_result');
|
42 |
+
if ($res != null){
|
43 |
+
$cats = $res->getDetailedCategories(0);
|
44 |
+
$eacats = array();
|
45 |
+
foreach($cats as $cat){
|
46 |
+
$ids = $cat->getIds();
|
47 |
+
$eacats[$ids[0]] = (String)$cat->getProductCount();
|
48 |
+
}
|
49 |
+
|
50 |
+
foreach ($categoryCollection as $category) {
|
51 |
+
$_count = 0;
|
52 |
+
if (isset($eacats[$category->getId()])) {
|
53 |
+
$_count = $eacats[$category->getId()];
|
54 |
+
}
|
55 |
+
$category->setProductCount($_count);
|
56 |
+
}
|
57 |
+
|
58 |
+
return $this;
|
59 |
+
|
60 |
+
} else {
|
61 |
+
return parent::addCountToCategories($categoryCollection);
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
public function setIsLoaded($flag = true)
|
66 |
+
{
|
67 |
+
$this->_setIsLoaded($flag);
|
68 |
+
return $this->isLoaded();
|
69 |
+
}
|
70 |
+
|
71 |
+
protected function _afterLoad()
|
72 |
+
{
|
73 |
+
|
74 |
+
$res = Mage::registry('ea_result');
|
75 |
+
if ($res != null){
|
76 |
+
|
77 |
+
}else{
|
78 |
+
return parent::_afterLoad();
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Retrieve collection loading status
|
85 |
+
*
|
86 |
+
* @return bool
|
87 |
+
*/
|
88 |
+
public function isLoaded()
|
89 |
+
{
|
90 |
+
return $this->_isCollectionLoaded;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Set collection loading status flag
|
95 |
+
*
|
96 |
+
* @param unknown_type $flag
|
97 |
+
* @return unknown
|
98 |
+
*/
|
99 |
+
protected function _setIsLoaded($flag = true)
|
100 |
+
{
|
101 |
+
$this->_isCollectionLoaded = $flag;
|
102 |
+
return $this;
|
103 |
+
}
|
104 |
+
|
105 |
+
}
|
app/code/local/EasyAsk/Search/Model/Resource/CatalogSearch/Fulltext/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/Model/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/controllers/Adminhtml/Search/System/Config/TestconnectionController.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento Enterprise Edition
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Magento Enterprise Edition License
|
8 |
+
* that is bundled with this package in the file LICENSE_EE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.magentocommerce.com/license/enterprise-edition
|
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 Enterprise
|
22 |
+
* @package Enterprise_Search
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://www.magentocommerce.com/license/enterprise-edition
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Admin search test connection controller
|
29 |
+
*
|
30 |
+
* @category Enterprise
|
31 |
+
* @package Enterprise_Search
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class EasyAsk_Search_Adminhtml_Search_System_Config_TestconnectionController
|
35 |
+
extends Mage_Adminhtml_Controller_Action
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* Check for connection to server
|
39 |
+
*/
|
40 |
+
public function pingAction()
|
41 |
+
{
|
42 |
+
Mage::log("EasyAsk_Search_Adminhtml_Search_System_Config_TestconnectionController pingAction ");
|
43 |
+
|
44 |
+
if (!isset($_REQUEST['host']) || !($host = $_REQUEST['host'])
|
45 |
+
|| !isset($_REQUEST['port']) || !($port = (int)$_REQUEST['port'])
|
46 |
+
|| !isset($_REQUEST['dictionary']) || !($dictionary = $_REQUEST['dictionary'])
|
47 |
+
) {
|
48 |
+
echo 0;
|
49 |
+
die;
|
50 |
+
}
|
51 |
+
|
52 |
+
$pingUrl = 'http://' . $host . ':' . $port . '/EasyAsk/health.jsp?dxp=' . $dictionary;
|
53 |
+
|
54 |
+
Mage::log("EasyAsk_Search_Adminhtml_Search_System_Config_TestconnectionController pingurl is " . $pingUrl);
|
55 |
+
|
56 |
+
$ping = $this->url_get_header($pingUrl);
|
57 |
+
|
58 |
+
Mage::log("EasyAsk_Search_Adminhtml_Search_System_Config_TestconnectionController ping is " . $ping);
|
59 |
+
|
60 |
+
// result is false if there was a timeout
|
61 |
+
// or if the HTTP status was not 200
|
62 |
+
if (strpos($ping, '200') === false) {
|
63 |
+
echo 0;
|
64 |
+
} else {
|
65 |
+
echo 1;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
function url_get_header ($Url) {
|
70 |
+
if (!function_exists('curl_init')){
|
71 |
+
die('CURL is not installed!');
|
72 |
+
}
|
73 |
+
$ch = curl_init($Url);
|
74 |
+
curl_setopt($ch, CURLOPT_HEADER, true); // we want headers
|
75 |
+
curl_setopt($ch, CURLOPT_NOBODY, true); // we don't need body
|
76 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
77 |
+
curl_setopt($ch, CURLOPT_TIMEOUT,10);
|
78 |
+
$output = curl_exec($ch);
|
79 |
+
curl_close($ch);
|
80 |
+
|
81 |
+
return $output;
|
82 |
+
}
|
83 |
+
}
|
app/code/local/EasyAsk/Search/controllers/Adminhtml/Search/System/Config/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/controllers/IndexController.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Search_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Returns generated Products CSV file
|
6 |
+
*/
|
7 |
+
public function productsListAction()
|
8 |
+
{
|
9 |
+
$filename = 'eae_products.csv';
|
10 |
+
$content = Mage::helper('easyask_search/eae')->generateEaeProductsList();
|
11 |
+
|
12 |
+
$this->_prepareDownloadResponse($filename, $content);
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Returns generated Catagory CSV file
|
17 |
+
*/
|
18 |
+
public function categoryListAction()
|
19 |
+
{
|
20 |
+
$filename = 'eae_categories.csv';
|
21 |
+
$content = Mage::helper('easyask_search/eae')->generateEaeCategoriesList();
|
22 |
+
|
23 |
+
$this->_prepareDownloadResponse($filename, $content);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Returns generated Attribute CSV file
|
28 |
+
*/
|
29 |
+
public function attributeListAction()
|
30 |
+
{
|
31 |
+
$filename = 'eae_attributes.csv';
|
32 |
+
$content = Mage::helper('easyask_search/eae')->generateEaeAttributesList();
|
33 |
+
|
34 |
+
$this->_prepareDownloadResponse($filename, $content);
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Returns generated Product Attribute CSV file
|
39 |
+
*/
|
40 |
+
public function productAttributeListAction()
|
41 |
+
{
|
42 |
+
$filename = 'eae_productAttributes.csv';
|
43 |
+
$content = Mage::helper('easyask_search/eae')->generateEaeProductAttributesList();
|
44 |
+
|
45 |
+
$this->_prepareDownloadResponse($filename, $content);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Returns generated Category Products CSV file
|
50 |
+
*/
|
51 |
+
public function categoryProductsListAction()
|
52 |
+
{
|
53 |
+
$filename = 'eae_categoryProducts.csv';
|
54 |
+
$content = Mage::helper('easyask_search/eae')->generateEaeCategoryProductsList();
|
55 |
+
|
56 |
+
$this->_prepareDownloadResponse($filename, $content);
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
app/code/local/EasyAsk/Search/controllers/ResultController.php
ADDED
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once('Mage/CatalogSearch/controllers/ResultController.php');
|
4 |
+
|
5 |
+
class EasyAsk_Search_ResultController extends Mage_CatalogSearch_ResultController
|
6 |
+
{
|
7 |
+
protected $_helper = null;
|
8 |
+
|
9 |
+
public function getHelper() {
|
10 |
+
if ($this->_helper === null) {
|
11 |
+
$this->_helper = Mage::helper('easyask_search');
|
12 |
+
}
|
13 |
+
return $this->_helper;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function indexAction()
|
17 |
+
{
|
18 |
+
$queryText = Mage::helper('catalogsearch')->getQueryText();
|
19 |
+
$bc = $this->getRequest()->getParam('ea_bc', '');
|
20 |
+
$eapath = $this->getRequest()->getParam('ea_path', '');
|
21 |
+
$eacat = $this->getRequest()->getParam('ea_c', '');
|
22 |
+
|
23 |
+
$groupId = "";
|
24 |
+
$login = Mage::getSingleton( 'customer/session' )->isLoggedIn(); //Check if User is Logged In
|
25 |
+
if($login){
|
26 |
+
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); //Get Customers Group ID
|
27 |
+
}
|
28 |
+
|
29 |
+
$cache = Mage::app()->getCache();
|
30 |
+
|
31 |
+
$query = Mage::helper('catalogsearch')->getQuery();
|
32 |
+
/* @var $query Mage_CatalogSearch_Model_Query */
|
33 |
+
|
34 |
+
$searchEngine = Mage::getStoreConfig('catalog/search/engine');
|
35 |
+
|
36 |
+
$query->setStoreId(Mage::app()->getStore()->getId());
|
37 |
+
|
38 |
+
if (strcasecmp($searchEngine, 'easyask_search/engine') === 0 ){//&& ($queryText != '' || $bc != '' || $eapath != '' || $eacat != '')) {
|
39 |
+
|
40 |
+
if (Mage::helper('catalogsearch')->isMinQueryLength()) {
|
41 |
+
$query->setId(0)
|
42 |
+
->setIsActive(1)
|
43 |
+
->setIsProcessed(1);
|
44 |
+
}
|
45 |
+
else {
|
46 |
+
if ($query->getId()) {
|
47 |
+
$query->setPopularity($query->getPopularity()+1);
|
48 |
+
}
|
49 |
+
else {
|
50 |
+
$query->setPopularity(1);
|
51 |
+
}
|
52 |
+
|
53 |
+
if ($query->getRedirect()){
|
54 |
+
$query->save();
|
55 |
+
$this->getResponse()->setRedirect($query->getRedirect());
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
else {
|
59 |
+
$query->prepare();
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
$mode = $this->getRequest()->getParam('mode', 'grid');
|
64 |
+
$limit = $this->getRequest()->getParam('limit', 0);
|
65 |
+
$page = $this->getRequest()->getParam('p');
|
66 |
+
$order = $this->getRequest()->getParam('order', 'relevance');
|
67 |
+
$dir = $this->getRequest()->getParam('dir', 'asc');
|
68 |
+
$attribSel = $this->getRequest()->getParam('ea_a', '');
|
69 |
+
|
70 |
+
$event_data_array = array(
|
71 |
+
'relevance' => 'relevance',
|
72 |
+
'name' => 'Product Name',
|
73 |
+
'price' => 'Price'
|
74 |
+
);
|
75 |
+
$varien_object = new Varien_Object($event_data_array);
|
76 |
+
Mage::dispatchEvent('catalog_controller_sortmap_update_set', array('varien_obj'=>$varien_object));
|
77 |
+
|
78 |
+
$attributeToColumn = $varien_object->getData();
|
79 |
+
|
80 |
+
if ($limit !== 'all' && $limit == 0){
|
81 |
+
$limit = Mage::getSingleton('catalog/session')->getLimitPage();
|
82 |
+
}
|
83 |
+
|
84 |
+
$rpp = 0;
|
85 |
+
if ($mode == 'grid'){
|
86 |
+
$rpp = ($limit === 0) ? Mage::getStoreConfig('catalog/frontend/grid_per_page') : $limit;
|
87 |
+
} else {
|
88 |
+
$rpp = ($limit === 0) ? Mage::getStoreConfig('catalog/frontend/list_per_page') : $limit;
|
89 |
+
}
|
90 |
+
|
91 |
+
Varien_Profiler::start('EASYASK::searchrequest1');
|
92 |
+
|
93 |
+
// The call to create a RemoteEasyAsk object that allows you to access the remote server
|
94 |
+
// to get the resultset of the search. We need to to provide the server and port information
|
95 |
+
//$ea = EasyAsk_Impl_RemoteFactory::create("75.150.81.116", 9120, "magento16");
|
96 |
+
|
97 |
+
$eahostname = Mage::getStoreConfig('catalog/search/ea_server_hostname');
|
98 |
+
$eaport = Mage::getStoreConfig('catalog/search/ea_server_port');
|
99 |
+
$eadictionary = Mage::getStoreConfig('catalog/search/ea_dictionary');
|
100 |
+
|
101 |
+
if ($eahostname == '' || $eadictionary == ''){
|
102 |
+
throw new Exception("To use easyask search engine you need to specify the host name, port and dictionary in catalog search configuration screen in admin console.");
|
103 |
+
}
|
104 |
+
|
105 |
+
$ea = EasyAsk_Impl_RemoteFactory::create($eahostname, $eaport, $eadictionary);
|
106 |
+
|
107 |
+
$opts = $ea->getOptions();
|
108 |
+
$opts->setResultsPerPage($rpp);
|
109 |
+
$opts->setGrouping("");
|
110 |
+
// $opts->setToplevelProducts(true);
|
111 |
+
$opts->setNavigateHierarchy(false);
|
112 |
+
$opts->setSubCategories(false);
|
113 |
+
$opts->setGroupId($groupId);
|
114 |
+
$opts->setCustomerId("");
|
115 |
+
//$opts->setCallOutParam("&eap_PriceCode=1");
|
116 |
+
|
117 |
+
// Set sort field and direction
|
118 |
+
if ($order != 'relevance') {
|
119 |
+
$opts->setSortOrder($attributeToColumn[$order] . ',' . ($dir == 'asc' ? 't' : 'f'));
|
120 |
+
}
|
121 |
+
|
122 |
+
if ($page){
|
123 |
+
$res = $ea->userGoToPage($eapath, $page);
|
124 |
+
}else if (strlen($attribSel) > 0){
|
125 |
+
$attrtype = substr($attribSel, 0, strpos($attribSel, ':'));
|
126 |
+
$eapatharr = explode('/', $eapath);
|
127 |
+
|
128 |
+
for($i = 0; sizeof($eapatharr) > $i; $i++){
|
129 |
+
if (!(strpos($eapatharr[$i], $attrtype . ':') === false)){
|
130 |
+
$attribSel = $eapatharr[$i] . ';' . $attribSel;
|
131 |
+
unset($eapatharr[$i]);
|
132 |
+
}
|
133 |
+
$eapath = implode('/', $eapatharr);
|
134 |
+
}
|
135 |
+
|
136 |
+
$res = $ea->userAttributeClick($eapath, $attribSel);
|
137 |
+
|
138 |
+
$catPath = $this->getHelper()->getCatPath($res);
|
139 |
+
if (strlen($catPath) > 0){
|
140 |
+
$this->getHelper()->updateCachedAttributes($res->getOriginalQuestionAsked(). '-'.$catPath,$res->getAttributeNamesFull(), $res, $cache);
|
141 |
+
$this->getHelper()->updateCachedAttributes($res->getOriginalQuestionAsked(). '-'.$catPath,$res->getCommonAttributeNames(true), $res, $cache);
|
142 |
+
}else{
|
143 |
+
$this->getHelper()->updateCachedAttributes($queryText,$res->getAttributeNamesFull(), $res, $cache);
|
144 |
+
$this->getHelper()->updateCachedAttributes($queryText,$res->getCommonAttributeNames(true), $res, $cache);
|
145 |
+
}
|
146 |
+
}else if (strlen($eacat) > 0){
|
147 |
+
$res = $ea->userCategoryClick($eapath, $eacat);
|
148 |
+
$catPath = $this->getHelper()->getCatPath($res);
|
149 |
+
$this->getHelper()->updateCachedAttributes($res->getOriginalQuestionAsked(). '-'.$catPath,$res->getAttributeNamesFull(), $res, $cache);
|
150 |
+
$this->getHelper()->updateCachedAttributes($res->getOriginalQuestionAsked(). '-'.$catPath,$res->getCommonAttributeNames(true), $res, $cache);
|
151 |
+
}else if (strlen($bc) > 0){
|
152 |
+
$res = $ea->userBreadCrumbClick($bc);
|
153 |
+
|
154 |
+
$catPath = $this->getHelper()->getCatPath($res);
|
155 |
+
if (strlen($catPath) > 0){
|
156 |
+
$this->getHelper()->updateCachedAttributes($queryText. '-'.$catPath,$res->getAttributeNamesFull(), $res, $cache);
|
157 |
+
$this->getHelper()->updateCachedAttributes($queryText. '-'.$catPath,$res->getCommonAttributeNames(true), $res, $cache);
|
158 |
+
}else{
|
159 |
+
$this->getHelper()->updateCachedAttributes($queryText,$res->getAttributeNamesFull(), $res, $cache);
|
160 |
+
$this->getHelper()->updateCachedAttributes($queryText,$res->getCommonAttributeNames(true), $res, $cache);
|
161 |
+
}
|
162 |
+
}else{
|
163 |
+
$res = $ea->userSearch($eapath, $queryText);
|
164 |
+
$this->getHelper()->cacheAttributes($res->getOriginalQuestion(), $res, $cache);
|
165 |
+
}
|
166 |
+
|
167 |
+
|
168 |
+
Varien_Profiler::stop('EASYASK::searchrequest1');
|
169 |
+
|
170 |
+
if ($res->isRedirect()) {
|
171 |
+
$this->getResponse()->setRedirect($res->getRedirect());
|
172 |
+
return;
|
173 |
+
}
|
174 |
+
|
175 |
+
if($res->getReturnCode() == -1 || $res->getTotalItems() == -1){
|
176 |
+
Mage::helper('catalogsearch')->setNoteMessages(array($res->getErrorMsg()));
|
177 |
+
$this->getResponse()->setRedirect(Mage::getBaseUrl() . 'no_results');
|
178 |
+
return;
|
179 |
+
}else{
|
180 |
+
Varien_Profiler::start('EASYASK::searchrequest2');
|
181 |
+
|
182 |
+
//Check to see if the response has only one item in which case we redirect to the product page
|
183 |
+
if ((Mage::getStoreConfig('catalog/search/auto_redirect') == 1) && $res->getTotalItems() === 1){
|
184 |
+
$this->getResponse()->setRedirect(Mage::getBaseUrl() . $res->getCellData(0, $res->getColumnIndex('Url Path')));
|
185 |
+
}
|
186 |
+
|
187 |
+
$path = $res->getCatPath();
|
188 |
+
|
189 |
+
$commentary = $res->getCommentary();
|
190 |
+
$originalQuestion = $res->getOriginalQuestion();
|
191 |
+
|
192 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
193 |
+
|
194 |
+
if (($res->getReturnCode() == -1) && (count($searchPath) === 0)){
|
195 |
+
throw new Exception("The search yields no results. Please try again later.");
|
196 |
+
}
|
197 |
+
|
198 |
+
// $realSearchQuery = $originalQuestion != '' ? $originalQuestion : $searchPath[count($searchPath) - 1]->getValue();
|
199 |
+
$realSearchQuery = isset($searchPath[1]) ? $searchPath[1]->getValue() : $originalQuestion;
|
200 |
+
|
201 |
+
Mage::register('ea_result', $res);
|
202 |
+
|
203 |
+
|
204 |
+
|
205 |
+
if (strpos($commentary, 'Ignored:') !== false || strpos($commentary, 'Corrected Word:') !== false) {
|
206 |
+
Mage::helper('catalogsearch')->setNoteMessages(array(
|
207 |
+
sprintf("We found no results for '%s' but you may find the following results relevant:", $originalQuestion)
|
208 |
+
));
|
209 |
+
}
|
210 |
+
|
211 |
+
Varien_Profiler::stop('EASYASK::searchrequest2');
|
212 |
+
|
213 |
+
}
|
214 |
+
$this->loadLayout();
|
215 |
+
$this->_initLayoutMessages('catalog/session');
|
216 |
+
$this->_initLayoutMessages('checkout/session');
|
217 |
+
|
218 |
+
if (isset($realSearchQuery)){
|
219 |
+
$searchTitle = sprintf("Search results for '%s'", $realSearchQuery);
|
220 |
+
$this->getLayout()->getBlock('head')->setTitle($searchTitle);
|
221 |
+
$this->getLayout()->getBlock('search.result')->setHeaderText($searchTitle);
|
222 |
+
}
|
223 |
+
|
224 |
+
$this->renderLayout();
|
225 |
+
|
226 |
+
if (!Mage::helper('catalogsearch')->isMinQueryLength()) {
|
227 |
+
$query->save();
|
228 |
+
}
|
229 |
+
} else {
|
230 |
+
$this->_redirectReferer();
|
231 |
+
}
|
232 |
+
|
233 |
+
}
|
234 |
+
|
235 |
+
private function isOnlyAttribute($res){
|
236 |
+
$numAttrs = 0;
|
237 |
+
$numCategories = 0;
|
238 |
+
$searchPath = $res->getBreadCrumbTrail()->getSearchPath();
|
239 |
+
foreach ($searchPath as $path){
|
240 |
+
if ($path->getType() == 2){
|
241 |
+
$numAttrs += 1;
|
242 |
+
}
|
243 |
+
if($path->getType() == 1){
|
244 |
+
$numCategories +=1;
|
245 |
+
}
|
246 |
+
}
|
247 |
+
if (($numAttrs == 1) && !($numCategories > 1)){
|
248 |
+
return true;
|
249 |
+
}
|
250 |
+
return false;
|
251 |
+
}
|
252 |
+
|
253 |
+
}
|
app/code/local/EasyAsk/Search/controllers/vssver.scc
ADDED
Binary file
|
app/code/local/EasyAsk/Search/etc/attrib.xml
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<attrib>
|
3 |
+
<field>accessories_type</field>
|
4 |
+
<field>apparel_type</field>
|
5 |
+
<field>author_artist</field>
|
6 |
+
<field>bag_luggage_type</field>
|
7 |
+
<field>bedding_pattern</field>
|
8 |
+
<field>bed_bath_type</field>
|
9 |
+
<field>books_music_type</field>
|
10 |
+
<field>camera_megapixels</field>
|
11 |
+
<field>camera_type</field>
|
12 |
+
<field>color</field>
|
13 |
+
<field>country_of_manufacture</field>
|
14 |
+
<field>created_at</field>
|
15 |
+
<field>decor_type</field>
|
16 |
+
<field>description</field>
|
17 |
+
<field>electronic_type</field>
|
18 |
+
<field>fit</field>
|
19 |
+
<field>format</field>
|
20 |
+
<field>gender</field>
|
21 |
+
<field>genre</field>
|
22 |
+
<field>has_options</field>
|
23 |
+
<field>homeware_style</field>
|
24 |
+
<field>home_decor_type</field>
|
25 |
+
<field>image</field>
|
26 |
+
<field>is_recurring</field>
|
27 |
+
<field>jewelry_type</field>
|
28 |
+
<field>length</field>
|
29 |
+
<field>links_exist</field>
|
30 |
+
<field>links_purchased_separately</field>
|
31 |
+
<field>links_title</field>
|
32 |
+
<field>luggage_size</field>
|
33 |
+
<field>luggage_style</field>
|
34 |
+
<field>luggage_travel_style</field>
|
35 |
+
<field>material</field>
|
36 |
+
<field>media_gallery</field>
|
37 |
+
<field>msrp</field>
|
38 |
+
<field>msrp_display_actual_price_type</field>
|
39 |
+
<field>msrp_enabled</field>
|
40 |
+
<field>name</field>
|
41 |
+
<field>necklace_length</field>
|
42 |
+
<field>occasion</field>
|
43 |
+
<field>options_container</field>
|
44 |
+
<field>page_layout</field>
|
45 |
+
<field>price</field>
|
46 |
+
<field>price_type</field>
|
47 |
+
<field>price_view</field>
|
48 |
+
<field>recurring_profile</field>
|
49 |
+
<field>required_options</field>
|
50 |
+
<field>samples_title</field>
|
51 |
+
<field>shipment_type</field>
|
52 |
+
<field>shoe_size</field>
|
53 |
+
<field>shoe_type</field>
|
54 |
+
<field>short_description</field>
|
55 |
+
<field>size</field>
|
56 |
+
<field>sku</field>
|
57 |
+
<field>sku_type</field>
|
58 |
+
<field>sleeve_length</field>
|
59 |
+
<field>small_image</field>
|
60 |
+
<field>small_image_label</field>
|
61 |
+
<field>status</field>
|
62 |
+
<field>style</field>
|
63 |
+
<field>tax_class_id</field>
|
64 |
+
<field>thumbnail</field>
|
65 |
+
<field>updated_at</field>
|
66 |
+
<field>url_key</field>
|
67 |
+
<field>url_path</field>
|
68 |
+
<field>visibility</field>
|
69 |
+
<field>weight</field>
|
70 |
+
<field>weight_type</field>
|
71 |
+
<field>width</field>
|
72 |
+
</attrib>
|
app/code/local/EasyAsk/Search/etc/config.xml
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<EasyAsk_Search>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</EasyAsk_Search>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<frontend>
|
10 |
+
|
11 |
+
<routers>
|
12 |
+
<catalogsearch>
|
13 |
+
<args>
|
14 |
+
<modules>
|
15 |
+
<EasyAsk_Search before="Mage_CatalogSearch">EasyAsk_Search</EasyAsk_Search>
|
16 |
+
</modules>
|
17 |
+
</args>
|
18 |
+
</catalogsearch>
|
19 |
+
</routers>
|
20 |
+
|
21 |
+
<routers>
|
22 |
+
<easyask_search>
|
23 |
+
<use>standard</use>
|
24 |
+
<args>
|
25 |
+
<module>EasyAsk_Search</module>
|
26 |
+
<frontName>eae</frontName>
|
27 |
+
</args>
|
28 |
+
</easyask_search>
|
29 |
+
</routers>
|
30 |
+
|
31 |
+
<layout>
|
32 |
+
<updates>
|
33 |
+
<easyask_search>
|
34 |
+
<file>easyask/easyask.xml</file>
|
35 |
+
</easyask_search>
|
36 |
+
</updates>
|
37 |
+
</layout>
|
38 |
+
|
39 |
+
</frontend>
|
40 |
+
|
41 |
+
<global>
|
42 |
+
|
43 |
+
<models>
|
44 |
+
|
45 |
+
<easyask_search>
|
46 |
+
<class>EasyAsk_Search_Model</class>
|
47 |
+
</easyask_search>
|
48 |
+
|
49 |
+
<catalogsearch_resource>
|
50 |
+
<rewrite>
|
51 |
+
<fulltext_collection>EasyAsk_Search_Model_Resource_CatalogSearch_Fulltext_Collection</fulltext_collection>
|
52 |
+
</rewrite>
|
53 |
+
</catalogsearch_resource>
|
54 |
+
<catalog_resource>
|
55 |
+
<rewrite>
|
56 |
+
<product_collection>EasyAsk_Search_Model_Resource_Catalog_Product_Collection</product_collection>
|
57 |
+
</rewrite>
|
58 |
+
</catalog_resource>
|
59 |
+
|
60 |
+
<catalog>
|
61 |
+
<rewrite>
|
62 |
+
<layer>EasyAsk_Search_Model_Catalog_Layer</layer>
|
63 |
+
<layer_filter_attribute>EasyAsk_Search_Model_Catalog_Layer_Filter_Attribute</layer_filter_attribute>
|
64 |
+
<layer_filter_item>EasyAsk_Search_Model_Catalog_Layer_Filter_Item</layer_filter_item>
|
65 |
+
<layer_filter_category>EasyAsk_Search_Model_Catalog_Layer_Filter_Category</layer_filter_category>
|
66 |
+
</rewrite>
|
67 |
+
</catalog>
|
68 |
+
|
69 |
+
<catalogsearch>
|
70 |
+
<rewrite>
|
71 |
+
<layer_filter_attribute>EasyAsk_Search_Model_CatalogSearch_Layer_Filter_Attribute</layer_filter_attribute>
|
72 |
+
<layer>EasyAsk_Search_Model_CatalogSearch_Layer</layer>
|
73 |
+
</rewrite>
|
74 |
+
</catalogsearch>
|
75 |
+
|
76 |
+
</models>
|
77 |
+
|
78 |
+
<helpers>
|
79 |
+
|
80 |
+
<easyask_search>
|
81 |
+
<class>EasyAsk_Search_Helper</class>
|
82 |
+
</easyask_search>
|
83 |
+
|
84 |
+
<!--<catalog>
|
85 |
+
<rewrite>
|
86 |
+
<category>EasyAsk_Search_Helper_Category</category>
|
87 |
+
</rewrite>
|
88 |
+
</catalog>-->
|
89 |
+
|
90 |
+
</helpers>
|
91 |
+
|
92 |
+
<blocks>
|
93 |
+
|
94 |
+
<easyask_search>
|
95 |
+
<class>EasyAsk_Search_Block</class>
|
96 |
+
</easyask_search>
|
97 |
+
|
98 |
+
<catalog>
|
99 |
+
<rewrite>
|
100 |
+
<product_list>EasyAsk_Search_Block_Catalog_Product_List</product_list>
|
101 |
+
<product_list_toolbar>EasyAsk_Search_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
|
102 |
+
<layer_state>EasyAsk_Search_Block_Catalog_Layer_State</layer_state>
|
103 |
+
<layer_view>EasyAsk_Search_Block_Catalog_Layer</layer_view>
|
104 |
+
<layer_filter_attribute>EasyAsk_Search_Block_Catalog_Layer_Filter_Attribute</layer_filter_attribute>
|
105 |
+
<breadcrumbs>EasyAsk_Search_Block_Catalog_Breadcrumbs</breadcrumbs>
|
106 |
+
</rewrite>
|
107 |
+
</catalog>
|
108 |
+
|
109 |
+
<catalogsearch>
|
110 |
+
<rewrite>
|
111 |
+
<layer_filter_attribute>EasyAsk_Search_Block_CatalogSearch_Layer_Filter_Attribute</layer_filter_attribute>
|
112 |
+
<layer>EasyAsk_Search_Block_CatalogSearch_Layer</layer>
|
113 |
+
<result>EasyAsk_Search_Block_CatalogSearch_Result</result>
|
114 |
+
</rewrite>
|
115 |
+
</catalogsearch>
|
116 |
+
|
117 |
+
<page>
|
118 |
+
<rewrite>
|
119 |
+
<html_pager>EasyAsk_Search_Block_Html_Pager</html_pager>
|
120 |
+
</rewrite>
|
121 |
+
</page>
|
122 |
+
|
123 |
+
</blocks>
|
124 |
+
|
125 |
+
<events>
|
126 |
+
|
127 |
+
<catalog_controller_category_init_after>
|
128 |
+
<observers>
|
129 |
+
<easyask_search_catalog_controller_category_init_after>
|
130 |
+
<type>singleton</type>
|
131 |
+
<class>easyask_search/observer</class>
|
132 |
+
<method>catalogControllerCategoryInitAfter</method>
|
133 |
+
</easyask_search_catalog_controller_category_init_after>
|
134 |
+
</observers>
|
135 |
+
</catalog_controller_category_init_after>
|
136 |
+
|
137 |
+
</events>
|
138 |
+
|
139 |
+
</global>
|
140 |
+
|
141 |
+
<admin>
|
142 |
+
<routers>
|
143 |
+
<adminhtml>
|
144 |
+
<args>
|
145 |
+
<modules>
|
146 |
+
<easyask_search before="Mage_Adminhtml">EasyAsk_Search_Adminhtml</easyask_search>
|
147 |
+
</modules>
|
148 |
+
</args>
|
149 |
+
</adminhtml>
|
150 |
+
</routers>
|
151 |
+
</admin>
|
152 |
+
|
153 |
+
<default>
|
154 |
+
<catalog>
|
155 |
+
<layered_navigation>
|
156 |
+
<ea_multiselect>1</ea_multiselect>
|
157 |
+
</layered_navigation>
|
158 |
+
</catalog>
|
159 |
+
</default>
|
160 |
+
|
161 |
+
</config>
|
app/code/local/EasyAsk/Search/etc/system.xml
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento Enterprise Edition
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Magento Enterprise Edition License
|
9 |
+
* that is bundled with this package in the file LICENSE_EE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.magentocommerce.com/license/enterprise-edition
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Enterprise
|
23 |
+
* @package Enterprise_Search
|
24 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
25 |
+
* @license http://www.magentocommerce.com/license/enterprise-edition
|
26 |
+
*/
|
27 |
+
-->
|
28 |
+
<config>
|
29 |
+
<sections>
|
30 |
+
<catalog>
|
31 |
+
<groups>
|
32 |
+
<search>
|
33 |
+
<fields>
|
34 |
+
<auto_redirect translate="label">
|
35 |
+
<label>Auto Redirect to Product Detail Page</label>
|
36 |
+
<frontend_type>select</frontend_type>
|
37 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
38 |
+
<sort_order>18</sort_order>
|
39 |
+
<show_in_default>1</show_in_default>
|
40 |
+
</auto_redirect>
|
41 |
+
<engine translate="label">
|
42 |
+
<label>Search Engine</label>
|
43 |
+
<frontend_type>select</frontend_type>
|
44 |
+
<backend_model>easyask_search/adminhtml_system_config_backend_engine</backend_model>
|
45 |
+
<source_model>easyask_search/adminhtml_system_config_source_engine</source_model>
|
46 |
+
<sort_order>19</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>0</show_in_website>
|
49 |
+
<show_in_store>0</show_in_store>
|
50 |
+
</engine>
|
51 |
+
<ea_server_hostname translate="label">
|
52 |
+
<label>EasyAsk Server Hostname</label>
|
53 |
+
<frontend_type>text</frontend_type>
|
54 |
+
<sort_order>51</sort_order>
|
55 |
+
<show_in_default>1</show_in_default>
|
56 |
+
<show_in_website>0</show_in_website>
|
57 |
+
<show_in_store>0</show_in_store>
|
58 |
+
<depends><engine>easyask_search/engine</engine></depends>
|
59 |
+
</ea_server_hostname>
|
60 |
+
<ea_server_port translate="label">
|
61 |
+
<label>EasyAsk Server Port</label>
|
62 |
+
<frontend_type>text</frontend_type>
|
63 |
+
<sort_order>52</sort_order>
|
64 |
+
<show_in_default>1</show_in_default>
|
65 |
+
<show_in_website>0</show_in_website>
|
66 |
+
<show_in_store>0</show_in_store>
|
67 |
+
<depends><engine>easyask_search/engine</engine></depends>
|
68 |
+
</ea_server_port>
|
69 |
+
<ea_dictionary translate="label">
|
70 |
+
<label>EasyAsk Dictionary</label>
|
71 |
+
<frontend_type>text</frontend_type>
|
72 |
+
<sort_order>53</sort_order>
|
73 |
+
<show_in_default>1</show_in_default>
|
74 |
+
<show_in_website>0</show_in_website>
|
75 |
+
<show_in_store>0</show_in_store>
|
76 |
+
<depends><engine>easyask_search/engine</engine></depends>
|
77 |
+
</ea_dictionary>
|
78 |
+
<ea_test_connect_wizard translate="button_label">
|
79 |
+
<label></label>
|
80 |
+
<button_label>Test Connection</button_label>
|
81 |
+
<frontend_model>easyask_search/adminhtml_system_config_testconnection</frontend_model>
|
82 |
+
<sort_order>58</sort_order>
|
83 |
+
<show_in_default>1</show_in_default>
|
84 |
+
<show_in_website>0</show_in_website>
|
85 |
+
<show_in_store>0</show_in_store>
|
86 |
+
<depends><engine>easyask_search/engine</engine></depends>
|
87 |
+
</ea_test_connect_wizard>
|
88 |
+
<search_type>
|
89 |
+
<depends><engine>catalogsearch/fulltext_engine</engine></depends>
|
90 |
+
</search_type>
|
91 |
+
<use_layered_navigation_count>
|
92 |
+
<depends><engine>catalogsearch/fulltext_engine</engine></depends>
|
93 |
+
</use_layered_navigation_count>
|
94 |
+
</fields>
|
95 |
+
</search>
|
96 |
+
<navigation translate="label">
|
97 |
+
<fields>
|
98 |
+
<use_easyask translate="label">
|
99 |
+
<label>Use EasyAsk Navigation</label>
|
100 |
+
<frontend_type>select</frontend_type>
|
101 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
102 |
+
<sort_order>1</sort_order>
|
103 |
+
<show_in_default>1</show_in_default>
|
104 |
+
</use_easyask>
|
105 |
+
</fields>
|
106 |
+
</navigation>
|
107 |
+
|
108 |
+
<layered_navigation translate="label">
|
109 |
+
<fields>
|
110 |
+
<ea_multiselect translate="label">
|
111 |
+
<label>Use Multi-attribute Selection</label>
|
112 |
+
<frontend_type>select</frontend_type>
|
113 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
114 |
+
<sort_order>54</sort_order>
|
115 |
+
<show_in_default>1</show_in_default>
|
116 |
+
</ea_multiselect>
|
117 |
+
</fields>
|
118 |
+
</layered_navigation>
|
119 |
+
|
120 |
+
<frontend translate="label">
|
121 |
+
<fields>
|
122 |
+
<use_magento_db translate="label">
|
123 |
+
<label>Use Mageto DB to Load Product Collections</label>
|
124 |
+
<frontend_type>select</frontend_type>
|
125 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
126 |
+
<sort_order>100</sort_order>
|
127 |
+
<show_in_default>1</show_in_default>
|
128 |
+
</use_magento_db>
|
129 |
+
</fields>
|
130 |
+
</frontend>
|
131 |
+
|
132 |
+
</groups>
|
133 |
+
</catalog>
|
134 |
+
</sections>
|
135 |
+
</config>
|
app/code/local/EasyAsk/Search/etc/vssver.scc
ADDED
Binary file
|
app/design/adminhtml/default/default/template/easyask/search/js.phtml
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento Enterprise Edition
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Magento Enterprise Edition License
|
8 |
+
* that is bundled with this package in the file LICENSE_EE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.magentocommerce.com/license/enterprise-edition
|
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 design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://www.magentocommerce.com/license/enterprise-edition
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
if ($this->isThirdPartSearchEngine()) :?>
|
29 |
+
<script type="text/javascript">
|
30 |
+
//<![CDATA[
|
31 |
+
function checkIsSearchWeightVisibility()
|
32 |
+
{
|
33 |
+
if ($F('is_searchable')==1) {
|
34 |
+
setRowVisibility('search_weight', true);
|
35 |
+
} else {
|
36 |
+
setRowVisibility('search_weight', false);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
checkIsSearchWeightVisibility();
|
40 |
+
if($('frontend_input')){
|
41 |
+
Event.observe($('is_searchable'), 'change', checkIsSearchWeightVisibility);
|
42 |
+
}
|
43 |
+
//]]>
|
44 |
+
</script>
|
45 |
+
<?php endif;?>
|
app/design/adminhtml/default/default/template/easyask/search/system/config/testconnection.phtml
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento Enterprise Edition
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Magento Enterprise Edition License
|
8 |
+
* that is bundled with this package in the file LICENSE_EE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.magentocommerce.com/license/enterprise-edition
|
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 design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://www.magentocommerce.com/license/enterprise-edition
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
/**http://localhost:8983/solr/admin/ping
|
29 |
+
* @see Mage_Paypal_Block_Adminhtml_System_Config_ApiWizard
|
30 |
+
*/
|
31 |
+
?>
|
32 |
+
<script type="text/javascript">
|
33 |
+
function testConnection() {
|
34 |
+
var elem = $('<?php echo $this->getHtmlId() ?>');
|
35 |
+
|
36 |
+
params = {
|
37 |
+
host: $('catalog_search_ea_server_hostname').value,
|
38 |
+
port: $('catalog_search_ea_server_port').value,
|
39 |
+
dictionary: $('catalog_search_ea_dictionary').value
|
40 |
+
};
|
41 |
+
|
42 |
+
new Ajax.Request('<?php echo $this->getAjaxUrl() ?>', {
|
43 |
+
parameters: params,
|
44 |
+
onSuccess: function(response) {
|
45 |
+
result = '<?php echo $this->__('Connection failed! Test again?') ?>';
|
46 |
+
try {
|
47 |
+
response = response.responseText;
|
48 |
+
if (response == 1) {
|
49 |
+
result = '<?php echo $this->__('Successful! Test again?') ?>';
|
50 |
+
elem.removeClassName('fail').addClassName('success')
|
51 |
+
} else {
|
52 |
+
elem.removeClassName('success').addClassName('fail')
|
53 |
+
}
|
54 |
+
} catch (e) {
|
55 |
+
elem.removeClassName('success').addClassName('fail')
|
56 |
+
}
|
57 |
+
$('connection_test_result').update(result);
|
58 |
+
}
|
59 |
+
});
|
60 |
+
}
|
61 |
+
</script>
|
62 |
+
<button onclick="javascript:testConnection(); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>">
|
63 |
+
<span id="connection_test_result"><?php echo $this->escapeHtml($this->getButtonLabel()) ?></span>
|
64 |
+
</button>
|
app/design/adminhtml/default/default/template/easyask/search/system/config/vssver.scc
ADDED
Binary file
|
app/design/adminhtml/default/default/template/easyask/search/vssver.scc
ADDED
Binary file
|
app/design/frontend/base/default/template/catalog/layer/filter.phtml
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-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 design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Template for filter items block
|
31 |
+
*
|
32 |
+
* @see Mage_Catalog_Block_Layer_Filter
|
33 |
+
*/
|
34 |
+
?>
|
35 |
+
|
36 |
+
<ol>
|
37 |
+
<?php
|
38 |
+
|
39 |
+
$searchEngine = Mage::getStoreConfig ( 'catalog/search/engine' );
|
40 |
+
$useEA = Mage::getStoreConfig ( 'catalog/navigation/use_easyask' );
|
41 |
+
if ((strcasecmp ( $searchEngine, 'easyask_search/engine' ) === 0 && $useEA) || (strcasecmp ( $searchEngine, 'easyask_search/engine' ) === 0 && $this->getRequest()->getControllerName() == 'result')) {
|
42 |
+
|
43 |
+
$displaySize = $this->getIsInitDisplayLimited ();
|
44 |
+
$i = 0;
|
45 |
+
$filterName = strtolower ( $this->getName () );
|
46 |
+
$cnt = count ( $this->getItems () );
|
47 |
+
|
48 |
+
$shortListItems;
|
49 |
+
$longListItems;
|
50 |
+
if ($displaySize > 0) {
|
51 |
+
$shortListItems = array_slice ( $this->getItems (), 0, $displaySize );
|
52 |
+
$longListItems = array_slice ( $this->getItems (), $displaySize );
|
53 |
+
} else {
|
54 |
+
$longListItems = $this->getItems ();
|
55 |
+
}
|
56 |
+
|
57 |
+
if ($displaySize > 0) {
|
58 |
+
?>
|
59 |
+
|
60 |
+
<div ea_id="short-<?php echo $filterName?>">
|
61 |
+
|
62 |
+
<?php foreach ($shortListItems as $_item): ?>
|
63 |
+
|
64 |
+
<li>
|
65 |
+
<?php if (($_item->getFilter()->getRequestVar() != 'cat') && (($this->getRequest()->getControllerName() == 'result') || ($this->getRequest()->getControllerName() == 'category'))): ?>
|
66 |
+
<input type="checkbox" id="<?php echo $_item->getUniqueId() ?>"
|
67 |
+
value="<?php echo $_item->getValue() ?>"
|
68 |
+
<?php if ($_item->getIsChecked()): ?> checked="checked"
|
69 |
+
<?php endif; ?> <?php if ($_item->getIsDisabled()): ?>
|
70 |
+
disabled="disabled" <?php endif; ?>
|
71 |
+
onClick="setLocation('<?php echo $this->urlEscape($_item->getIsChecked() ? $_item->getRemoveUrl() : $_item->getUrl()) ?>');" />
|
72 |
+
<?php if ($_item->getImageURL()): ?><img
|
73 |
+
src=<?php echo $_item->getImageURL() ?>><?php endif; ?>
|
74 |
+
<label for="<?php echo $_item->getUniqueId() ?>"> <span
|
75 |
+
<?php if ($_item->getMSelected()): ?>
|
76 |
+
class="m-selected-checkbox-item" <?php endif; ?>>
|
77 |
+
<?php echo $_item->getLabel() ?></span></label>
|
78 |
+
<?php else: ?>
|
79 |
+
<a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
|
80 |
+
<?php endif; ?>
|
81 |
+
<?php if ($_item->getCount() > 0): ?>
|
82 |
+
(<?php echo $_item->getCount() ?>)
|
83 |
+
<?php endif; ?>
|
84 |
+
</li>
|
85 |
+
<?php
|
86 |
+
|
87 |
+
endforeach
|
88 |
+
;
|
89 |
+
if ($cnt > $displaySize) {
|
90 |
+
?>
|
91 |
+
<span class="ea-nav-val-toggle"><a> Show (<?php echo ($cnt - $displaySize) ?> ) more</a></span>
|
92 |
+
<?php }?></div>
|
93 |
+
<div ea_id="cont-<?php echo $filterName?>">
|
94 |
+
|
95 |
+
<?php foreach ($longListItems as $_item): ?>
|
96 |
+
<li>
|
97 |
+
<?php if (($_item->getFilter()->getRequestVar() != 'cat') && (($this->getRequest()->getControllerName() == 'result') || ($this->getRequest()->getControllerName() == 'category'))): ?>
|
98 |
+
<input type="checkbox" id="<?php echo $_item->getUniqueId() ?>"
|
99 |
+
value="<?php echo $_item->getValue() ?>"
|
100 |
+
<?php if ($_item->getIsChecked()): ?> checked="checked"
|
101 |
+
<?php endif; ?> <?php if ($_item->getIsDisabled()): ?>
|
102 |
+
disabled="disabled" <?php endif; ?>
|
103 |
+
onClick="setLocation('<?php echo $this->urlEscape($_item->getIsChecked() ? $_item->getRemoveUrl() : $_item->getUrl()) ?>');" />
|
104 |
+
<?php if ($_item->getImageURL()): ?><img
|
105 |
+
src=<?php echo $_item->getImageURL() ?>><?php endif; ?>
|
106 |
+
<label for="<?php echo $_item->getUniqueId() ?>"> <span
|
107 |
+
<?php if ($_item->getMSelected()): ?>
|
108 |
+
class="m-selected-checkbox-item" <?php endif; ?>>
|
109 |
+
<?php echo $_item->getLabel() ?></span></label>
|
110 |
+
<?php else: ?>
|
111 |
+
<a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
|
112 |
+
<?php endif; ?>
|
113 |
+
<?php if ($_item->getCount() > 0): ?>
|
114 |
+
(<?php echo $_item->getCount() ?>)
|
115 |
+
<?php endif; ?>
|
116 |
+
</li>
|
117 |
+
<?php
|
118 |
+
|
119 |
+
endforeach
|
120 |
+
;
|
121 |
+
if ($cnt > $displaySize) {
|
122 |
+
echo '<span class="ea-nav-val-toggle"><a >Show less </a></span>';
|
123 |
+
}
|
124 |
+
?> </div>
|
125 |
+
<?php
|
126 |
+
} else {
|
127 |
+
|
128 |
+
foreach ( $this->getItems () as $_item ) :
|
129 |
+
?>
|
130 |
+
<li>
|
131 |
+
<?php if (($_item->getFilter()->getRequestVar() != 'cat') && (($this->getRequest()->getControllerName() == 'result') || ($this->getRequest()->getControllerName() == 'category'))): ?>
|
132 |
+
<input type="checkbox" id="<?php echo $_item->getUniqueId() ?>"
|
133 |
+
value="<?php echo $_item->getValue() ?>"
|
134 |
+
<?php if ($_item->getIsChecked()): ?> checked="checked"
|
135 |
+
<?php endif; ?> <?php if ($_item->getIsDisabled()): ?>
|
136 |
+
disabled="disabled" <?php endif; ?>
|
137 |
+
onClick="setLocation('<?php echo $this->urlEscape($_item->getIsChecked() ? $_item->getRemoveUrl() : $_item->getUrl()) ?>');" />
|
138 |
+
<?php if ($_item->getImageURL()): ?><img
|
139 |
+
src=<?php echo $_item->getImageURL() ?>><?php endif; ?>
|
140 |
+
<label for="<?php echo $_item->getUniqueId() ?>"> <span
|
141 |
+
<?php if ($_item->getMSelected()): ?>
|
142 |
+
class="m-selected-checkbox-item" <?php endif; ?>>
|
143 |
+
<?php echo $_item->getLabel() ?></span></label>
|
144 |
+
<?php else: ?>
|
145 |
+
<a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
|
146 |
+
<?php endif; ?>
|
147 |
+
<?php if ($_item->getCount() > 0): ?>
|
148 |
+
(<?php echo $_item->getCount() ?>)
|
149 |
+
<?php endif; ?>
|
150 |
+
</li>
|
151 |
+
<?php
|
152 |
+
|
153 |
+
endforeach
|
154 |
+
;
|
155 |
+
}
|
156 |
+
} else {
|
157 |
+
foreach ( $this->getItems () as $_item ) :
|
158 |
+
?>
|
159 |
+
<li>
|
160 |
+
<?php if ($_item->getCount() > 0): ?>
|
161 |
+
<a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
|
162 |
+
<?php else: echo $_item->getLabel()?>
|
163 |
+
<?php endif; ?>
|
164 |
+
<?php if ($this->shouldDisplayProductCount()): ?>
|
165 |
+
(<?php echo $_item->getCount() ?>)
|
166 |
+
<?php endif; ?>
|
167 |
+
</li>
|
168 |
+
<?php endforeach;
|
169 |
+
} ?>
|
170 |
+
</ol>
|
app/design/frontend/base/default/template/catalog/layer/view.phtml
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-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 design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Category layered navigation
|
31 |
+
*
|
32 |
+
* @see Mage_Catalog_Block_Layer_View
|
33 |
+
*/
|
34 |
+
?>
|
35 |
+
<?php
|
36 |
+
|
37 |
+
$searchEngine = Mage::getStoreConfig ( 'catalog/search/engine' );
|
38 |
+
$useEA = Mage::getStoreConfig ( 'catalog/navigation/use_easyask' );
|
39 |
+
if ((strcasecmp ( $searchEngine, 'easyask_search/engine' ) === 0 && $useEA) || (strcasecmp ( $searchEngine, 'easyask_search/engine' ) === 0 && $this->getRequest()->getControllerName() == 'result')) {
|
40 |
+
|
41 |
+
$hiddenFilters = array ();
|
42 |
+
$showFilters = array ();
|
43 |
+
?>
|
44 |
+
|
45 |
+
<?php if($this->canShowBlock()): ?>
|
46 |
+
<div class="block block-layered-nav">
|
47 |
+
<div class="block-title">
|
48 |
+
<strong><span><?php echo $this->__('Shop By') ?></span></strong>
|
49 |
+
</div>
|
50 |
+
<div class="block-content">
|
51 |
+
<?php echo $this->getStateHtml()?>
|
52 |
+
<?php if($this->canShowOptions()): ?>
|
53 |
+
<p class="block-subtitle"><?php echo $this->__('Shopping Options') ?></p>
|
54 |
+
<dl id="narrow-by-list">
|
55 |
+
<?php $_filters = $this->getFilters()?>
|
56 |
+
<?php foreach ($_filters as $_filter): ?>
|
57 |
+
|
58 |
+
<?php
|
59 |
+
|
60 |
+
$selectionInLonglist = false;
|
61 |
+
$j = 0;
|
62 |
+
$selectionsInShortList = array ();
|
63 |
+
foreach ( $_filter->getItems () as $item ) :
|
64 |
+
$j ++;
|
65 |
+
if ($item->getIsChecked () && $j < $_filter->getIsInitDisplayLimited ()) {
|
66 |
+
$selectionsInShortList [] = $item->getUniqueId ();
|
67 |
+
} else if ($item->getIsChecked () && $j > $_filter->getIsInitDisplayLimited () && ! in_array ( $item->getUniqueId (), $selectionsInShortList )) {
|
68 |
+
$selectionInLonglist = true;
|
69 |
+
}
|
70 |
+
endforeach
|
71 |
+
;
|
72 |
+
|
73 |
+
if ($_filter->getIsInitDisplayLimited () > 0 && ($_filter->getItemsCount () > $_filter->getIsInitDisplayLimited ())) {
|
74 |
+
if (! $selectionInLonglist) {
|
75 |
+
$hiddenFilters [] = strtolower ( $_filter->getName () );
|
76 |
+
} else {
|
77 |
+
$showFilters [] = strtolower ( $_filter->getName () );
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
if ($_filter->getItemsCount ()) :
|
82 |
+
?>
|
83 |
+
<dt
|
84 |
+
title=<?php echo $this->__($_filter->getAttributeCode()) ?>><?php echo $this->__($_filter->getName()) ?></dt>
|
85 |
+
<?php if($_filter->getIsRangeFilter() == 1):?>
|
86 |
+
<?php
|
87 |
+
|
88 |
+
foreach ( $_filter->getItems () as $item ) :
|
89 |
+
$av = $item;
|
90 |
+
break;
|
91 |
+
endforeach
|
92 |
+
;
|
93 |
+
?>
|
94 |
+
<dd class="ea-range-container">
|
95 |
+
<div class="ea-range-attr"
|
96 |
+
ea_attr="<?php echo $this->__($_filter->getName()) ?>"
|
97 |
+
eaMin="<?php echo $av->getMinValue() ?>"
|
98 |
+
eaMax="<?php echo $av->getMaxValue() ?>"
|
99 |
+
eaMinRange="<?php echo $av->getMinRangeValue() ?>"
|
100 |
+
eaMaxRange="<?php echo $av->getMaxRangeValue() ?>"
|
101 |
+
eaScale="<?php echo $av->getRangeRound() ?>"
|
102 |
+
eaSeoAttr="<?php echo $av->getEaSeoAttr() ?>"
|
103 |
+
eaPath="<?php echo $av->getEapath() ?>"></div>
|
104 |
+
<input class="ea-range-value ea-range-min" type="text"> <input
|
105 |
+
class="ea-range-value ea-range-max" type="text">
|
106 |
+
<?php else: ?>
|
107 |
+
|
108 |
+
|
109 |
+
|
110 |
+
<dd><?php echo $_filter->getHtml()?>
|
111 |
+
<?php endif; ?>
|
112 |
+
<?php endif; ?>
|
113 |
+
<?php endforeach; ?>
|
114 |
+
|
115 |
+
|
116 |
+
</dl>
|
117 |
+
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
|
118 |
+
<script type="text/javascript">
|
119 |
+
// Toggle Functions
|
120 |
+
// Source modified from http://bonrouge.com/~togglit
|
121 |
+
function toggleNext(elm) {
|
122 |
+
var next = elm.nextSibling;
|
123 |
+
while ( next.nodeType !== 1 ) {
|
124 |
+
next = next.nextSibling;
|
125 |
+
}
|
126 |
+
next.style.display = (
|
127 |
+
(next.style.display === "none")
|
128 |
+
? "block"
|
129 |
+
: "none"
|
130 |
+
);
|
131 |
+
}
|
132 |
+
|
133 |
+
function toggleEl(elm) {
|
134 |
+
elm.className += ' ' + 'clicker';
|
135 |
+
elm.onclick = function() {
|
136 |
+
toggleNext(this);
|
137 |
+
}
|
138 |
+
toggleNext(elm);
|
139 |
+
}
|
140 |
+
|
141 |
+
var sheet = document.createElement('style');
|
142 |
+
sheet.innerHTML = ".clicker { cursor: pointer; }";
|
143 |
+
document.head.appendChild(sheet);
|
144 |
+
var toggle = document.getElementsByTagName("dt");
|
145 |
+
if ( toggle != undefined ) {
|
146 |
+
for (var i = 1; i < toggle.length; i++) {
|
147 |
+
if (toggle[i].title != 2)
|
148 |
+
toggleEl( toggle[i] );
|
149 |
+
}
|
150 |
+
}
|
151 |
+
var toggle1 = document.getElementsByName("more");
|
152 |
+
|
153 |
+
</script>
|
154 |
+
<?php endif; ?>
|
155 |
+
</div>
|
156 |
+
</div>
|
157 |
+
<?php endif; ?>
|
158 |
+
<script type="text/javascript">
|
159 |
+
(function(jQuery){
|
160 |
+
(function( $, undefined ) {
|
161 |
+
<?php
|
162 |
+
foreach ( $hiddenFilters as $v ) {
|
163 |
+
echo "$('div[ea_id=\"cont-" . $v . "\"]').hide();";
|
164 |
+
}
|
165 |
+
foreach ( $showFilters as $v ) {
|
166 |
+
echo "$('div[ea_id=\"short-" . $v . "\"]').hide();";
|
167 |
+
}
|
168 |
+
?>
|
169 |
+
|
170 |
+
$('#narrow-by-list dd ol').each(function(){
|
171 |
+
var vals = $(this).children('div');
|
172 |
+
|
173 |
+
if (2 == vals.length){
|
174 |
+
vals.each(function(){
|
175 |
+
$(this).find('.ea-nav-val-toggle a').each(function(_,togVal){
|
176 |
+
$(togVal).click(function(){
|
177 |
+
$(vals).toggle();
|
178 |
+
return false;
|
179 |
+
});
|
180 |
+
});
|
181 |
+
});
|
182 |
+
}
|
183 |
+
});
|
184 |
+
|
185 |
+
$('.ea-range-attr').each(function(){
|
186 |
+
var min = $(this).attr('eaMin');
|
187 |
+
var max = $(this).attr('eaMax');
|
188 |
+
var attrName = $(this).attr('ea_attr');
|
189 |
+
var minRange = $(this).attr('eaMinRange');
|
190 |
+
var maxRange = $(this).attr('eaMaxRange');
|
191 |
+
var step = $(this).attr('eaScale') || 1.0;
|
192 |
+
var minInput = $(this).siblings('.ea-range-min')[0];
|
193 |
+
var maxInput = $(this).siblings('.ea-range-max')[0];
|
194 |
+
var eapath = $(this).attr('eaPath');
|
195 |
+
var eaSeoAttr = $(this).attr('eaSeoAttr');
|
196 |
+
var slider = $(this).slider({
|
197 |
+
range: true,
|
198 |
+
min: Number(minRange),
|
199 |
+
max: Number(maxRange),
|
200 |
+
step: Number(step),
|
201 |
+
values: [Number(min), Number(max) ],
|
202 |
+
change: function( event, ui ) {
|
203 |
+
var val = ui.values[0] + '@' + ui.values[1] + '@' + minRange + '@' + maxRange;
|
204 |
+
self.executeRangeAttr(eapath,eaSeoAttr,attrName,val);
|
205 |
+
// window.console && console.log('range: ' + ui.values[0] + ' - ' + ui.values[1]);
|
206 |
+
},
|
207 |
+
create: function(){
|
208 |
+
minInput.value = self.formatNumber(min,2);
|
209 |
+
maxInput.value = self.formatNumber(max,2);
|
210 |
+
},
|
211 |
+
slide: function(event, ui){
|
212 |
+
var min = ui.values[0];
|
213 |
+
var max = ui.values[1];
|
214 |
+
minInput.value = self.formatNumber(min,2);
|
215 |
+
maxInput.value = self.formatNumber(max,2);
|
216 |
+
}
|
217 |
+
});
|
218 |
+
|
219 |
+
$(minInput).keypress(function(e){
|
220 |
+
if (13 == e.which){
|
221 |
+
minInput.value = self.formatNumber(minInput.value,2);
|
222 |
+
var val = minInput.value + '@' + maxInput.value + '@' + minRange + '@' + maxRange;
|
223 |
+
self.executeRangeAttr(eapath,eaSeoAttr,attrName,val);
|
224 |
+
// window.console && console.log('val: ' + val);
|
225 |
+
e.preventDefault();
|
226 |
+
}
|
227 |
+
});
|
228 |
+
$(maxInput).keypress(function(e){
|
229 |
+
if (13 == e.which){
|
230 |
+
maxInput.value = self.formatNumber(maxInput.value,2);
|
231 |
+
var val = minInput.value + '@' + maxInput.value + '@' + minRange + '@' + maxRange;
|
232 |
+
self.executeRangeAttr(eapath,eaSeoAttr,attrName,val);
|
233 |
+
// window.console && console.log('val: ' + val);
|
234 |
+
e.preventDefault();
|
235 |
+
}
|
236 |
+
});
|
237 |
+
|
238 |
+
});
|
239 |
+
|
240 |
+
|
241 |
+
}(jQuery));
|
242 |
+
}(window.eaj$183 || jQuery));
|
243 |
+
|
244 |
+
function formatNumber(val, decimal, group){
|
245 |
+
var re = '\\d(?=(\\d{' + (group || 3) + '})+' + (decimal > 0 ? '\\.' : '$') + ')';
|
246 |
+
return Number(val).toFixed(Math.max(0, ~~decimal)).replace(new RegExp(re, 'g'), '$&,');
|
247 |
+
};
|
248 |
+
|
249 |
+
function executeRangeAttr(path,easeoattr,attr,val){
|
250 |
+
var pathParts = path.split('/');
|
251 |
+
var query = '';
|
252 |
+
for(var i = 0; i < pathParts.length; i++){
|
253 |
+
var seg = pathParts[i];
|
254 |
+
if (seg.indexOf('-') == 0){
|
255 |
+
query = seg.substring(1);
|
256 |
+
}
|
257 |
+
if (seg.indexOf(easeoattr) == 0){ // begins with
|
258 |
+
pathParts[i] = attr + ":" + val;
|
259 |
+
window.location = '<?php echo $this->helper('catalogsearch')->getResultUrl() ?>' + "?ea_bc=" + pathParts.join('/');
|
260 |
+
return;
|
261 |
+
}
|
262 |
+
}
|
263 |
+
window.location = '<?php echo $this->helper('catalogsearch')->getResultUrl() ?>' + "?q=" + query + "&ea_path=" + path + '&ea_a=' + attr + ':' + val ;
|
264 |
+
};
|
265 |
+
|
266 |
+
|
267 |
+
</script>
|
268 |
+
|
269 |
+
<?php
|
270 |
+
|
271 |
+
} else {
|
272 |
+
if ($this->canShowBlock ()) :
|
273 |
+
?>
|
274 |
+
<div class="block block-layered-nav">
|
275 |
+
<div class="block-title">
|
276 |
+
<strong><span><?php echo $this->__('Shop By') ?></span></strong>
|
277 |
+
</div>
|
278 |
+
<div class="block-content">
|
279 |
+
<?php echo $this->getStateHtml()?>
|
280 |
+
<?php if ($this->getLayer()->getState()->getFilters()): ?>
|
281 |
+
<div class="actions">
|
282 |
+
<a href="<?php echo $this->getClearUrl() ?>"><?php echo $this->__('Clear All') ?></a>
|
283 |
+
</div>
|
284 |
+
<?php endif; ?>
|
285 |
+
<?php if($this->canShowOptions()): ?>
|
286 |
+
<p class="block-subtitle"><?php echo $this->__('Shopping Options') ?></p>
|
287 |
+
<dl id="narrow-by-list">
|
288 |
+
<?php $_filters = $this->getFilters()?>
|
289 |
+
<?php foreach ($_filters as $_filter): ?>
|
290 |
+
<?php if($_filter->getItemsCount()): ?>
|
291 |
+
<dt><?php echo $this->__($_filter->getName()) ?></dt>
|
292 |
+
<dd><?php echo $_filter->getHtml() ?></dd>
|
293 |
+
<?php endif; ?>
|
294 |
+
<?php endforeach; ?>
|
295 |
+
</dl>
|
296 |
+
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
|
297 |
+
<?php endif; ?>
|
298 |
+
</div>
|
299 |
+
</div>
|
300 |
+
<?php endif; }?>
|
app/design/frontend/base/default/template/catalogsearch/form.mini.phtml
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-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 design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<form id="search_mini_form" action="<?php echo $this->helper('catalogsearch')->getResultUrl() ?>" method="get">
|
28 |
+
<div class="form-search">
|
29 |
+
<label for="search"><?php echo $this->__('Search:') ?></label>
|
30 |
+
<input id="search" type="text" name="<?php echo $this->helper('catalogsearch')->getQueryParamName() ?>" value="<?php echo $this->helper('catalogsearch')->getEscapedQueryText() ?>" class="input-text" />
|
31 |
+
<button id="searchBtn" type="submit" title="<?php echo $this->__('Search') ?>" class="button"><span><span><?php echo $this->__('Search') ?></span></span></button>
|
32 |
+
|
33 |
+
<!-- jQuery libraries with ui -->
|
34 |
+
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
|
35 |
+
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
|
36 |
+
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
|
37 |
+
|
38 |
+
<script type='text/javascript'>
|
39 |
+
var $ea = jQuery.noConflict();
|
40 |
+
</script>
|
41 |
+
<!-- <script src="/magento19/js/easyask/js/ea-noconflict.js"></script> -->
|
42 |
+
<!-- <script type='text/javascript' src='/magento19/js/easyask/js/jquery-ui-1.9.2a.custom.min.js' > </script>
|
43 |
+
|
44 |
+
<link type='text/css' rel='stylesheet' charset='utf-8' href='/magento19/js/easyask/css/flick/jquery-ui-1.9.2.custom.min.css'>
|
45 |
+
-->
|
46 |
+
<!-- EasyAsk SAYT -->
|
47 |
+
<script type='text/javascript' src='/magento19/js/easyask/2.0/ea-autocomplete-2.0.1.js' > </script>
|
48 |
+
<!-- If there is a configuration entry for base_url in database
|
49 |
+
<script type='text/javascript' src='<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS)?>easyask/js/ea-autocomplete-1.2.1.js' > </script>
|
50 |
+
-->
|
51 |
+
<link type='text/css' rel='stylesheet' charset='utf-8' href='/magento19/js/easyask/2.0/ea-autocomplete-2.0.1.css'>
|
52 |
+
|
53 |
+
<style>
|
54 |
+
img.ea-featured-product-image { width: 138px;}
|
55 |
+
.ea-toplevel-category { width: 550px; background: green; color: white; text-align: center; }
|
56 |
+
.ea-toplevel-attribute { width: 550px;background: blue; color: white; text-align: center; }
|
57 |
+
.ea-range-values { margin: 0px 10px; height: 50px;}
|
58 |
+
.ea-range-attr { height: 10px; margin: 5px 15px 5px 10px;}
|
59 |
+
.ea-range-container {padding-bottom: 25px !important;}
|
60 |
+
.ea-range-value {margin-top: 5px; text-align:right; width: 45px; font-size: 12px;}
|
61 |
+
.ea-range-min { float: left; text-align: left;}
|
62 |
+
.ea-range-max { float: right; text-align: right; }
|
63 |
+
|
64 |
+
.catalogsearch-result-index .ui-corner-all,
|
65 |
+
.catalogsearch-result-index .ui-corner-bottom,
|
66 |
+
.catalogsearch-result-index .ui-corner-right,
|
67 |
+
.catalogsearch-result-index .ui-corner-br { border-bottom-right-radius: 8px; }
|
68 |
+
.catalogsearch-result-index .ui-corner-all,
|
69 |
+
.catalogsearch-result-index .ui-corner-bottom,
|
70 |
+
.catalogsearch-result-index .ui-corner-left,
|
71 |
+
.catalogsearch-result-index .ui-corner-bl { border-bottom-left-radius: 8px; }
|
72 |
+
.catalogsearch-result-index .ui-corner-all,
|
73 |
+
.catalogsearch-result-index .ui-corner-top,
|
74 |
+
.catalogsearch-result-index .ui-corner-right,
|
75 |
+
.catalogsearch-result-index .ui-corner-tr { border-top-right-radius: 8px; }
|
76 |
+
.catalogsearch-result-index .ui-corner-all,
|
77 |
+
.catalogsearch-result-index .ui-corner-top,
|
78 |
+
.catalogsearch-result-index .ui-corner-left,
|
79 |
+
.catalogsearch-result-index .ui-corner-tl { border-top-left-radius: 8px; }
|
80 |
+
.catalogsearch-result-index .ui-state-default,
|
81 |
+
.catalogsearch-result-index .ui-widget-content .ui-state-default,
|
82 |
+
.catalogsearch-result-index .ui-widget-header .ui-state-default{
|
83 |
+
background: url(/magento19/js/easyask/images/price_filter.png) no-repeat scroll -0.1em ;
|
84 |
+
}
|
85 |
+
.catalogsearch-result-index .ui-slider,
|
86 |
+
.catalogsearch-result-index .ui-slider .ui-slider-range { background: none repeat scroll 0 0 #6C6C6C; }
|
87 |
+
|
88 |
+
|
89 |
+
/* PRICE SLIDER DESIGN BEGIN */
|
90 |
+
.catalogsearch-result-index .ui-slider-horizontal { height: 3px; }
|
91 |
+
.catalogsearch-result-index .ui-slider-horizontal .ui-slider-handle {
|
92 |
+
top: -.5em;
|
93 |
+
margin-left: -.3em;
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
/* PRICE SLIDER DESIGN END */
|
98 |
+
|
99 |
+
|
100 |
+
|
101 |
+
</style>
|
102 |
+
|
103 |
+
<script type='text/javascript'>
|
104 |
+
(function(jQuery){
|
105 |
+
(function( $, undefined ) {
|
106 |
+
$(function() {
|
107 |
+
var acOptions = {
|
108 |
+
id: 'search',
|
109 |
+
dict: '<?php echo Mage::getStoreConfig('catalog/search/ea_dictionary') ?>',
|
110 |
+
server: '<?php echo ((substr($this->helper('catalogsearch')->getResultUrl(), 0, strlen('https:')) === 'https:' ? 'https://' : 'http://')) . Mage::getStoreConfig('catalog/search/ea_server_hostname') . ':' . Mage::getStoreConfig('catalog/search/ea_server_port') ?>',
|
111 |
+
serverSearch: '<?php echo ((substr($this->helper('catalogsearch')->getResultUrl(), 0, strlen('https:')) === 'https:' ? 'https://' : 'http://')) . Mage::getStoreConfig('catalog/search/ea_server_hostname') . ':' . Mage::getStoreConfig('catalog/search/ea_server_port') ?>',
|
112 |
+
prompt: 'Search by EasyAsk',
|
113 |
+
submitFctn: function(type,val){
|
114 |
+
if (type == 'nav'){
|
115 |
+
window.location = '<?php echo $this->helper('catalogsearch')->getResultUrl() ?>' + "index/?ea_bc=" + val;
|
116 |
+
}
|
117 |
+
else {
|
118 |
+
$('#searchBtn').click();
|
119 |
+
}
|
120 |
+
},
|
121 |
+
fixedWidth: 500,
|
122 |
+
leftWidth:'60%',
|
123 |
+
products: {
|
124 |
+
fields: {
|
125 |
+
thumbnail: 'Thumbnail_URL',
|
126 |
+
name: 'Product_Name',
|
127 |
+
description: 'SAYTDescription',
|
128 |
+
price: 'Price',
|
129 |
+
link: 'Url_Path'
|
130 |
+
},
|
131 |
+
sizes: {
|
132 |
+
description: 115
|
133 |
+
},
|
134 |
+
value: function(item,field){
|
135 |
+
if (field == 'Url_Path'){
|
136 |
+
item[field] = window.location.protocol + "//" + window.location.host + "/" + item[field];
|
137 |
+
}
|
138 |
+
return item[field];
|
139 |
+
}
|
140 |
+
},
|
141 |
+
navigation: {
|
142 |
+
size: 3,
|
143 |
+
sections: [{
|
144 |
+
size: 5,
|
145 |
+
title: 'Category',
|
146 |
+
type: 'Category'
|
147 |
+
},{
|
148 |
+
size: 4,
|
149 |
+
title: 'Price Range',
|
150 |
+
type: 'Price Range'
|
151 |
+
},{
|
152 |
+
size: 4,
|
153 |
+
title: 'Style',
|
154 |
+
type: 'Style'
|
155 |
+
},{
|
156 |
+
size: 4,
|
157 |
+
title: 'Size',
|
158 |
+
type: 'Size'
|
159 |
+
}]
|
160 |
+
}
|
161 |
+
};
|
162 |
+
new EAAutoComplete().init(acOptions);
|
163 |
+
});
|
164 |
+
}(jQuery));
|
165 |
+
}(window.$ea || jQuery));
|
166 |
+
</script>
|
167 |
+
|
168 |
+
|
169 |
+
</div>
|
170 |
+
</form>
|
app/design/frontend/base/default/template/catalogsearch/result.phtml
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-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 design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php if($this->getResultCount()): ?>
|
28 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
29 |
+
<div class="page-title">
|
30 |
+
<?php if ($this->helper('rss/catalog')->getTagFeedUrl()): ?>
|
31 |
+
<a href="<?php echo $this->helper('rss/catalog')->getTagFeedUrl() ?>" class="nobr link-rss"><?php echo $this->__('Subscribe to Feed') ?></a>
|
32 |
+
<?php endif; ?>
|
33 |
+
<h1><?php echo ($this->getHeaderText() || $this->getHeaderText() === false) ? $this->getHeaderText() : $this->__("Search results for '%s'", $this->helper('catalogsearch')->getEscapedQueryText()) ?></h1>
|
34 |
+
</div>
|
35 |
+
<?php if ($messages = $this->getNoteMessages()):?>
|
36 |
+
<p class="note-msg">
|
37 |
+
<?php foreach ($messages as $message):?>
|
38 |
+
<?php echo $message?><br />
|
39 |
+
<?php endforeach;?>
|
40 |
+
</p>
|
41 |
+
<?php endif; ?>
|
42 |
+
<?php if ($this->hasBanner(1)):?>
|
43 |
+
<?php echo $this->getBanner(1)?>
|
44 |
+
<?php endif; ?>
|
45 |
+
<?php echo $this->getProductListHtml() ?>
|
46 |
+
<?php else: ?>
|
47 |
+
<div class="page-title">
|
48 |
+
<h1><?php echo ($this->getHeaderText() || $this->getHeaderText() === false) ? $this->getHeaderText() : $this->__("Search results for '%s'", $this->helper('catalogsearch')->getEscapedQueryText()) ?></h1>
|
49 |
+
</div>
|
50 |
+
<p class="note-msg">
|
51 |
+
<?php echo ($this->getNoResultText()) ? $this->getNoResultText() : $this->__('Your search returns no results.') ?>
|
52 |
+
<?php if ($messages = $this->getNoteMessages()):?>
|
53 |
+
<?php foreach ($messages as $message):?>
|
54 |
+
<br /><?php echo $message?>
|
55 |
+
<?php endforeach;?>
|
56 |
+
<?php endif; ?>
|
57 |
+
</p>
|
58 |
+
<?php endif; ?>
|
app/etc/modules/EasyAsk_Search.xml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<EasyAsk_Search>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_CatalogSearch/>
|
9 |
+
</depends>
|
10 |
+
<version>0.1.0</version>
|
11 |
+
</EasyAsk_Search>
|
12 |
+
</modules>
|
13 |
+
</config>
|
js/easyask/2.0/ea-autocomplete-2.0.1.css
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* autocomplete with sayt using jQuery UI V12 */
|
2 |
+
|
3 |
+
/* these highlight the sections of the suggestion that match the input */
|
4 |
+
.ea-sug-text { font-weight: normal; }
|
5 |
+
.ea-sug-match { font-weight: bold; }
|
6 |
+
|
7 |
+
/* fonts */
|
8 |
+
.ui-menu-item, .ea-sug-product-name, .ea-sug-product-price, .ea-sug-nav-value, .ea-sug-sec-heading, .ui-menu-item { font-family: arial, helvetica, sans-serif; font-size:12px; border-radius: 0 }
|
9 |
+
|
10 |
+
/* ea-sug-wrapper surrounds all of the suggestion areas */
|
11 |
+
|
12 |
+
.ea-sug-wrapper { background: #f8f8f8; padding: 3px; text-align: left; position: absolute;}
|
13 |
+
|
14 |
+
/* suggestions are in columns, when there are 2 columns need a visual separator */
|
15 |
+
.ea-sug-multi-column { padding-left:3px; }
|
16 |
+
|
17 |
+
/* columns are organized into sections */
|
18 |
+
.ea-sug-section { border: 1px solid #b4b4b4;background: white; float:left;width:100%;overflow-x:hidden; line-height: normal;}
|
19 |
+
|
20 |
+
/* sections need vertical space between them, use the same value as wrapper padding */
|
21 |
+
.ea-sug-section-vertical-space { margin-top: 3px }
|
22 |
+
|
23 |
+
/* section headings stand out using a gradient */
|
24 |
+
.ea-sug-sec-heading {
|
25 |
+
padding: 5px 2px;
|
26 |
+
background:#ede8e2;
|
27 |
+
/* background:#cfcfcf url('./images/sug-title-gradient.gif') repeat-x;
|
28 |
+
background:-webkit-linear-gradient(top, #fff, #cfcfcf);
|
29 |
+
background:-moz-linear-gradient(top,#fff,#cfcfcf);
|
30 |
+
background:-o-linear-gradient(top,#fff,#cfcfcf);
|
31 |
+
background:linear-gradient(to bottom,#fff,#cfcfcf);*/
|
32 |
+
}
|
33 |
+
|
34 |
+
/* section heading parts can be individually styled */
|
35 |
+
.ea-sug-sec-head-title { }
|
36 |
+
.ea-sug-sec-head-value { font-weight: bold; }
|
37 |
+
.ea-sug-sec-head-count { float: right;}
|
38 |
+
|
39 |
+
/* highlighting of selections */
|
40 |
+
.ea-sug-choices .ui-state-hover, .ea-sug-menu .ui-state-focus { border: 1px solid transparent; background: #d2d2d2; font-weight: bold; color: #ffffff; }
|
41 |
+
.ea-sug-product-name.ui-state-hover { background: #d2d2d2; font-weight: bold; color: #ffffff; border:none;}
|
42 |
+
.ea-sug-product-desc.ui-state-hover {background: white; color: black; border:none;font-weight: normal;}
|
43 |
+
.ui-corner-all {border-radius: 0;}
|
44 |
+
.ea-sug-menu a, a.ea-sug-nav-link,.ea-sug-product a { cursor:pointer; text-decoration:none; color: black;}
|
45 |
+
.ea-sug-section { cursor: default; }
|
46 |
+
|
47 |
+
/* product section */
|
48 |
+
.ea-sug-product-name, .ea-sug-product-price { font-weight: bold; }
|
49 |
+
.ea-sug-product-name { padding: 2px .4em; }
|
50 |
+
.ea-sug-product-desc { font-size: 12px; }
|
51 |
+
td.ea-sug-product-picture { float: left; vertical-align: top; }
|
52 |
+
img.ea-sug-product-image { width: 40px; border: 0;}
|
53 |
+
td.ea-sug-product-info { vertical-align: top; width: 90%; }
|
54 |
+
.ea-sug-product-separator { border-bottom: 1px dotted black; }
|
55 |
+
|
56 |
+
/* entries in each navigation section are lists that are rendered without decorations */
|
57 |
+
ul.ea-sug-choices { list-style:none; padding:2px; margin:0; }
|
58 |
+
|
59 |
+
/* navigation sections */
|
60 |
+
.ea-sug-nav-value{ zoom:1; list-style:none; padding:2px .4em 2px 20px;margin:0px 2px;}
|
61 |
+
.ea-sug-nav-value a { margin-left:-15px; line-height:1.5;font-weight:normal;}
|
62 |
+
.ui-state-hover a, .ui-state-hover a:link, .ui-state-hover a:hover,.ui-state-hover a:visited,.ui-state-focus a, .ui-state-focus a:link, .ui-state-focus a:hover, .ui-state-focus a:visited { color: white; }
|
63 |
+
.ea-sug-nav-count { font-weight:normal;}
|
64 |
+
.ea-sug-nav-value.ui-state-focus { margin:-1px 1px;}
|
65 |
+
|
66 |
+
/* EasyAsk logo position */
|
67 |
+
.ea-sug-nav-tm {background-image:url('./images/tm-logo.png');height:30px;width:86px;position:absolute;bottom:1px; right: 10px; }
|
68 |
+
a.ea-search-selection { background-color: #a2a2a2; color: white; }
|
69 |
+
|
js/easyask/2.0/ea-autocomplete-2.0.1.js
ADDED
@@ -0,0 +1,878 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*! Copyright (c) 2000-2014 EasyAsk Technologies, Inc. All Rights Reserved.
|
2 |
+
* Use, reproduction, transfer, publication or disclosure is prohibited
|
3 |
+
* except in accordance with the License Agreement.
|
4 |
+
*/
|
5 |
+
(function(jQuery){
|
6 |
+
(function( $, _undefined ) {
|
7 |
+
var jquiver = ($.ui ? $.ui.version || '1.5': '1.5').split('.');
|
8 |
+
var AUTOCOMPLETE_WIDGET = "easyask-sayt";
|
9 |
+
EAAutoComplete = function(){
|
10 |
+
return {
|
11 |
+
defaults: {
|
12 |
+
dict: null,
|
13 |
+
submitFctn: function () {},
|
14 |
+
id: 'question',
|
15 |
+
sort: 'weight',
|
16 |
+
reduce: 'cluster',
|
17 |
+
matchAllSearchWords: true,
|
18 |
+
matchAnySuggestionWord: true,
|
19 |
+
boostExact: false,
|
20 |
+
delay: 300,
|
21 |
+
minLength: 2,
|
22 |
+
prompt: null,
|
23 |
+
handler: null,
|
24 |
+
serverSearch: '',
|
25 |
+
defaultSearchParams: 'indexed=1&oneshot=1&ie=UTF-8&disp=json&RequestAction=advisor&RequestData=CA_Search&CatPath=All Products&defarrangeby=////NONE////',
|
26 |
+
urlSearch: '/EasyAsk/apps/Advisor.jsp',
|
27 |
+
server: '',
|
28 |
+
url: '/EasyAsk/AutoComplete-1.2.1.jsp',
|
29 |
+
xOffset: 0,
|
30 |
+
yOffset: 0,
|
31 |
+
widthOffset: 0,
|
32 |
+
numCols: 2,
|
33 |
+
search: {
|
34 |
+
heading:{
|
35 |
+
display: true,
|
36 |
+
format: '<span class="ea-sug-sec-head-title">Search Suggestions for: </span><span class="ea-sug-sec-head-value">{value}</span>'
|
37 |
+
},
|
38 |
+
size: 5
|
39 |
+
}
|
40 |
+
},
|
41 |
+
defaultProducts: {
|
42 |
+
products: {
|
43 |
+
size: 5,
|
44 |
+
display: true,
|
45 |
+
value: function(item,field){ return item[field]; },
|
46 |
+
fields: {
|
47 |
+
thumbnail: 'thumbnail',
|
48 |
+
name: 'name',
|
49 |
+
link: 'link',
|
50 |
+
description: 'description',
|
51 |
+
price: 'price'
|
52 |
+
},
|
53 |
+
heading:{
|
54 |
+
display:true,
|
55 |
+
format: '<span class="ea-sug-sec-head-title">Products</span><span class="ea-sug-sec-head-count">total: {count}</span>'
|
56 |
+
},
|
57 |
+
|
58 |
+
sizes: {
|
59 |
+
name: 45,
|
60 |
+
description: 100
|
61 |
+
}
|
62 |
+
},
|
63 |
+
navigation: {
|
64 |
+
size: 2,
|
65 |
+
embed: false,
|
66 |
+
heading:{
|
67 |
+
display: true,
|
68 |
+
format: '<span class="ea-sug-sec-head-title">{title}</span><span class="ea-sug-sec-head-count">total: {count}</span>'
|
69 |
+
},
|
70 |
+
sections: [{
|
71 |
+
type: 'category',
|
72 |
+
size: 5,
|
73 |
+
title: 'Category'
|
74 |
+
}]
|
75 |
+
}
|
76 |
+
},
|
77 |
+
init: function(opts, dct){
|
78 |
+
var options = $.extend(true,this.defaults,{
|
79 |
+
dict: dct,
|
80 |
+
position: {
|
81 |
+
collision: "none",
|
82 |
+
my: (opts.horizAlign || "right") + " top",
|
83 |
+
at: (opts.horizAlign || "right") + " bottom"
|
84 |
+
}
|
85 |
+
},opts.products?$.extend(true,{},this.defaultProducts,opts):opts);
|
86 |
+
if (options.dict){
|
87 |
+
if (options.xOffset || options.yOffset){
|
88 |
+
options.position.offset = options.xOffset + " " + options.yOffset;
|
89 |
+
}
|
90 |
+
this._init(options);
|
91 |
+
}
|
92 |
+
var self = this;
|
93 |
+
$(window).resize(function(){
|
94 |
+
setTimeout(function(){
|
95 |
+
self._widget.reposition();
|
96 |
+
},10);
|
97 |
+
});
|
98 |
+
|
99 |
+
return this;
|
100 |
+
},
|
101 |
+
_init: function(opts){
|
102 |
+
var options = $.extend({},opts,{
|
103 |
+
source: function(request, response ) {
|
104 |
+
this.lastSearch = null;
|
105 |
+
var self = this;
|
106 |
+
this.pendingAlt = false;
|
107 |
+
this.alt = null;
|
108 |
+
this.pendingProds = false;
|
109 |
+
this.prods = null;
|
110 |
+
$.ajax({
|
111 |
+
url: self.options.server + self.options.url,
|
112 |
+
dataType: "jsonp",
|
113 |
+
data: {
|
114 |
+
dct: self.options.dict,
|
115 |
+
num: self.options.search.size,
|
116 |
+
key: request.term,
|
117 |
+
sort: self.options.sort,
|
118 |
+
reduce: self.options.reduce,
|
119 |
+
match: self.options.matchAllSearchWords,
|
120 |
+
anchor: self.options.matchAnySuggestionWord
|
121 |
+
},
|
122 |
+
success: function( data ) {
|
123 |
+
if (data.suggests && data.suggests.length && data.input == self._value()){
|
124 |
+
if (self.options.handler){
|
125 |
+
self.options.handler(data.input,data.suggests);
|
126 |
+
}
|
127 |
+
else {
|
128 |
+
if (self.options.boostExact){
|
129 |
+
//pull any exact matches to the front
|
130 |
+
var lcTerm = request.term.toLowerCase();
|
131 |
+
for(var i = 0; i < data.suggests.length; i++){
|
132 |
+
var item = data.suggests[i];
|
133 |
+
if (item.val.toLowerCase() == lcTerm){
|
134 |
+
if (0 < i){
|
135 |
+
data.suggests.splice(i,1);
|
136 |
+
data.suggests.unshift(item);
|
137 |
+
break;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
response( $.map( data.suggests, function( item, _idx ) {
|
143 |
+
var obj = {
|
144 |
+
label: item.val,
|
145 |
+
value: item.val,
|
146 |
+
start: item.start,
|
147 |
+
end: item.end
|
148 |
+
};
|
149 |
+
if (0 == _idx){
|
150 |
+
obj['className'] = 'ea-search-selection';
|
151 |
+
}
|
152 |
+
return obj;
|
153 |
+
}));
|
154 |
+
}
|
155 |
+
// add a spacer for options (rounded corners);
|
156 |
+
self.menu.element.find('li:last').after($('<div class="ea-sug-last-spacer"></div>'));
|
157 |
+
self.findProducts(data.suggests[0].val,true);
|
158 |
+
self.newSearch = true;
|
159 |
+
self.findAlt(request.term);
|
160 |
+
self.showSuggestions(true);
|
161 |
+
}
|
162 |
+
else if (self.options.altSuggest){
|
163 |
+
self.newSearch = true;
|
164 |
+
self.findAlt(request.term);
|
165 |
+
self.showSuggestions(false);
|
166 |
+
}
|
167 |
+
else {
|
168 |
+
$(self.wrapperId).hide();
|
169 |
+
}
|
170 |
+
}
|
171 |
+
});
|
172 |
+
},
|
173 |
+
|
174 |
+
select: function( event, ui ) {
|
175 |
+
var widget = $(this).data(AUTOCOMPLETE_WIDGET);
|
176 |
+
setTimeout(function(){
|
177 |
+
widget.term = '';
|
178 |
+
widget.options.submitFctn();
|
179 |
+
},10); // let the select complete then process it
|
180 |
+
},
|
181 |
+
|
182 |
+
create: function(evt, ui){
|
183 |
+
var widget = $(this).data(AUTOCOMPLETE_WIDGET);
|
184 |
+
widget._on({
|
185 |
+
keydown: function(event){
|
186 |
+
var keyCode = $.ui.keyCode;
|
187 |
+
if (keyCode.ENTER == event.keyCode || keyCode.NUMPAD_ENTER == event.keyCode){
|
188 |
+
clearTimeout(widget.searching);
|
189 |
+
if (!widget.menu.active && widget.menu.element.is(':visible')){
|
190 |
+
setTimeout(function(){widget.close(event);},10);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
}
|
194 |
+
});
|
195 |
+
},
|
196 |
+
open: function() {
|
197 |
+
var widget = $(this).data(AUTOCOMPLETE_WIDGET);
|
198 |
+
widget.openCnt++;
|
199 |
+
this.currentWidth = undefined;
|
200 |
+
if (widget.wrapperId){
|
201 |
+
$(widget.wrapperId).show();
|
202 |
+
}
|
203 |
+
|
204 |
+
},
|
205 |
+
|
206 |
+
close: function(event,ui) {
|
207 |
+
var widget = $(this).data(AUTOCOMPLETE_WIDGET);
|
208 |
+
widget.openCnt = 0;
|
209 |
+
this.currentWidth = undefined;
|
210 |
+
widget.term = ''; // clear copy since using ajax
|
211 |
+
$(widget.wrapperId).hide();
|
212 |
+
},
|
213 |
+
|
214 |
+
focus: function(event,ui){
|
215 |
+
if (ui.item && (event.keyCode || $(this).data(AUTOCOMPLETE_WIDGET).options.hover)){ // only on keyboard unless hover
|
216 |
+
$('.ea-sug-section .ea-search-selection').removeClass('ea-search-selection'); // clear out any
|
217 |
+
$('.ea-sug-section a.ui-state-focus').addClass('ea-search-selection'); // add this one
|
218 |
+
$(this).data(AUTOCOMPLETE_WIDGET).findProducts(ui.item.label,false);
|
219 |
+
}
|
220 |
+
}
|
221 |
+
});
|
222 |
+
this._widget = $('#' + options.id).sayt(options).data(AUTOCOMPLETE_WIDGET);
|
223 |
+
// emulate placeholder support if prompt is specified
|
224 |
+
if (options.prompt){
|
225 |
+
var supportsPlaceholder = ('placeholder' in document.createElement('input'));
|
226 |
+
if (supportsPlaceholder){
|
227 |
+
$('#' + options.id).attr('placeholder',options.prompt);
|
228 |
+
}
|
229 |
+
else {
|
230 |
+
$('#' + options.id).each(function(){
|
231 |
+
var placeholder = options.prompt;
|
232 |
+
if ($(this).val() === '') {
|
233 |
+
$(this).val(placeholder).addClass('ea-sug-placeholder');
|
234 |
+
}
|
235 |
+
$(this).bind('focus',function() {
|
236 |
+
if ($(this).val() === placeholder) {
|
237 |
+
$(this).val('').removeClass('ea-sug-placeholder');
|
238 |
+
}
|
239 |
+
})
|
240 |
+
.bind('blur',function() {
|
241 |
+
if ($(this).val() === '' && $(this).val() !== placeholder) {
|
242 |
+
$(this).val(placeholder).addClass('ea-sug-placeholder');
|
243 |
+
}
|
244 |
+
});
|
245 |
+
});
|
246 |
+
}
|
247 |
+
}
|
248 |
+
},
|
249 |
+
disable: function() {
|
250 |
+
this._widget.cancelSearch = true;
|
251 |
+
}
|
252 |
+
};
|
253 |
+
};
|
254 |
+
|
255 |
+
$(function() {
|
256 |
+
$.widget("easyask.sayt",$.ui.autocomplete, {
|
257 |
+
openCnt: 0,
|
258 |
+
// overrides
|
259 |
+
_create: function(){
|
260 |
+
this._super();
|
261 |
+
this.element.attr("spellcheck","false");
|
262 |
+
var menu = this.menu.element;
|
263 |
+
var zindex = parseInt(this.options.zIndex || menu.css('z-index')) || 100;
|
264 |
+
var widget = this;
|
265 |
+
var divWrapper = $('<div class="ea-sug-wrapper" ></div>')
|
266 |
+
.on(
|
267 |
+
'mousedown', function(event){
|
268 |
+
event.preventDefault();
|
269 |
+
widget.cancelBlur = true;
|
270 |
+
widget._delay(function() {
|
271 |
+
delete widget.cancelBlur;
|
272 |
+
});
|
273 |
+
})
|
274 |
+
.zIndex(zindex)
|
275 |
+
.width('0px')
|
276 |
+
.css('display','none')
|
277 |
+
.css('clear','both')
|
278 |
+
.uniqueId().appendTo('body');
|
279 |
+
this.wrapperId = '#' + divWrapper.attr('id');
|
280 |
+
var divLeftCol = $('<div class="ea-sug-nav ea-sug-nav-left" style="float:left;display:none;z-index:' + (zindex+1) + '"></div>')
|
281 |
+
.uniqueId().appendTo(divWrapper);
|
282 |
+
this.leftColId = '#' + divLeftCol.attr('id');
|
283 |
+
var divMenu = $('<div class="ea-sug-section"></div>').uniqueId().appendTo(divLeftCol);
|
284 |
+
this.menuId = '#'+divMenu.attr('id');
|
285 |
+
if (this.options.search && this.options.search.heading.display){
|
286 |
+
$('<div class="ea-sug-sec-heading ea-sug-sug">'+this.generateHeading(this.options.search.heading.format,null,' ',null)+ '</div>').appendTo(divMenu);
|
287 |
+
}
|
288 |
+
menu.zIndex((zindex+1).toString());
|
289 |
+
menu.removeClass('ui-corner-all ui-autocomplete').detach().appendTo(divMenu);
|
290 |
+
this.rightColId = '#' + $('<div class="ea-sug-nav ea-sug-nav-right" style="float:left;display:none;z-index:' + (zindex+1) + '"></div>')
|
291 |
+
.uniqueId().appendTo(divWrapper).attr('id');
|
292 |
+
this.spacerId = '#'+$('<div class="ea-sug-spacer" style="height:0px;clear:both;"></div>').uniqueId().appendTo(divWrapper).attr('id');
|
293 |
+
this.txtNode = $('<span style="display:none;"></span>');
|
294 |
+
},
|
295 |
+
_renderItem: function(ul,item){
|
296 |
+
var anchor = '<a class="ui-corner-all' + (item.className?' ' + item.className:'') + '"></a>';
|
297 |
+
return $('<li class="ui-menu-item" style="width:auto;"></li>')
|
298 |
+
.append($(anchor).data('ui-autocomplete-item',item)
|
299 |
+
.append($('<div></div>').css('whiteSpace','nowrap')
|
300 |
+
.append($('<span class="ea-sug-text">' + item.label.substring(0,item.start) +
|
301 |
+
'</span><span class="ea-sug-match">' + item.label.substring(item.start,item.end) +
|
302 |
+
'</span><span class="ea-sug-text">' + item.label.substring(item.end)+'</span>'))))
|
303 |
+
.appendTo(ul);
|
304 |
+
},
|
305 |
+
_renderMenu: function( ul, items ) {
|
306 |
+
$(this.menuId + ' .ea-sug-sec-head-value').text('"' + this.term + '"');
|
307 |
+
this._super(ul,items);
|
308 |
+
ul.addClass('ea-sug-menu').removeClass('ui-widget-content');
|
309 |
+
},
|
310 |
+
_resizeMenu: function() {
|
311 |
+
var ul = this.menu.element;
|
312 |
+
if (ul.is(':hidden')){
|
313 |
+
ul.outerWidth( Math.max(
|
314 |
+
// Firefox wraps long text (possibly a rounding bug)
|
315 |
+
// so we add 1px to avoid the wrapping (#7513)
|
316 |
+
ul.width( "" ).outerWidth() + 1,
|
317 |
+
this.options.fixedWidth || this.element.outerWidth()
|
318 |
+
) );
|
319 |
+
}
|
320 |
+
},
|
321 |
+
_suggest: function( items ) {
|
322 |
+
var ul = this.menu.element
|
323 |
+
.empty()
|
324 |
+
.zIndex( this.element.zIndex() + 1 );
|
325 |
+
this._renderMenu( ul, items );
|
326 |
+
this.menu.refresh();
|
327 |
+
|
328 |
+
// size and position menu
|
329 |
+
var wasHidden = ul.is(':hidden');
|
330 |
+
ul.show();
|
331 |
+
this._resizeMenu();
|
332 |
+
if (wasHidden) {
|
333 |
+
ul.position( $.extend({
|
334 |
+
of: this.element
|
335 |
+
}, this.options.position ));
|
336 |
+
}
|
337 |
+
if ( this.options.autoFocus ) {
|
338 |
+
this.menu.next();
|
339 |
+
}
|
340 |
+
},
|
341 |
+
reposition: function(){
|
342 |
+
if (!this.menu.element.is(':hidden')){
|
343 |
+
$(this.wrapperId)
|
344 |
+
.position($.extend({
|
345 |
+
of: this.element
|
346 |
+
},this.options.position));
|
347 |
+
}
|
348 |
+
},
|
349 |
+
// extensions
|
350 |
+
trimString: function(val, len){
|
351 |
+
if (val){
|
352 |
+
if (val.length < len){
|
353 |
+
return val;
|
354 |
+
}
|
355 |
+
else {
|
356 |
+
var sub = val.substring(0,len);
|
357 |
+
var idx = sub.lastIndexOf(' ');
|
358 |
+
if (-1 < idx){
|
359 |
+
sub = sub.substring(0,idx);
|
360 |
+
}
|
361 |
+
sub += '...';
|
362 |
+
return sub;
|
363 |
+
}
|
364 |
+
}
|
365 |
+
return val;
|
366 |
+
},
|
367 |
+
|
368 |
+
setColWidth: function(elt,width){
|
369 |
+
elt.outerWidth(width);
|
370 |
+
var inner = elt.width();
|
371 |
+
elt.children('.ea-sug-section').each(function(){$(this).outerWidth(inner)});
|
372 |
+
},
|
373 |
+
|
374 |
+
showSuggestions: function(anySuggests){
|
375 |
+
if (this.newSearch){
|
376 |
+
this.newSearch = false;
|
377 |
+
var width = this.options.fixedWidth || this.element.outerWidth();
|
378 |
+
var inner = $(this.wrapperId).outerWidth(width)
|
379 |
+
.show()
|
380 |
+
.position($.extend({
|
381 |
+
of: this.element
|
382 |
+
},this.options.position))
|
383 |
+
.width();
|
384 |
+
$(this.rightColId).hide();
|
385 |
+
$(this.leftColId).show();
|
386 |
+
this.setColWidth($(this.leftColId),inner);
|
387 |
+
$(this.menuId).css('position','static');
|
388 |
+
this.menu.element.css({'position':'relative','float':'','width':'','top':'0px','left':'0px'});
|
389 |
+
this.currentWidth = this.originalWidth = inner;
|
390 |
+
}
|
391 |
+
if (anySuggests && this.menuId){
|
392 |
+
$(this.menuId).show();
|
393 |
+
}
|
394 |
+
},
|
395 |
+
|
396 |
+
addSearch: function(srch) {
|
397 |
+
if (this.pendingProds || this.pendingAlt){ // wait for both before processing
|
398 |
+
return;
|
399 |
+
}
|
400 |
+
var alts = this.alt;
|
401 |
+
var data = this.prods;
|
402 |
+
$(this.wrapperId).show();
|
403 |
+
if (data && 0 == data.returnCode && data.source && data.source.products && data.source.products.items){
|
404 |
+
var htmlProd = this.generateProducts(data,this.options.products.heading);
|
405 |
+
var htmlAlt = '';
|
406 |
+
if (alts && this.options.altSuggest){
|
407 |
+
htmlAlt = this.options.altSuggest.generateHTML.call(this.options.altSuggest.scope || this,alts,this.options.altSuggest.heading);
|
408 |
+
}
|
409 |
+
var htmlNav = '';
|
410 |
+
var htmlX = '';
|
411 |
+
if (2 == this.options.numCols){
|
412 |
+
htmlNav = this.generateNavigation(data);
|
413 |
+
}
|
414 |
+
else {
|
415 |
+
htmlX = this.generateNavigation(data);
|
416 |
+
}
|
417 |
+
if (htmlNav){ // 2 col
|
418 |
+
$(this.rightColId).addClass('ea-sug-multi-column');
|
419 |
+
}
|
420 |
+
var inner = this.originalWidth;
|
421 |
+
var menuDiv = $(this.menuId);
|
422 |
+
var widthLeft = htmlNav?((inner/2 + .5) | 0):inner; // default 50%
|
423 |
+
if (htmlNav){
|
424 |
+
var splitPos = this.options.leftWidth;
|
425 |
+
if (splitPos){
|
426 |
+
// already a number (default in px)
|
427 |
+
if (!isNaN(splitPos) && 0 < splitPos && splitPos < inner){
|
428 |
+
widthLeft = splitPos | 0;
|
429 |
+
}
|
430 |
+
else {
|
431 |
+
var val = parseFloat(splitPos);
|
432 |
+
if (!isNaN(val)){
|
433 |
+
if (splitPos.charAt(splitPos.length-1) == '%' && 0.0 < val && val < 100.0){
|
434 |
+
widthLeft = (inner * val / 100.0 + .5) | 0;
|
435 |
+
}
|
436 |
+
else if (splitPos.toLowerCase().substring(splitPos.length-2) == 'px' && 0.0 < val && val < inner){
|
437 |
+
widthLeft = val | 0;
|
438 |
+
}
|
439 |
+
}
|
440 |
+
}
|
441 |
+
}
|
442 |
+
}
|
443 |
+
if (htmlNav){
|
444 |
+
$(this.rightColId).show();
|
445 |
+
this.currentWidth = widthLeft;
|
446 |
+
}
|
447 |
+
else {
|
448 |
+
widthLeft = this.originalWidth;
|
449 |
+
$(this.rightColId).hide();
|
450 |
+
}
|
451 |
+
$(this.spacerId).width(inner);
|
452 |
+
if (htmlProd){
|
453 |
+
var cnt = data.source.products.itemDescription.totalItems;
|
454 |
+
if (this.prodId){
|
455 |
+
$(this.prodId).remove();
|
456 |
+
this.prodId = null;
|
457 |
+
}
|
458 |
+
var divProd = $('<div class="ea-sug-section ea-sug-prod ea-sug-section-vertical-space"></div>').uniqueId();
|
459 |
+
this.prodId = '#' + divProd.attr('id');
|
460 |
+
divProd.appendTo($(this.leftColId)).show();
|
461 |
+
}
|
462 |
+
else if (this.prodId){
|
463 |
+
$(this.prodId).remove();
|
464 |
+
this.prodId = null;
|
465 |
+
}
|
466 |
+
if (htmlAlt){
|
467 |
+
if (this.altId){
|
468 |
+
$(this.altId).remove();
|
469 |
+
this.altId = null;
|
470 |
+
}
|
471 |
+
var divProd = $('<div class="ea-sug-section ea-sug-alt ea-sug-section-vertical-space"></div>').uniqueId();
|
472 |
+
this.altId = '#' + divProd.attr('id');
|
473 |
+
divProd.appendTo($(this.leftColId)).show();
|
474 |
+
$(this.altId).html(htmlAlt).show();
|
475 |
+
}
|
476 |
+
else if (this.altId){
|
477 |
+
$(this.altId).remove();
|
478 |
+
this.altId = null;
|
479 |
+
}
|
480 |
+
this.setColWidth($(this.leftColId),widthLeft);
|
481 |
+
var widthRight = inner-widthLeft-2; // 2 for borders on nav
|
482 |
+
if (2 == this.options.numCols && htmlNav){
|
483 |
+
this.setColWidth($(this.rightColId),widthRight);
|
484 |
+
}
|
485 |
+
this.renderNavigation(2 == this.options.numCols?htmlNav:htmlX);
|
486 |
+
if (this.options.products.display){
|
487 |
+
this.renderProducts(htmlProd);
|
488 |
+
}
|
489 |
+
}
|
490 |
+
else if (alts) { // alternate search?
|
491 |
+
if (this.menuId){
|
492 |
+
$(this.menuId).hide();
|
493 |
+
}
|
494 |
+
if (this.prodId){
|
495 |
+
$(this.prodId).remove();
|
496 |
+
this.prodId = null;
|
497 |
+
}
|
498 |
+
if (this.altId){
|
499 |
+
$(this.altId).remove();
|
500 |
+
this.altId = null;
|
501 |
+
}
|
502 |
+
var htmlAlt = this.generateAlt(alts);
|
503 |
+
if (!htmlAlt){
|
504 |
+
$(this.wrapperId).hide();
|
505 |
+
return;
|
506 |
+
}
|
507 |
+
var inner = this.originalWidth;
|
508 |
+
var menuDiv = $(this.menuId);
|
509 |
+
var widthLeft = inner;
|
510 |
+
widthLeft = this.originalWidth;
|
511 |
+
$(this.rightColId).hide();
|
512 |
+
$(this.spacerId).width(inner);
|
513 |
+
this.setColWidth($(this.leftColId),widthLeft);
|
514 |
+
var widthRight = inner-widthLeft-2; // 2 for borders on nav
|
515 |
+
var divProd = $('<div class="ea-sug-section ea-sug-prod"></div>').uniqueId();
|
516 |
+
this.altId = '#' + divProd.attr('id');
|
517 |
+
divProd.appendTo($(this.leftColId)).show();
|
518 |
+
$(this.altId).html(htmlAlt).show();
|
519 |
+
}
|
520 |
+
else {
|
521 |
+
// no products -> no html, widen to original
|
522 |
+
$(this.rightColId).hide();
|
523 |
+
$(this.prodId).hide();
|
524 |
+
$(this.altId).hide();
|
525 |
+
this.setColWidth($(this.leftColId),this.originalWidth);
|
526 |
+
}
|
527 |
+
},
|
528 |
+
generateAlt: function(data){
|
529 |
+
var html = '';
|
530 |
+
if (this.options.altSuggest){
|
531 |
+
html = this.options.altSuggest.generateHTML.call(this,data,this.options.altSuggest.heading);
|
532 |
+
}
|
533 |
+
return html;
|
534 |
+
},
|
535 |
+
generateHeading: function(format, title, value, cnt){
|
536 |
+
var html = '';
|
537 |
+
if (format){
|
538 |
+
var html = format;
|
539 |
+
var idx;
|
540 |
+
if (title){
|
541 |
+
idx = html.indexOf('{title}');
|
542 |
+
if (-1 < idx){
|
543 |
+
html = html.substring(0,idx) + title + html.substring(idx+'{title}'.length);
|
544 |
+
}
|
545 |
+
}
|
546 |
+
if (value){
|
547 |
+
idx = html.indexOf('{value}');
|
548 |
+
if (-1 < idx){
|
549 |
+
html = html.substring(0,idx) + value + html.substring(idx+'{value}'.length);
|
550 |
+
}
|
551 |
+
}
|
552 |
+
if (cnt){
|
553 |
+
var idx = html.indexOf('{count}');
|
554 |
+
if (-1 < idx){
|
555 |
+
html = html.substring(0,idx) + cnt + html.substring(idx+'{count}'.length);
|
556 |
+
}
|
557 |
+
}
|
558 |
+
}
|
559 |
+
return html;
|
560 |
+
},
|
561 |
+
|
562 |
+
generateCategory: function(cat,pathStart){
|
563 |
+
return '<li class="ea-sug-nav-value">' +
|
564 |
+
'<a class="ea-sug-nav-link" ea_link="' + this.htmlEncode(pathStart+cat.nodeString) + '" href="#">' + cat.name + (0 < cat.productCount?('<span class="ea-sug-nav-count"> (' + cat.productCount +')</span>'):'') + '</a></li>';
|
565 |
+
},
|
566 |
+
generateCategories: function(size,title,lstCats,pathStart,format){
|
567 |
+
if (lstCats && 0 < lstCats.length){
|
568 |
+
var lst = '<div class="ea-sug-sec-heading">' + this.generateHeading(format,title,null,lstCats.length) + '</div><ul class="ea-sug-choices">';
|
569 |
+
for(var i = 0; i < size && i < lstCats.length; i++){
|
570 |
+
lst += this.generateCategory(lstCats[i],pathStart);
|
571 |
+
}
|
572 |
+
lst += '</ul>';
|
573 |
+
return lst;
|
574 |
+
}
|
575 |
+
},
|
576 |
+
|
577 |
+
|
578 |
+
generateAttribute: function(av,pathStart){
|
579 |
+
return '<li class="ea-sug-nav-value">' +
|
580 |
+
'<a class="ea-sug-nav-link" ea_link="' + this.htmlEncode(pathStart + av.nodeString) + '" href="#">' + av.attributeValue + (0 < av.productCount?('<span class="ea-sug-nav-count"> (' + av.productCount +')</span>'):'') + '</a></li>';
|
581 |
+
},
|
582 |
+
|
583 |
+
generateAttributes: function(size,title,attr,pathStart,format,full){
|
584 |
+
if (attr){
|
585 |
+
// use full or initial, if initial and none, then use full
|
586 |
+
var valList = full?attr.attributeValueList:(attr.initialAttributeValueList || attr.attributeValueList);
|
587 |
+
if (valList && 0 < valList.length){
|
588 |
+
var lst = '<div class="ea-sug-sec-heading">' + this.generateHeading(format,title,null,valList.length) + '</div><ul class="ea-sug-choices">';
|
589 |
+
for(var i = 0; i < size && i < valList.length; i++){
|
590 |
+
lst += this.generateAttribute(valList[i],pathStart);
|
591 |
+
}
|
592 |
+
lst += '</ul>';
|
593 |
+
return lst;
|
594 |
+
}
|
595 |
+
}
|
596 |
+
},
|
597 |
+
|
598 |
+
getCategories: function(ds,full){
|
599 |
+
// use full or initial list, if initial and none then use full
|
600 |
+
return ds.categories?(full?ds.categories.categoryList:(ds.categories.initialCategoryList || ds.categories.categoryList)):null;
|
601 |
+
},
|
602 |
+
|
603 |
+
getAttributes: function(ds,name){
|
604 |
+
if (ds.attributes){
|
605 |
+
var lcName = name.toLowerCase();
|
606 |
+
for(var i = 0; i < ds.attributes.attribute.length;i++){
|
607 |
+
var attr = ds.attributes.attribute[i];
|
608 |
+
if (attr.name.toLowerCase() == lcName){
|
609 |
+
return attr;
|
610 |
+
}
|
611 |
+
}
|
612 |
+
}
|
613 |
+
return null;
|
614 |
+
},
|
615 |
+
|
616 |
+
SEARCH_NODE: 3,
|
617 |
+
|
618 |
+
getSearch: function(ds){
|
619 |
+
var npl = ds.navPath.navPathNodeList;
|
620 |
+
if (npl && 0 < npl.length){
|
621 |
+
var node = npl[npl.length-1];
|
622 |
+
if (node.navNodePathType == this.SEARCH_NODE){
|
623 |
+
return node.seoPath+'/';
|
624 |
+
}
|
625 |
+
}
|
626 |
+
return "";
|
627 |
+
},
|
628 |
+
textOnly: function(val){
|
629 |
+
if (val){
|
630 |
+
try {
|
631 |
+
return this.txtNode.html(val).text();
|
632 |
+
}
|
633 |
+
catch(err){}
|
634 |
+
}
|
635 |
+
return val;
|
636 |
+
},
|
637 |
+
generateProduct: function(item){
|
638 |
+
var fields = this.options.products.fields;
|
639 |
+
var sizes = this.options.products.sizes;
|
640 |
+
var value = this.options.products.value;
|
641 |
+
var link = value(item,fields.link);
|
642 |
+
var id = fields.id?value(item,fields.id):'';
|
643 |
+
var thumbnail = value(item,fields.thumbnail);
|
644 |
+
var name = this.trimString(this.textOnly(value(item,fields.name)),sizes.name);
|
645 |
+
var price = this.textOnly(value(item,fields.price));
|
646 |
+
var description = this.trimString(this.textOnly(value(item,fields.description)),sizes.description);
|
647 |
+
return '<tr class="ea-sug-product"' + (id?' ea-prod-id="' + this.htmlEncode(id) +'"':'')+'>' +
|
648 |
+
'<td class="ea-sug-product-picture">' +
|
649 |
+
'<a class="ea-sug-product-picture-link" href="' + (link || '#') + '">' +
|
650 |
+
(thumbnail?'<image class="ea-sug-product-image" src="' + thumbnail +'">':'') +
|
651 |
+
'</a>' +
|
652 |
+
'</td>' +
|
653 |
+
'<td class="ea-sug-product-info">' +
|
654 |
+
'<a class="ea-sug-product-info-link" href="' + (link || '#') + '">' +
|
655 |
+
(name?'<div class="ea-sug-product-name">' + name + '</div>':'') +
|
656 |
+
(description?'<div class="ea-sug-product-desc">' + description + '</div>':'') +
|
657 |
+
(price?'<div class="ea-sug-product-price">' + price + '</div>':'') +
|
658 |
+
'</a>' +
|
659 |
+
'</td>' +
|
660 |
+
'</tr>';
|
661 |
+
},
|
662 |
+
|
663 |
+
generateProducts: function(data,heading){
|
664 |
+
var ds = this.options.products.display && data && 0 == data.returnCode?data.source:null;
|
665 |
+
if (ds && ds.products && ds.products.items){
|
666 |
+
var cnt = ds.products.itemDescription.totalItems;
|
667 |
+
var html = '';
|
668 |
+
if (heading && heading.display){
|
669 |
+
html = '<div class="ea-sug-sec-heading">' + this.generateHeading(heading.format,null,null,cnt) + '</div>';
|
670 |
+
}
|
671 |
+
html += '<table class="ea-sug-products" border="0" style="width:100%"><tbody>';
|
672 |
+
var self = this;
|
673 |
+
$.map( data.source.products.items, function(item,_idx){
|
674 |
+
html += self.generateProduct(item);
|
675 |
+
});
|
676 |
+
html += '</tbody></table>';
|
677 |
+
if (this.options.numCols == 1){
|
678 |
+
html += ('<div class="ea-sug-section-vertical-space" style="clear:both;height:30px"></div>');
|
679 |
+
html += ('<div class="ea-sug-nav-tm"> </div>');
|
680 |
+
}
|
681 |
+
|
682 |
+
return html;
|
683 |
+
}
|
684 |
+
return null;
|
685 |
+
},
|
686 |
+
|
687 |
+
// defaultSectionHeaderFormat: '<span class="ea-sug-sec-head-title">{title}</span><span class="ea-sug-sec-head-count">{count}</span>',
|
688 |
+
|
689 |
+
generateNavigation: function(data){
|
690 |
+
var ds = data && 0 == data.returnCode?data.source:null;
|
691 |
+
if (ds){
|
692 |
+
var navOpts = this.options.navigation.sections || [];
|
693 |
+
var html = '';
|
694 |
+
var navGenerated = 0;
|
695 |
+
var pathStart = this.getSearch(ds);
|
696 |
+
var maxSections = this.options.navigation.size || 2;
|
697 |
+
for(var i = 0; i < navOpts.length && navGenerated < maxSections; i++){
|
698 |
+
var classType = '';
|
699 |
+
var itemHtml = null;
|
700 |
+
var navOpt = navOpts[i];
|
701 |
+
var format = null;
|
702 |
+
if (navOpts.heading){
|
703 |
+
if (navOpts.heading.display){
|
704 |
+
format = navOpts.heading.format || this.options.navigation.heading.display;
|
705 |
+
}
|
706 |
+
}
|
707 |
+
else if (this.options.navigation.heading.display){
|
708 |
+
format = this.options.navigation.heading.format;
|
709 |
+
}
|
710 |
+
if (navOpt.type.toLowerCase() == 'category'){
|
711 |
+
itemHtml = this.generateCategories(navOpt.size,navOpt.title || 'Category',this.getCategories(ds,navOpt.full),pathStart,format);
|
712 |
+
classType = ' ea-sug-cat';
|
713 |
+
}
|
714 |
+
else {
|
715 |
+
itemHtml = this.generateAttributes(navOpt.size,navOpt.title,this.getAttributes(ds,navOpt.type),pathStart,format,navOpt.full);
|
716 |
+
classType = ' ea-sug-attr';
|
717 |
+
}
|
718 |
+
if (itemHtml){
|
719 |
+
var extraClass = 0 == navGenerated++?'':' ea-sug-section-vertical-space';
|
720 |
+
html += ('<div class="ea-sug-section' + classType + extraClass + '">'+itemHtml+'</div>');
|
721 |
+
}
|
722 |
+
}
|
723 |
+
if (html && 1 != this.options.numCols){
|
724 |
+
html += ('<div class="ea-sug-section-vertical-space" style="clear:both;height:30px"></div>');
|
725 |
+
html += ('<div class="ea-sug-nav-tm"> </div>');
|
726 |
+
}
|
727 |
+
return html;
|
728 |
+
}
|
729 |
+
return null;
|
730 |
+
},
|
731 |
+
|
732 |
+
renderProducts: function(html){
|
733 |
+
$(this.prodId).html(html).show();
|
734 |
+
$('.ea-sug-product').each(function(){
|
735 |
+
$(this).hover(function() {
|
736 |
+
$(this).find('.ea-sug-product-name').toggleClass('ui-state-hover');
|
737 |
+
$(this).find('.ea-sug-product-desc').toggleClass('ui-state-hover');
|
738 |
+
});
|
739 |
+
});
|
740 |
+
$('.ea-sug-product :not(:last)').find('.ea-sug-product-info').addClass('ea-sug-product-separator');
|
741 |
+
$('.ea-sug-product-name').addClass('ui-corner-all');
|
742 |
+
$('tr.ea-sug-product').hover(function(){
|
743 |
+
$(this).toggleClass('ea-state-hover');
|
744 |
+
});
|
745 |
+
},
|
746 |
+
|
747 |
+
renderNavigation: function(html){
|
748 |
+
if (html){
|
749 |
+
var nav = '';
|
750 |
+
if (2 == this.options.numCols){
|
751 |
+
nav = $(this.rightColId);
|
752 |
+
nav.empty().append($(html));
|
753 |
+
nav.find('.ea-sug-section').find('li :last').after($('<div class="ea-sug-last-spacer"></div>')) // last entries in each section need padding
|
754 |
+
}
|
755 |
+
else {
|
756 |
+
var navOptions = $(html).find('ul'); // get the beginning of the nav options
|
757 |
+
nav = $('.ea-sug-menu');
|
758 |
+
if (this.options.navigation.embed){
|
759 |
+
|
760 |
+
// put them inline under the focus menu or the first one
|
761 |
+
$(nav).find('.ea-sug-choices').remove(); // remove any existing options
|
762 |
+
var choice = nav.find('li a.ui-state-focus');
|
763 |
+
if (!choice.length){ // nothing focused, select first one
|
764 |
+
choice = nav.find('li:first a');
|
765 |
+
}
|
766 |
+
$(choice).parent().append(navOptions);
|
767 |
+
}
|
768 |
+
else {
|
769 |
+
$(nav).find('.ea-sug-section-vertical-space').remove();
|
770 |
+
$(nav).find('.ea-sug-section').remove();
|
771 |
+
$(nav).append(html);
|
772 |
+
}
|
773 |
+
}
|
774 |
+
nav.show();
|
775 |
+
var widget = this
|
776 |
+
$('a.ea-sug-nav-link').each(function(){
|
777 |
+
var link = $(this);
|
778 |
+
link.unbind('click').click(function(event){
|
779 |
+
widget.close();
|
780 |
+
widget.options.submitFctn('nav',$(link).attr('ea_link'));
|
781 |
+
return false;
|
782 |
+
});
|
783 |
+
});
|
784 |
+
$('.ea-sug-nav-value').each(function(){
|
785 |
+
$(this).addClass('ui-corner-all')
|
786 |
+
.click(function(){
|
787 |
+
$(this).closest('.ea-sug-nav-value').find('a.ea-sug-nav-link').click();
|
788 |
+
}).hover(function() {
|
789 |
+
$(this).toggleClass('ui-state-hover ui-state-focus');
|
790 |
+
});
|
791 |
+
});
|
792 |
+
|
793 |
+
}
|
794 |
+
else if (2 != this.options.numCols){
|
795 |
+
$('.ea-sug-menu').find('.ea-sug-choices').remove(); // clean up any existing suggestions that are inline
|
796 |
+
$('.ea-sug-cat').hide(); //if no categories, hide the category section
|
797 |
+
// $('.ea-sug-section-vertical-space').hide();
|
798 |
+
// $('.ea-sug-nav-tm').hide();
|
799 |
+
}
|
800 |
+
|
801 |
+
return;
|
802 |
+
},
|
803 |
+
|
804 |
+
findProducts: function(q,s){
|
805 |
+
if (this.options.products){
|
806 |
+
if (this.lastSearch == q){
|
807 |
+
return;
|
808 |
+
}
|
809 |
+
this.lastSearch=q;
|
810 |
+
this.getProducts(q,s);
|
811 |
+
}
|
812 |
+
},
|
813 |
+
findAlt: function(q,s){
|
814 |
+
if (this.options.altSuggest){
|
815 |
+
if (this.lastAlt == q){
|
816 |
+
return;
|
817 |
+
}
|
818 |
+
this.lastAlt = q;
|
819 |
+
this.getAlt(q,s);
|
820 |
+
}
|
821 |
+
},
|
822 |
+
htmlEncode: function (str) {
|
823 |
+
return String(str)
|
824 |
+
.replace(/&/g, '&')
|
825 |
+
.replace(/"/g, '"')
|
826 |
+
.replace(/'/g, ''')
|
827 |
+
.replace(/</g, '<')
|
828 |
+
.replace(/>/g, '>');
|
829 |
+
},
|
830 |
+
|
831 |
+
getProducts: function(q,s){
|
832 |
+
this.pendingProds = true;
|
833 |
+
var self = this;
|
834 |
+
$.ajax({
|
835 |
+
url: self.options.serverSearch + self.options.urlSearch + '?' + self.options.defaultSearchParams + '&customer=easayt',
|
836 |
+
dataType: 'jsonp',
|
837 |
+
data: {
|
838 |
+
dct: this.options.dict,
|
839 |
+
q: q,
|
840 |
+
ResultsPerPage: this.options.products.size
|
841 |
+
},
|
842 |
+
success: function(prods){
|
843 |
+
self.pendingProds = false;
|
844 |
+
self.prods = prods;
|
845 |
+
self.addSearch(s);
|
846 |
+
},
|
847 |
+
failure: function(data){
|
848 |
+
self.pendingProds = false;
|
849 |
+
self.prods = null;
|
850 |
+
self.addSearch(s);
|
851 |
+
}
|
852 |
+
});
|
853 |
+
},
|
854 |
+
getAlt: function(q,s){
|
855 |
+
this.pendingAlt = true;
|
856 |
+
var self = this;
|
857 |
+
$.ajax({
|
858 |
+
url: self.options.altSuggest.url + '?' + self.options.altSuggest.defaultParams,
|
859 |
+
dataType: self.options.altSuggest.ajaxMethod,
|
860 |
+
data: {
|
861 |
+
q: q
|
862 |
+
},
|
863 |
+
success: function(prods){
|
864 |
+
self.pendingAlt = false;
|
865 |
+
self.alt = prods;
|
866 |
+
self.addSearch(s);
|
867 |
+
},
|
868 |
+
failure: function(data){
|
869 |
+
self.pendingAlt = false;
|
870 |
+
self.alt = null;
|
871 |
+
addSearch(s)
|
872 |
+
}
|
873 |
+
});
|
874 |
+
}
|
875 |
+
});
|
876 |
+
});
|
877 |
+
}(jQuery ));
|
878 |
+
}(window.$ea || window.eaj$183 || jQuery));
|
js/easyask/2.0/ea-autocomplete-2.0.1.js_save
ADDED
@@ -0,0 +1,881 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*! Copyright (c) 2000-2014 EasyAsk Technologies, Inc. All Rights Reserved.
|
2 |
+
* Use, reproduction, transfer, publication or disclosure is prohibited
|
3 |
+
* except in accordance with the License Agreement.
|
4 |
+
*/
|
5 |
+
(function(jQuery){
|
6 |
+
(function( $, _undefined ) {
|
7 |
+
var jquiver = ($.ui ? $.ui.version || '1.5': '1.5').split('.');
|
8 |
+
var AUTOCOMPLETE_WIDGET = (1 <= parseInt(jquiver[0]) && 10 <= parseInt(jquiver[1]))?"ui-autocomplete":"autocomplete";
|
9 |
+
EAAutoComplete = function(){
|
10 |
+
return {
|
11 |
+
defaults: {
|
12 |
+
dict: null,
|
13 |
+
submitFctn: function () {},
|
14 |
+
id: 'question',
|
15 |
+
sort: 'weight',
|
16 |
+
reduce: 'cluster',
|
17 |
+
matchAllSearchWords: true,
|
18 |
+
matchAnySuggestionWord: true,
|
19 |
+
boostExact: false,
|
20 |
+
delay: 300,
|
21 |
+
minLength: 2,
|
22 |
+
prompt: null,
|
23 |
+
handler: null,
|
24 |
+
serverSearch: '',
|
25 |
+
defaultSearchParams: 'indexed=1&oneshot=1&ie=UTF-8&disp=json&RequestAction=advisor&RequestData=CA_Search&CatPath=All Products&defarrangeby=////NONE////',
|
26 |
+
urlSearch: '/EasyAsk/apps/Advisor.jsp',
|
27 |
+
server: '',
|
28 |
+
url: '/EasyAsk/AutoComplete-1.2.1.jsp',
|
29 |
+
xOffset: 0,
|
30 |
+
yOffset: 0,
|
31 |
+
widthOffset: 0,
|
32 |
+
numCols: 2,
|
33 |
+
search: {
|
34 |
+
heading:{
|
35 |
+
display: true,
|
36 |
+
format: '<span class="ea-sug-sec-head-title">Search Suggestions for: </span><span class="ea-sug-sec-head-value">{value}</span>'
|
37 |
+
},
|
38 |
+
size: 5
|
39 |
+
}
|
40 |
+
},
|
41 |
+
defaultProducts: {
|
42 |
+
products: {
|
43 |
+
size: 5,
|
44 |
+
display: true,
|
45 |
+
value: function(item,field){ return item[field]; },
|
46 |
+
fields: {
|
47 |
+
thumbnail: 'thumbnail',
|
48 |
+
name: 'name',
|
49 |
+
link: 'link',
|
50 |
+
description: 'description',
|
51 |
+
price: 'price'
|
52 |
+
},
|
53 |
+
heading:{
|
54 |
+
display:true,
|
55 |
+
format: '<span class="ea-sug-sec-head-title">Products</span><span class="ea-sug-sec-head-count">total: {count}</span>'
|
56 |
+
},
|
57 |
+
|
58 |
+
sizes: {
|
59 |
+
name: 45,
|
60 |
+
description: 100
|
61 |
+
}
|
62 |
+
},
|
63 |
+
navigation: {
|
64 |
+
size: 2,
|
65 |
+
embed: false,
|
66 |
+
heading:{
|
67 |
+
display: true,
|
68 |
+
format: '<span class="ea-sug-sec-head-title">{title}</span><span class="ea-sug-sec-head-count">total: {count}</span>'
|
69 |
+
},
|
70 |
+
sections: [{
|
71 |
+
type: 'category',
|
72 |
+
size: 5,
|
73 |
+
title: 'Category'
|
74 |
+
}]
|
75 |
+
}
|
76 |
+
},
|
77 |
+
init: function(opts, dct){
|
78 |
+
var options = $.extend(true,this.defaults,{
|
79 |
+
dict: dct,
|
80 |
+
position: {
|
81 |
+
collision: "none",
|
82 |
+
my: (opts.horizAlign || "right") + " top",
|
83 |
+
at: (opts.horizAlign || "right") + " bottom"
|
84 |
+
}
|
85 |
+
},opts.products?$.extend(true,{},this.defaultProducts,opts):opts);
|
86 |
+
if (options.dict){
|
87 |
+
if (options.xOffset || options.yOffset){
|
88 |
+
options.position.offset = options.xOffset + " " + options.yOffset;
|
89 |
+
}
|
90 |
+
this._init(options);
|
91 |
+
}
|
92 |
+
var self = this;
|
93 |
+
$(window).resize(function(){
|
94 |
+
setTimeout(function(){
|
95 |
+
self._widget.reposition();
|
96 |
+
},10);
|
97 |
+
});
|
98 |
+
|
99 |
+
return this;
|
100 |
+
},
|
101 |
+
_init: function(opts){
|
102 |
+
var options = $.extend({},opts,{
|
103 |
+
source: function(request, response ) {
|
104 |
+
this.lastSearch = null;
|
105 |
+
var self = this;
|
106 |
+
this.pendingAlt = false;
|
107 |
+
this.alt = null;
|
108 |
+
this.pendingProds = false;
|
109 |
+
this.prods = null;
|
110 |
+
$.ajax({
|
111 |
+
url: self.options.server + self.options.url,
|
112 |
+
dataType: "jsonp",
|
113 |
+
data: {
|
114 |
+
dct: self.options.dict,
|
115 |
+
num: self.options.search.size,
|
116 |
+
key: request.term,
|
117 |
+
sort: self.options.sort,
|
118 |
+
reduce: self.options.reduce,
|
119 |
+
match: self.options.matchAllSearchWords,
|
120 |
+
anchor: self.options.matchAnySuggestionWord
|
121 |
+
},
|
122 |
+
success: function( data ) {
|
123 |
+
if (data.suggests && data.suggests.length && data.input == self._value()){
|
124 |
+
if (self.options.handler){
|
125 |
+
self.options.handler(data.input,data.suggests);
|
126 |
+
}
|
127 |
+
else {
|
128 |
+
if (self.options.boostExact){
|
129 |
+
//pull any exact matches to the front
|
130 |
+
var lcTerm = request.term.toLowerCase();
|
131 |
+
for(var i = 0; i < data.suggests.length; i++){
|
132 |
+
var item = data.suggests[i];
|
133 |
+
if (item.val.toLowerCase() == lcTerm){
|
134 |
+
if (0 < i){
|
135 |
+
data.suggests.splice(i,1);
|
136 |
+
data.suggests.unshift(item);
|
137 |
+
break;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
response( $.map( data.suggests, function( item, _idx ) {
|
143 |
+
var obj = {
|
144 |
+
label: item.val,
|
145 |
+
value: item.val,
|
146 |
+
start: item.start,
|
147 |
+
end: item.end
|
148 |
+
};
|
149 |
+
if (0 == _idx){
|
150 |
+
obj['className'] = 'ea-search-selection';
|
151 |
+
}
|
152 |
+
return obj;
|
153 |
+
}));
|
154 |
+
}
|
155 |
+
// add a spacer for options (rounded corners);
|
156 |
+
self.menu.element.find('li:last').after($('<div class="ea-sug-last-spacer"></div>'));
|
157 |
+
self.findProducts(data.suggests[0].val,true);
|
158 |
+
self.newSearch = true;
|
159 |
+
self.findAlt(request.term);
|
160 |
+
self.showSuggestions(true);
|
161 |
+
}
|
162 |
+
else if (self.options.altSuggest){
|
163 |
+
self.newSearch = true;
|
164 |
+
self.findAlt(request.term);
|
165 |
+
self.showSuggestions(false);
|
166 |
+
}
|
167 |
+
else {
|
168 |
+
$(self.wrapperId).hide();
|
169 |
+
}
|
170 |
+
}
|
171 |
+
});
|
172 |
+
},
|
173 |
+
|
174 |
+
select: function( event, ui ) {
|
175 |
+
var widget = $(this).data(AUTOCOMPLETE_WIDGET);
|
176 |
+
setTimeout(function(){
|
177 |
+
widget.term = '';
|
178 |
+
widget.options.submitFctn();
|
179 |
+
},10); // let the select complete then process it
|
180 |
+
},
|
181 |
+
|
182 |
+
create: function(evt, ui){
|
183 |
+
var widget = $(this).data(AUTOCOMPLETE_WIDGET);
|
184 |
+
widget._on({
|
185 |
+
keydown: function(event){
|
186 |
+
var keyCode = $.ui.keyCode;
|
187 |
+
if (keyCode.ENTER == event.keyCode || keyCode.NUMPAD_ENTER == event.keyCode){
|
188 |
+
clearTimeout(widget.searching);
|
189 |
+
if (!widget.menu.active && widget.menu.element.is(':visible')){
|
190 |
+
setTimeout(function(){widget.close(event);},10);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
}
|
194 |
+
});
|
195 |
+
},
|
196 |
+
open: function() {
|
197 |
+
var widget = $(this).data(AUTOCOMPLETE_WIDGET);
|
198 |
+
widget.openCnt++;
|
199 |
+
this.currentWidth = undefined;
|
200 |
+
if (widget.wrapperId){
|
201 |
+
$(widget.wrapperId).show();
|
202 |
+
}
|
203 |
+
|
204 |
+
},
|
205 |
+
|
206 |
+
close: function(event,ui) {
|
207 |
+
var widget = $(this).data(AUTOCOMPLETE_WIDGET);
|
208 |
+
widget.openCnt = 0;
|
209 |
+
this.currentWidth = undefined;
|
210 |
+
widget.term = ''; // clear copy since using ajax
|
211 |
+
$(widget.wrapperId).hide();
|
212 |
+
},
|
213 |
+
|
214 |
+
focus: function(event,ui){
|
215 |
+
if (ui.item && (event.keyCode || $(this).data(AUTOCOMPLETE_WIDGET).options.hover)){ // only on keyboard unless hover
|
216 |
+
$('.ea-sug-section .ea-search-selection').removeClass('ea-search-selection'); // clear out any
|
217 |
+
$('.ea-sug-section a.ui-state-focus').addClass('ea-search-selection'); // add this one
|
218 |
+
$(this).data(AUTOCOMPLETE_WIDGET).findProducts(ui.item.label,false);
|
219 |
+
}
|
220 |
+
}
|
221 |
+
});
|
222 |
+
this._widget = $('#' + options.id).autocomplete(options).data(AUTOCOMPLETE_WIDGET);
|
223 |
+
// emulate placeholder support if prompt is specified
|
224 |
+
if (options.prompt){
|
225 |
+
var supportsPlaceholder = ('placeholder' in document.createElement('input'));
|
226 |
+
if (supportsPlaceholder){
|
227 |
+
$('#' + options.id).attr('placeholder',options.prompt);
|
228 |
+
}
|
229 |
+
else {
|
230 |
+
$('#' + options.id).each(function(){
|
231 |
+
var placeholder = options.prompt;
|
232 |
+
if ($(this).val() === '') {
|
233 |
+
$(this).val(placeholder).addClass('ea-sug-placeholder');
|
234 |
+
}
|
235 |
+
$(this).bind('focus',function() {
|
236 |
+
if ($(this).val() === placeholder) {
|
237 |
+
$(this).val('').removeClass('ea-sug-placeholder');
|
238 |
+
}
|
239 |
+
})
|
240 |
+
.bind('blur',function() {
|
241 |
+
if ($(this).val() === '' && $(this).val() !== placeholder) {
|
242 |
+
$(this).val(placeholder).addClass('ea-sug-placeholder');
|
243 |
+
}
|
244 |
+
});
|
245 |
+
});
|
246 |
+
}
|
247 |
+
}
|
248 |
+
},
|
249 |
+
disable: function() {
|
250 |
+
this._widget.cancelSearch = true;
|
251 |
+
}
|
252 |
+
};
|
253 |
+
};
|
254 |
+
|
255 |
+
$(function() {
|
256 |
+
var acprototype = $.ui.autocomplete.prototype;
|
257 |
+
var ac_renderMenu = acprototype._renderMenu;
|
258 |
+
var ac_create = acprototype._create;
|
259 |
+
$.extend(acprototype,{
|
260 |
+
openCnt: 0,
|
261 |
+
// overrides
|
262 |
+
_create: function(){
|
263 |
+
ac_create.call(this);
|
264 |
+
this.element.attr("spellcheck","false");
|
265 |
+
var menu = this.menu.element;
|
266 |
+
var zindex = parseInt(this.options.zIndex || menu.css('z-index')) || 100;
|
267 |
+
var widget = this;
|
268 |
+
var divWrapper = $('<div class="ea-sug-wrapper" ></div>')
|
269 |
+
.on(
|
270 |
+
'mousedown', function(event){
|
271 |
+
event.preventDefault();
|
272 |
+
widget.cancelBlur = true;
|
273 |
+
widget._delay(function() {
|
274 |
+
delete widget.cancelBlur;
|
275 |
+
});
|
276 |
+
})
|
277 |
+
.zIndex(zindex)
|
278 |
+
.width('0px')
|
279 |
+
.css('display','none')
|
280 |
+
.css('clear','both')
|
281 |
+
.uniqueId().appendTo('body');
|
282 |
+
this.wrapperId = '#' + divWrapper.attr('id');
|
283 |
+
var divLeftCol = $('<div class="ea-sug-nav ea-sug-nav-left" style="float:left;display:none;z-index:' + (zindex+1) + '"></div>')
|
284 |
+
.uniqueId().appendTo(divWrapper);
|
285 |
+
this.leftColId = '#' + divLeftCol.attr('id');
|
286 |
+
var divMenu = $('<div class="ea-sug-section"></div>').uniqueId().appendTo(divLeftCol);
|
287 |
+
this.menuId = '#'+divMenu.attr('id');
|
288 |
+
if (this.options.search && this.options.search.heading.display){
|
289 |
+
$('<div class="ea-sug-sec-heading ea-sug-sug">'+this.generateHeading(this.options.search.heading.format,null,' ',null)+ '</div>').appendTo(divMenu);
|
290 |
+
}
|
291 |
+
menu.zIndex((zindex+1).toString());
|
292 |
+
menu.removeClass('ui-corner-all ui-autocomplete').detach().appendTo(divMenu);
|
293 |
+
this.rightColId = '#' + $('<div class="ea-sug-nav ea-sug-nav-right" style="float:left;display:none;z-index:' + (zindex+1) + '"></div>')
|
294 |
+
.uniqueId().appendTo(divWrapper).attr('id');
|
295 |
+
this.spacerId = '#'+$('<div class="ea-sug-spacer" style="height:0px;clear:both;"></div>').uniqueId().appendTo(divWrapper).attr('id');
|
296 |
+
this.txtNode = $('<span style="display:none;"></span>');
|
297 |
+
},
|
298 |
+
_renderItem: function(ul,item){
|
299 |
+
var anchor = '<a class="ui-corner-all' + (item.className?' ' + item.className:'') + '"></a>';
|
300 |
+
return $('<li class="ui-menu-item" style="width:auto;"></li>')
|
301 |
+
.append($(anchor).data('ui-autocomplete-item',item)
|
302 |
+
.append($('<div></div>').css('whiteSpace','nowrap')
|
303 |
+
.append($('<span class="ea-sug-text">' + item.label.substring(0,item.start) +
|
304 |
+
'</span><span class="ea-sug-match">' + item.label.substring(item.start,item.end) +
|
305 |
+
'</span><span class="ea-sug-text">' + item.label.substring(item.end)+'</span>'))))
|
306 |
+
.appendTo(ul);
|
307 |
+
},
|
308 |
+
_renderMenu: function( ul, items ) {
|
309 |
+
$(this.menuId + ' .ea-sug-sec-head-value').text('"' + this.term + '"');
|
310 |
+
ac_renderMenu.call(this,ul,items);
|
311 |
+
ul.addClass('ea-sug-menu').removeClass('ui-widget-content');
|
312 |
+
},
|
313 |
+
_resizeMenu: function() {
|
314 |
+
var ul = this.menu.element;
|
315 |
+
if (ul.is(':hidden')){
|
316 |
+
ul.outerWidth( Math.max(
|
317 |
+
// Firefox wraps long text (possibly a rounding bug)
|
318 |
+
// so we add 1px to avoid the wrapping (#7513)
|
319 |
+
ul.width( "" ).outerWidth() + 1,
|
320 |
+
this.options.fixedWidth || this.element.outerWidth()
|
321 |
+
) );
|
322 |
+
}
|
323 |
+
},
|
324 |
+
_suggest: function( items ) {
|
325 |
+
var ul = this.menu.element
|
326 |
+
.empty()
|
327 |
+
.zIndex( this.element.zIndex() + 1 );
|
328 |
+
this._renderMenu( ul, items );
|
329 |
+
this.menu.refresh();
|
330 |
+
|
331 |
+
// size and position menu
|
332 |
+
var wasHidden = ul.is(':hidden');
|
333 |
+
ul.show();
|
334 |
+
this._resizeMenu();
|
335 |
+
if (wasHidden) {
|
336 |
+
ul.position( $.extend({
|
337 |
+
of: this.element
|
338 |
+
}, this.options.position ));
|
339 |
+
}
|
340 |
+
if ( this.options.autoFocus ) {
|
341 |
+
this.menu.next();
|
342 |
+
}
|
343 |
+
},
|
344 |
+
reposition: function(){
|
345 |
+
if (!this.menu.element.is(':hidden')){
|
346 |
+
$(this.wrapperId)
|
347 |
+
.position($.extend({
|
348 |
+
of: this.element
|
349 |
+
},this.options.position));
|
350 |
+
}
|
351 |
+
},
|
352 |
+
// extensions
|
353 |
+
trimString: function(val, len){
|
354 |
+
if (val){
|
355 |
+
if (val.length < len){
|
356 |
+
return val;
|
357 |
+
}
|
358 |
+
else {
|
359 |
+
var sub = val.substring(0,len);
|
360 |
+
var idx = sub.lastIndexOf(' ');
|
361 |
+
if (-1 < idx){
|
362 |
+
sub = sub.substring(0,idx);
|
363 |
+
}
|
364 |
+
sub += '...';
|
365 |
+
return sub;
|
366 |
+
}
|
367 |
+
}
|
368 |
+
return val;
|
369 |
+
},
|
370 |
+
|
371 |
+
setColWidth: function(elt,width){
|
372 |
+
elt.outerWidth(width);
|
373 |
+
var inner = elt.width();
|
374 |
+
elt.children('.ea-sug-section').each(function(){$(this).outerWidth(inner)});
|
375 |
+
},
|
376 |
+
|
377 |
+
showSuggestions: function(anySuggests){
|
378 |
+
if (this.newSearch){
|
379 |
+
this.newSearch = false;
|
380 |
+
var width = this.options.fixedWidth || this.element.outerWidth();
|
381 |
+
var inner = $(this.wrapperId).outerWidth(width)
|
382 |
+
.show()
|
383 |
+
.position($.extend({
|
384 |
+
of: this.element
|
385 |
+
},this.options.position))
|
386 |
+
.width();
|
387 |
+
$(this.rightColId).hide();
|
388 |
+
$(this.leftColId).show();
|
389 |
+
this.setColWidth($(this.leftColId),inner);
|
390 |
+
$(this.menuId).css('position','static');
|
391 |
+
this.menu.element.css({'position':'relative','float':'','width':'','top':'0px','left':'0px'});
|
392 |
+
this.currentWidth = this.originalWidth = inner;
|
393 |
+
}
|
394 |
+
if (anySuggests && this.menuId){
|
395 |
+
$(this.menuId).show();
|
396 |
+
}
|
397 |
+
},
|
398 |
+
|
399 |
+
addSearch: function(srch) {
|
400 |
+
if (this.pendingProds || this.pendingAlt){ // wait for both before processing
|
401 |
+
return;
|
402 |
+
}
|
403 |
+
var alts = this.alt;
|
404 |
+
var data = this.prods;
|
405 |
+
$(this.wrapperId).show();
|
406 |
+
if (data && 0 == data.returnCode && data.source && data.source.products && data.source.products.items){
|
407 |
+
var htmlProd = this.generateProducts(data,this.options.products.heading);
|
408 |
+
var htmlAlt = '';
|
409 |
+
if (alts && this.options.altSuggest){
|
410 |
+
htmlAlt = this.options.altSuggest.generateHTML.call(this.options.altSuggest.scope || this,alts,this.options.altSuggest.heading);
|
411 |
+
}
|
412 |
+
var htmlNav = '';
|
413 |
+
var htmlX = '';
|
414 |
+
if (2 == this.options.numCols){
|
415 |
+
htmlNav = this.generateNavigation(data);
|
416 |
+
}
|
417 |
+
else {
|
418 |
+
htmlX = this.generateNavigation(data);
|
419 |
+
}
|
420 |
+
if (htmlNav){ // 2 col
|
421 |
+
$(this.rightColId).addClass('ea-sug-multi-column');
|
422 |
+
}
|
423 |
+
var inner = this.originalWidth;
|
424 |
+
var menuDiv = $(this.menuId);
|
425 |
+
var widthLeft = htmlNav?((inner/2 + .5) | 0):inner; // default 50%
|
426 |
+
if (htmlNav){
|
427 |
+
var splitPos = this.options.leftWidth;
|
428 |
+
if (splitPos){
|
429 |
+
// already a number (default in px)
|
430 |
+
if (!isNaN(splitPos) && 0 < splitPos && splitPos < inner){
|
431 |
+
widthLeft = splitPos | 0;
|
432 |
+
}
|
433 |
+
else {
|
434 |
+
var val = parseFloat(splitPos);
|
435 |
+
if (!isNaN(val)){
|
436 |
+
if (splitPos.charAt(splitPos.length-1) == '%' && 0.0 < val && val < 100.0){
|
437 |
+
widthLeft = (inner * val / 100.0 + .5) | 0;
|
438 |
+
}
|
439 |
+
else if (splitPos.toLowerCase().substring(splitPos.length-2) == 'px' && 0.0 < val && val < inner){
|
440 |
+
widthLeft = val | 0;
|
441 |
+
}
|
442 |
+
}
|
443 |
+
}
|
444 |
+
}
|
445 |
+
}
|
446 |
+
if (htmlNav){
|
447 |
+
$(this.rightColId).show();
|
448 |
+
this.currentWidth = widthLeft;
|
449 |
+
}
|
450 |
+
else {
|
451 |
+
widthLeft = this.originalWidth;
|
452 |
+
$(this.rightColId).hide();
|
453 |
+
}
|
454 |
+
$(this.spacerId).width(inner);
|
455 |
+
if (htmlProd){
|
456 |
+
var cnt = data.source.products.itemDescription.totalItems;
|
457 |
+
if (this.prodId){
|
458 |
+
$(this.prodId).remove();
|
459 |
+
this.prodId = null;
|
460 |
+
}
|
461 |
+
var divProd = $('<div class="ea-sug-section ea-sug-prod ea-sug-section-vertical-space"></div>').uniqueId();
|
462 |
+
this.prodId = '#' + divProd.attr('id');
|
463 |
+
divProd.appendTo($(this.leftColId)).show();
|
464 |
+
}
|
465 |
+
else if (this.prodId){
|
466 |
+
$(this.prodId).remove();
|
467 |
+
this.prodId = null;
|
468 |
+
}
|
469 |
+
if (htmlAlt){
|
470 |
+
if (this.altId){
|
471 |
+
$(this.altId).remove();
|
472 |
+
this.altId = null;
|
473 |
+
}
|
474 |
+
var divProd = $('<div class="ea-sug-section ea-sug-alt ea-sug-section-vertical-space"></div>').uniqueId();
|
475 |
+
this.altId = '#' + divProd.attr('id');
|
476 |
+
divProd.appendTo($(this.leftColId)).show();
|
477 |
+
$(this.altId).html(htmlAlt).show();
|
478 |
+
}
|
479 |
+
else if (this.altId){
|
480 |
+
$(this.altId).remove();
|
481 |
+
this.altId = null;
|
482 |
+
}
|
483 |
+
this.setColWidth($(this.leftColId),widthLeft);
|
484 |
+
var widthRight = inner-widthLeft-2; // 2 for borders on nav
|
485 |
+
if (2 == this.options.numCols && htmlNav){
|
486 |
+
this.setColWidth($(this.rightColId),widthRight);
|
487 |
+
}
|
488 |
+
this.renderNavigation(2 == this.options.numCols?htmlNav:htmlX);
|
489 |
+
if (this.options.products.display){
|
490 |
+
this.renderProducts(htmlProd);
|
491 |
+
}
|
492 |
+
}
|
493 |
+
else if (alts) { // alternate search?
|
494 |
+
if (this.menuId){
|
495 |
+
$(this.menuId).hide();
|
496 |
+
}
|
497 |
+
if (this.prodId){
|
498 |
+
$(this.prodId).remove();
|
499 |
+
this.prodId = null;
|
500 |
+
}
|
501 |
+
if (this.altId){
|
502 |
+
$(this.altId).remove();
|
503 |
+
this.altId = null;
|
504 |
+
}
|
505 |
+
var htmlAlt = this.generateAlt(alts);
|
506 |
+
if (!htmlAlt){
|
507 |
+
$(this.wrapperId).hide();
|
508 |
+
return;
|
509 |
+
}
|
510 |
+
var inner = this.originalWidth;
|
511 |
+
var menuDiv = $(this.menuId);
|
512 |
+
var widthLeft = inner;
|
513 |
+
widthLeft = this.originalWidth;
|
514 |
+
$(this.rightColId).hide();
|
515 |
+
$(this.spacerId).width(inner);
|
516 |
+
this.setColWidth($(this.leftColId),widthLeft);
|
517 |
+
var widthRight = inner-widthLeft-2; // 2 for borders on nav
|
518 |
+
var divProd = $('<div class="ea-sug-section ea-sug-prod"></div>').uniqueId();
|
519 |
+
this.altId = '#' + divProd.attr('id');
|
520 |
+
divProd.appendTo($(this.leftColId)).show();
|
521 |
+
$(this.altId).html(htmlAlt).show();
|
522 |
+
}
|
523 |
+
else {
|
524 |
+
// no products -> no html, widen to original
|
525 |
+
$(this.rightColId).hide();
|
526 |
+
$(this.prodId).hide();
|
527 |
+
$(this.altId).hide();
|
528 |
+
this.setColWidth($(this.leftColId),this.originalWidth);
|
529 |
+
}
|
530 |
+
},
|
531 |
+
generateAlt: function(data){
|
532 |
+
var html = '';
|
533 |
+
if (this.options.altSuggest){
|
534 |
+
html = this.options.altSuggest.generateHTML.call(this,data,this.options.altSuggest.heading);
|
535 |
+
}
|
536 |
+
return html;
|
537 |
+
},
|
538 |
+
generateHeading: function(format, title, value, cnt){
|
539 |
+
var html = '';
|
540 |
+
if (format){
|
541 |
+
var html = format;
|
542 |
+
var idx;
|
543 |
+
if (title){
|
544 |
+
idx = html.indexOf('{title}');
|
545 |
+
if (-1 < idx){
|
546 |
+
html = html.substring(0,idx) + title + html.substring(idx+'{title}'.length);
|
547 |
+
}
|
548 |
+
}
|
549 |
+
if (value){
|
550 |
+
idx = html.indexOf('{value}');
|
551 |
+
if (-1 < idx){
|
552 |
+
html = html.substring(0,idx) + value + html.substring(idx+'{value}'.length);
|
553 |
+
}
|
554 |
+
}
|
555 |
+
if (cnt){
|
556 |
+
var idx = html.indexOf('{count}');
|
557 |
+
if (-1 < idx){
|
558 |
+
html = html.substring(0,idx) + cnt + html.substring(idx+'{count}'.length);
|
559 |
+
}
|
560 |
+
}
|
561 |
+
}
|
562 |
+
return html;
|
563 |
+
},
|
564 |
+
|
565 |
+
generateCategory: function(cat,pathStart){
|
566 |
+
return '<li class="ea-sug-nav-value">' +
|
567 |
+
'<a class="ea-sug-nav-link" ea_link="' + this.htmlEncode(pathStart+cat.nodeString) + '" href="#">' + cat.name + (0 < cat.productCount?('<span class="ea-sug-nav-count"> (' + cat.productCount +')</span>'):'') + '</a></li>';
|
568 |
+
},
|
569 |
+
generateCategories: function(size,title,lstCats,pathStart,format){
|
570 |
+
if (lstCats && 0 < lstCats.length){
|
571 |
+
var lst = '<div class="ea-sug-sec-heading">' + this.generateHeading(format,title,null,lstCats.length) + '</div><ul class="ea-sug-choices">';
|
572 |
+
for(var i = 0; i < size && i < lstCats.length; i++){
|
573 |
+
lst += this.generateCategory(lstCats[i],pathStart);
|
574 |
+
}
|
575 |
+
lst += '</ul>';
|
576 |
+
return lst;
|
577 |
+
}
|
578 |
+
},
|
579 |
+
|
580 |
+
|
581 |
+
generateAttribute: function(av,pathStart){
|
582 |
+
return '<li class="ea-sug-nav-value">' +
|
583 |
+
'<a class="ea-sug-nav-link" ea_link="' + this.htmlEncode(pathStart + av.nodeString) + '" href="#">' + av.attributeValue + (0 < av.productCount?('<span class="ea-sug-nav-count"> (' + av.productCount +')</span>'):'') + '</a></li>';
|
584 |
+
},
|
585 |
+
|
586 |
+
generateAttributes: function(size,title,attr,pathStart,format,full){
|
587 |
+
if (attr){
|
588 |
+
// use full or initial, if initial and none, then use full
|
589 |
+
var valList = full?attr.attributeValueList:(attr.initialAttributeValueList || attr.attributeValueList);
|
590 |
+
if (valList && 0 < valList.length){
|
591 |
+
var lst = '<div class="ea-sug-sec-heading">' + this.generateHeading(format,title,null,valList.length) + '</div><ul class="ea-sug-choices">';
|
592 |
+
for(var i = 0; i < size && i < valList.length; i++){
|
593 |
+
lst += this.generateAttribute(valList[i],pathStart);
|
594 |
+
}
|
595 |
+
lst += '</ul>';
|
596 |
+
return lst;
|
597 |
+
}
|
598 |
+
}
|
599 |
+
},
|
600 |
+
|
601 |
+
getCategories: function(ds,full){
|
602 |
+
// use full or initial list, if initial and none then use full
|
603 |
+
return ds.categories?(full?ds.categories.categoryList:(ds.categories.initialCategoryList || ds.categories.categoryList)):null;
|
604 |
+
},
|
605 |
+
|
606 |
+
getAttributes: function(ds,name){
|
607 |
+
if (ds.attributes){
|
608 |
+
var lcName = name.toLowerCase();
|
609 |
+
for(var i = 0; i < ds.attributes.attribute.length;i++){
|
610 |
+
var attr = ds.attributes.attribute[i];
|
611 |
+
if (attr.name.toLowerCase() == lcName){
|
612 |
+
return attr;
|
613 |
+
}
|
614 |
+
}
|
615 |
+
}
|
616 |
+
return null;
|
617 |
+
},
|
618 |
+
|
619 |
+
SEARCH_NODE: 3,
|
620 |
+
|
621 |
+
getSearch: function(ds){
|
622 |
+
var npl = ds.navPath.navPathNodeList;
|
623 |
+
if (npl && 0 < npl.length){
|
624 |
+
var node = npl[npl.length-1];
|
625 |
+
if (node.navNodePathType == this.SEARCH_NODE){
|
626 |
+
return node.seoPath+'/';
|
627 |
+
}
|
628 |
+
}
|
629 |
+
return "";
|
630 |
+
},
|
631 |
+
textOnly: function(val){
|
632 |
+
if (val){
|
633 |
+
try {
|
634 |
+
return this.txtNode.html(val).text();
|
635 |
+
}
|
636 |
+
catch(err){}
|
637 |
+
}
|
638 |
+
return val;
|
639 |
+
},
|
640 |
+
generateProduct: function(item){
|
641 |
+
var fields = this.options.products.fields;
|
642 |
+
var sizes = this.options.products.sizes;
|
643 |
+
var value = this.options.products.value;
|
644 |
+
var link = value(item,fields.link);
|
645 |
+
var id = fields.id?value(item,fields.id):'';
|
646 |
+
var thumbnail = value(item,fields.thumbnail);
|
647 |
+
var name = this.trimString(this.textOnly(value(item,fields.name)),sizes.name);
|
648 |
+
var price = this.textOnly(value(item,fields.price));
|
649 |
+
var description = this.trimString(this.textOnly(value(item,fields.description)),sizes.description);
|
650 |
+
return '<tr class="ea-sug-product"' + (id?' ea-prod-id="' + this.htmlEncode(id) +'"':'')+'>' +
|
651 |
+
'<td class="ea-sug-product-picture">' +
|
652 |
+
'<a class="ea-sug-product-picture-link" href="' + (link || '#') + '">' +
|
653 |
+
(thumbnail?'<image class="ea-sug-product-image" src="' + thumbnail +'">':'') +
|
654 |
+
'</a>' +
|
655 |
+
'</td>' +
|
656 |
+
'<td class="ea-sug-product-info">' +
|
657 |
+
'<a class="ea-sug-product-info-link" href="' + (link || '#') + '">' +
|
658 |
+
(name?'<div class="ea-sug-product-name">' + name + '</div>':'') +
|
659 |
+
(description?'<div class="ea-sug-product-desc">' + description + '</div>':'') +
|
660 |
+
(price?'<div class="ea-sug-product-price">' + price + '</div>':'') +
|
661 |
+
'</a>' +
|
662 |
+
'</td>' +
|
663 |
+
'</tr>';
|
664 |
+
},
|
665 |
+
|
666 |
+
generateProducts: function(data,heading){
|
667 |
+
var ds = this.options.products.display && data && 0 == data.returnCode?data.source:null;
|
668 |
+
if (ds && ds.products && ds.products.items){
|
669 |
+
var cnt = ds.products.itemDescription.totalItems;
|
670 |
+
var html = '';
|
671 |
+
if (heading && heading.display){
|
672 |
+
html = '<div class="ea-sug-sec-heading">' + this.generateHeading(heading.format,null,null,cnt) + '</div>';
|
673 |
+
}
|
674 |
+
html += '<table class="ea-sug-products" border="0" style="width:100%"><tbody>';
|
675 |
+
var self = this;
|
676 |
+
$.map( data.source.products.items, function(item,_idx){
|
677 |
+
html += self.generateProduct(item);
|
678 |
+
});
|
679 |
+
html += '</tbody></table>';
|
680 |
+
if (this.options.numCols == 1){
|
681 |
+
html += ('<div class="ea-sug-section-vertical-space" style="clear:both;height:30px"></div>');
|
682 |
+
html += ('<div class="ea-sug-nav-tm"> </div>');
|
683 |
+
}
|
684 |
+
|
685 |
+
return html;
|
686 |
+
}
|
687 |
+
return null;
|
688 |
+
},
|
689 |
+
|
690 |
+
// defaultSectionHeaderFormat: '<span class="ea-sug-sec-head-title">{title}</span><span class="ea-sug-sec-head-count">{count}</span>',
|
691 |
+
|
692 |
+
generateNavigation: function(data){
|
693 |
+
var ds = data && 0 == data.returnCode?data.source:null;
|
694 |
+
if (ds){
|
695 |
+
var navOpts = this.options.navigation.sections || [];
|
696 |
+
var html = '';
|
697 |
+
var navGenerated = 0;
|
698 |
+
var pathStart = this.getSearch(ds);
|
699 |
+
var maxSections = this.options.navigation.size || 2;
|
700 |
+
for(var i = 0; i < navOpts.length && navGenerated < maxSections; i++){
|
701 |
+
var classType = '';
|
702 |
+
var itemHtml = null;
|
703 |
+
var navOpt = navOpts[i];
|
704 |
+
var format = null;
|
705 |
+
if (navOpts.heading){
|
706 |
+
if (navOpts.heading.display){
|
707 |
+
format = navOpts.heading.format || this.options.navigation.heading.display;
|
708 |
+
}
|
709 |
+
}
|
710 |
+
else if (this.options.navigation.heading.display){
|
711 |
+
format = this.options.navigation.heading.format;
|
712 |
+
}
|
713 |
+
if (navOpt.type.toLowerCase() == 'category'){
|
714 |
+
itemHtml = this.generateCategories(navOpt.size,navOpt.title || 'Category',this.getCategories(ds,navOpt.full),pathStart,format);
|
715 |
+
classType = ' ea-sug-cat';
|
716 |
+
}
|
717 |
+
else {
|
718 |
+
itemHtml = this.generateAttributes(navOpt.size,navOpt.title,this.getAttributes(ds,navOpt.type),pathStart,format,navOpt.full);
|
719 |
+
classType = ' ea-sug-attr';
|
720 |
+
}
|
721 |
+
if (itemHtml){
|
722 |
+
var extraClass = 0 == navGenerated++?'':' ea-sug-section-vertical-space';
|
723 |
+
html += ('<div class="ea-sug-section' + classType + extraClass + '">'+itemHtml+'</div>');
|
724 |
+
}
|
725 |
+
}
|
726 |
+
if (html && 1 != this.options.numCols){
|
727 |
+
html += ('<div class="ea-sug-section-vertical-space" style="clear:both;height:30px"></div>');
|
728 |
+
html += ('<div class="ea-sug-nav-tm"> </div>');
|
729 |
+
}
|
730 |
+
return html;
|
731 |
+
}
|
732 |
+
return null;
|
733 |
+
},
|
734 |
+
|
735 |
+
renderProducts: function(html){
|
736 |
+
$(this.prodId).html(html).show();
|
737 |
+
$('.ea-sug-product').each(function(){
|
738 |
+
$(this).hover(function() {
|
739 |
+
$(this).find('.ea-sug-product-name').toggleClass('ui-state-hover');
|
740 |
+
$(this).find('.ea-sug-product-desc').toggleClass('ui-state-hover');
|
741 |
+
});
|
742 |
+
});
|
743 |
+
$('.ea-sug-product :not(:last)').find('.ea-sug-product-info').addClass('ea-sug-product-separator');
|
744 |
+
$('.ea-sug-product-name').addClass('ui-corner-all');
|
745 |
+
$('tr.ea-sug-product').hover(function(){
|
746 |
+
$(this).toggleClass('ea-state-hover');
|
747 |
+
});
|
748 |
+
},
|
749 |
+
|
750 |
+
renderNavigation: function(html){
|
751 |
+
if (html){
|
752 |
+
var nav = '';
|
753 |
+
if (2 == this.options.numCols){
|
754 |
+
nav = $(this.rightColId);
|
755 |
+
nav.empty().append($(html));
|
756 |
+
nav.find('.ea-sug-section').find('li :last').after($('<div class="ea-sug-last-spacer"></div>')) // last entries in each section need padding
|
757 |
+
}
|
758 |
+
else {
|
759 |
+
var navOptions = $(html).find('ul'); // get the beginning of the nav options
|
760 |
+
nav = $('.ea-sug-menu');
|
761 |
+
if (this.options.navigation.embed){
|
762 |
+
|
763 |
+
// put them inline under the focus menu or the first one
|
764 |
+
$(nav).find('.ea-sug-choices').remove(); // remove any existing options
|
765 |
+
var choice = nav.find('li a.ui-state-focus');
|
766 |
+
if (!choice.length){ // nothing focused, select first one
|
767 |
+
choice = nav.find('li:first a');
|
768 |
+
}
|
769 |
+
$(choice).parent().append(navOptions);
|
770 |
+
}
|
771 |
+
else {
|
772 |
+
$(nav).find('.ea-sug-section-vertical-space').remove();
|
773 |
+
$(nav).find('.ea-sug-section').remove();
|
774 |
+
$(nav).append(html);
|
775 |
+
}
|
776 |
+
}
|
777 |
+
nav.show();
|
778 |
+
var widget = this
|
779 |
+
$('a.ea-sug-nav-link').each(function(){
|
780 |
+
var link = $(this);
|
781 |
+
link.unbind('click').click(function(event){
|
782 |
+
widget.close();
|
783 |
+
widget.options.submitFctn('nav',$(link).attr('ea_link'));
|
784 |
+
return false;
|
785 |
+
});
|
786 |
+
});
|
787 |
+
$('.ea-sug-nav-value').each(function(){
|
788 |
+
$(this).addClass('ui-corner-all')
|
789 |
+
.click(function(){
|
790 |
+
$(this).closest('.ea-sug-nav-value').find('a.ea-sug-nav-link').click();
|
791 |
+
}).hover(function() {
|
792 |
+
$(this).toggleClass('ui-state-hover ui-state-focus');
|
793 |
+
});
|
794 |
+
});
|
795 |
+
|
796 |
+
}
|
797 |
+
else if (2 != this.options.numCols){
|
798 |
+
$('.ea-sug-menu').find('.ea-sug-choices').remove(); // clean up any existing suggestions that are inline
|
799 |
+
$('.ea-sug-cat').hide(); //if no categories, hide the category section
|
800 |
+
// $('.ea-sug-section-vertical-space').hide();
|
801 |
+
// $('.ea-sug-nav-tm').hide();
|
802 |
+
}
|
803 |
+
|
804 |
+
return;
|
805 |
+
},
|
806 |
+
|
807 |
+
findProducts: function(q,s){
|
808 |
+
if (this.options.products){
|
809 |
+
if (this.lastSearch == q){
|
810 |
+
return;
|
811 |
+
}
|
812 |
+
this.lastSearch=q;
|
813 |
+
this.getProducts(q,s);
|
814 |
+
}
|
815 |
+
},
|
816 |
+
findAlt: function(q,s){
|
817 |
+
if (this.options.altSuggest){
|
818 |
+
if (this.lastAlt == q){
|
819 |
+
return;
|
820 |
+
}
|
821 |
+
this.lastAlt = q;
|
822 |
+
this.getAlt(q,s);
|
823 |
+
}
|
824 |
+
},
|
825 |
+
htmlEncode: function (str) {
|
826 |
+
return String(str)
|
827 |
+
.replace(/&/g, '&')
|
828 |
+
.replace(/"/g, '"')
|
829 |
+
.replace(/'/g, ''')
|
830 |
+
.replace(/</g, '<')
|
831 |
+
.replace(/>/g, '>');
|
832 |
+
},
|
833 |
+
|
834 |
+
getProducts: function(q,s){
|
835 |
+
this.pendingProds = true;
|
836 |
+
var self = this;
|
837 |
+
$.ajax({
|
838 |
+
url: self.options.serverSearch + self.options.urlSearch + '?' + self.options.defaultSearchParams + '&customer=easayt',
|
839 |
+
dataType: 'jsonp',
|
840 |
+
data: {
|
841 |
+
dct: this.options.dict,
|
842 |
+
q: q,
|
843 |
+
ResultsPerPage: this.options.products.size
|
844 |
+
},
|
845 |
+
success: function(prods){
|
846 |
+
self.pendingProds = false;
|
847 |
+
self.prods = prods;
|
848 |
+
self.addSearch(s);
|
849 |
+
},
|
850 |
+
failure: function(data){
|
851 |
+
self.pendingProds = false;
|
852 |
+
self.prods = null;
|
853 |
+
self.addSearch(s);
|
854 |
+
}
|
855 |
+
});
|
856 |
+
},
|
857 |
+
getAlt: function(q,s){
|
858 |
+
this.pendingAlt = true;
|
859 |
+
var self = this;
|
860 |
+
$.ajax({
|
861 |
+
url: self.options.altSuggest.url + '?' + self.options.altSuggest.defaultParams,
|
862 |
+
dataType: self.options.altSuggest.ajaxMethod,
|
863 |
+
data: {
|
864 |
+
q: q
|
865 |
+
},
|
866 |
+
success: function(prods){
|
867 |
+
self.pendingAlt = false;
|
868 |
+
self.alt = prods;
|
869 |
+
self.addSearch(s);
|
870 |
+
},
|
871 |
+
failure: function(data){
|
872 |
+
self.pendingAlt = false;
|
873 |
+
self.alt = null;
|
874 |
+
addSearch(s)
|
875 |
+
}
|
876 |
+
});
|
877 |
+
}
|
878 |
+
});
|
879 |
+
});
|
880 |
+
}(jQuery ));
|
881 |
+
}(window.$ea || window.eaj$183 || jQuery));
|
js/easyask/2.0/images/sug-title-gradient.gif
ADDED
Binary file
|
js/easyask/2.0/images/tm-logo.png
ADDED
Binary file
|
js/easyask/images/price_filter.png
ADDED
Binary file
|
js/easyask/sayt20_search.html
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<title>EasyAsk</title>
|
5 |
+
<!-- jQuery libraries with ui -->
|
6 |
+
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js' ></script>
|
7 |
+
<script type='text/javascript'>
|
8 |
+
$ea = jQuery.noConflict();
|
9 |
+
</script>
|
10 |
+
<script type='text/javascript' src="js/jquery-ui-1.9.2a.custom.min.js"></script>
|
11 |
+
<link type='text/css' rel='stylesheet' charset='utf-8' href='2.0/flick/jquery-ui-1.9.2.custom.min.css'>
|
12 |
+
|
13 |
+
<!-- EasyAsk client search -->
|
14 |
+
<script type='text/javascript' src='2.0/ea-search-2.0.0.js' > </script>
|
15 |
+
<link type='text/css' rel='stylesheet' charset='utf-8' href='css/ea-search-1.2.1.css'>
|
16 |
+
|
17 |
+
<!-- EasyAsk SayT -->
|
18 |
+
<script type='text/javascript' src='2.0/ea-autocomplete-2.0.0.js' > </script>
|
19 |
+
<link type='text/css' rel='stylesheet' charset='utf-8' href='2.0/ea-autocomplete-2.0.0.css'>
|
20 |
+
|
21 |
+
<!-- EasyAsk demo page -->
|
22 |
+
<link type='text/css' rel='stylesheet' charset='utf-8' href='css/sayt_search.css'>
|
23 |
+
|
24 |
+
</head>
|
25 |
+
<body>
|
26 |
+
<div class='ea-page'>
|
27 |
+
<table class='ea-top'>
|
28 |
+
<tr>
|
29 |
+
<!--td class='ea-logo'><img src='images/new_logo_2.gif' /></td-->
|
30 |
+
<td class='ea-logo'><img src='images/EasyAskLogo90pxHigh.png' /></td>
|
31 |
+
<td class='ea-search'>
|
32 |
+
<div class='ea-search-area'>
|
33 |
+
<input class='ea-input-area' id='question' type='text'/>
|
34 |
+
<input class='ea-input-button' id='search' type='image' src='images/search_button.gif'/>
|
35 |
+
</div>
|
36 |
+
</td>
|
37 |
+
</tr>
|
38 |
+
</table>
|
39 |
+
<table class='ea-body' cellpadding='5'>
|
40 |
+
<tr>
|
41 |
+
<td class='ea-lhs'>
|
42 |
+
<div id='ea-nav'></div>
|
43 |
+
</td>
|
44 |
+
<td class='ea-results'>
|
45 |
+
<div id='ea-bc' class='ea-breadcrumb'></div>
|
46 |
+
<div id='ea-controls' class='ea-results-controls'>
|
47 |
+
<table class='ea-controls-first' cellpadding='0' cellspacing='0' border='0'>
|
48 |
+
<tr>
|
49 |
+
<td class='ea-viewing'>
|
50 |
+
<span class='ea-label-displaying'>Displaying items:</span> <span class='ea-first-item'> </span> - <span class='ea-last-item'> </span> <span class='ea-label-of'>of</span> <span class='ea-total-items'> </span>
|
51 |
+
</td>
|
52 |
+
<td class='ea-page-controls'>
|
53 |
+
<div class='ea-page-buttons'>
|
54 |
+
<table cellpadding='0' cellspacing='0' border='0'>
|
55 |
+
<tr>
|
56 |
+
<td><input type='image' class='ea-page-first ea-page-image' src='images/movefirst.png'></td>
|
57 |
+
<td><input type='image' class='ea-page-prev ea-page-image' src='images/moveprev.png'></td>
|
58 |
+
<td><span class='ea-label-page'>Page</span>
|
59 |
+
<td><input class='ea-current-page' type='text'/></td>
|
60 |
+
<td><span class='ea-label-of'>of</span></td>
|
61 |
+
<td><span class='ea-total-pages'></span></td>
|
62 |
+
<td><input type='image' class='ea-page-next ea-page-image' src='images/movenext.png'></td>
|
63 |
+
<td><input type='image' class='ea-page-last ea-page-image' src='images/movelast.png'></td>
|
64 |
+
</tr>
|
65 |
+
</table>
|
66 |
+
</div>
|
67 |
+
</td>
|
68 |
+
</tr>
|
69 |
+
</table>
|
70 |
+
<table class='ea-controls-second' cellpadding='0' cellspacing='0' border='0'>
|
71 |
+
<tr>
|
72 |
+
<td class='ea-results-per-page-controls'>
|
73 |
+
<div class='ea-results-per-page'>
|
74 |
+
<span class='ea-label-per-page'>Per Page</span>
|
75 |
+
<select class='ea-select-results-per-page'>
|
76 |
+
<option selected='selected' value='16'>16</option>
|
77 |
+
<option value='32'>32</option>
|
78 |
+
<option value='48'>48</option>
|
79 |
+
<option value='All'>View All</option>
|
80 |
+
</select>
|
81 |
+
</div>
|
82 |
+
</td>
|
83 |
+
<td class='ea-results-sort-by-controls'>
|
84 |
+
<div class='ea-results-sort-by'>
|
85 |
+
<span class='ea-label-sort-by'>Sort By</span>
|
86 |
+
<select class='ea-select-sort-by'>
|
87 |
+
<option selected='selected' value='-default-'>Recommended</option>
|
88 |
+
<option value='Product Name,t'>Name (A-Z)</option>
|
89 |
+
<option value='Product Name,f'>Name (Z-A)</option>
|
90 |
+
<option value='Price,t'>Price ($-$$$)</option>
|
91 |
+
<option value='Price,f'>Price ($$$-$)</option>
|
92 |
+
<option value='Manufacturer,t'>Manufacturer (A-Z)</option>
|
93 |
+
<option value='Manufacturer,f'>Manufacturer (Z-A)</option>
|
94 |
+
</select>
|
95 |
+
</div>
|
96 |
+
</td>
|
97 |
+
</tr>
|
98 |
+
</table>
|
99 |
+
</div>
|
100 |
+
<div id='ea-featured-products' class='ea-featured-products'></div>
|
101 |
+
<div id='ea-products' class='ea-products'></div>
|
102 |
+
</td>
|
103 |
+
</tr>
|
104 |
+
</table>
|
105 |
+
</div>
|
106 |
+
</body>
|
107 |
+
<script type='text/javascript' src="2.0/ea-search-autocomplete-init.js"></script>
|
108 |
+
</html>
|
lib/EasyAsk/IBreadCrumbTrail.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iBreadCrumbTrail
|
3 |
+
{
|
4 |
+
// Returns the full path to the current node location.
|
5 |
+
public function getFullPath();
|
6 |
+
// Returns the path to the category node.
|
7 |
+
public function getPureCategoryPath();
|
8 |
+
// Returns the path the search used to get to the current node location.
|
9 |
+
public function getSearchPath();
|
10 |
+
}
|
11 |
+
?>
|
lib/EasyAsk/ICarveOut.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iCarveOut
|
3 |
+
{
|
4 |
+
// Returns the maximum size of the carveout
|
5 |
+
public function getMaximum();
|
6 |
+
// Returns the current display format of the carveout
|
7 |
+
public function getDisplayFormat();
|
8 |
+
// Returns the dataset for the carveout
|
9 |
+
public function getItems();
|
10 |
+
// Returns the current number of products in the carveout
|
11 |
+
public function getProductCount();
|
12 |
+
}
|
13 |
+
?>
|
lib/EasyAsk/IDataDescription.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iDataDescription
|
3 |
+
{
|
4 |
+
// Returns whether the data is displayable or not.
|
5 |
+
public function getDisplayable();
|
6 |
+
// Returns whether the data is decoded or not.
|
7 |
+
public function getDecoded();
|
8 |
+
// Returns the column type of the current data.
|
9 |
+
public function getColType();
|
10 |
+
// Returns the HTML type of the current data.
|
11 |
+
public function getHTMLType();
|
12 |
+
// Returns the format type of the current data.
|
13 |
+
public function getFormat();
|
14 |
+
// Returns the tag name of the current data.
|
15 |
+
public function getTagName();
|
16 |
+
// Returns the column name of the current data.
|
17 |
+
public function getColName();
|
18 |
+
}
|
19 |
+
?>
|
lib/EasyAsk/IFeaturedProducts.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iFeaturedProducts
|
3 |
+
{
|
4 |
+
// Returns the dataset for the FeaturedProducts
|
5 |
+
public function getItems();
|
6 |
+
// Returns the current number of products in the FeaturedProducts
|
7 |
+
public function getProductCount();
|
8 |
+
}
|
9 |
+
?>
|
lib/EasyAsk/IGroupedResult.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iGroupedResult
|
3 |
+
{
|
4 |
+
// Returns a list of all the the categories for the group.
|
5 |
+
public function getAllCategoryDetails();
|
6 |
+
// Returns a list of all the attribute names contained in the IGroupedResult.
|
7 |
+
public function getAttributeNames();
|
8 |
+
// Returns the attribute value count
|
9 |
+
public function getAttributeValueCount($attrName, $attrValue);
|
10 |
+
// Returns a list of the category names contained within the IGroupedResult.
|
11 |
+
public function getCategories();
|
12 |
+
// Returns detailed suggested category
|
13 |
+
public function getDetailedSuggestedCategory();
|
14 |
+
// Returns the last row of the group on the current page
|
15 |
+
public function getEndRow();
|
16 |
+
// Returns a description of the group. This is normally an attribute or category value that is applicible for all the items.
|
17 |
+
// For example, if grouping on an attribute such as color, the group description could be 'red' for those items that have color = red.
|
18 |
+
// In the case of the unspecified group (that is the set of rows that have no value for the criteria, this can be blank).
|
19 |
+
public function getGroupValue();
|
20 |
+
// Returns the first row of the group on the current page
|
21 |
+
public function getStartRow();
|
22 |
+
// Returns a string for the id of the suggested category (common parent)
|
23 |
+
public function getSuggestedCategoryID();
|
24 |
+
// Returns a string for the suggested category name (common parent) for the categories in the group.
|
25 |
+
public function getSuggestedCategoryTitle();
|
26 |
+
// Returns the total number of items in the group. This may be greater than or equal to the getNumberOfRows
|
27 |
+
public function getTotalNumberOfRows();
|
28 |
+
// Returns the data held in the grouped result at a specific position
|
29 |
+
public function getCellData($row, $col);
|
30 |
+
// Returns the number of rows contained in the result.
|
31 |
+
public function getNumberOfRows();
|
32 |
+
// Returns the IResultRow held in the IGroupedResult at position "row".
|
33 |
+
public function getItem($row);
|
34 |
+
|
35 |
+
public function getDetailedAttributeValues($attrName, $displayMode);
|
36 |
+
}
|
37 |
+
?>
|
lib/EasyAsk/IGroupedResultSet.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iGroupedResultSet
|
3 |
+
{
|
4 |
+
// Returns the index of the last group on the current page
|
5 |
+
public function getEndGroup();
|
6 |
+
// Retrieves a group based on the index
|
7 |
+
public function getGroup($i);
|
8 |
+
// Returns the criteria of the GroupedResultSet, either the name of the attribute or current category level.
|
9 |
+
public function getGroupCriteria();
|
10 |
+
// Returns the type of search
|
11 |
+
public function getGroupCriteriaType();
|
12 |
+
// Returns the current maximum number of items per group (can return GROUP_RETURN_ALL)
|
13 |
+
public function getMaximumRowsPerGroup();
|
14 |
+
// Returns the total number of groups (including the group with no criteria)
|
15 |
+
public function getNumberOfGroups();
|
16 |
+
// Returns the number of pages needed to diplay all the groups
|
17 |
+
public function getPageCount();
|
18 |
+
// Returns the index of the first group on the current page
|
19 |
+
public function getStartGroup();
|
20 |
+
// Returns the total number of items in the set.
|
21 |
+
public function getTotalNumberOfRows();
|
22 |
+
// Returns the node string for a specific group within the set.
|
23 |
+
public function getNodeString($group);
|
24 |
+
}
|
25 |
+
?>
|
lib/EasyAsk/INavigateAttribute.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iNavigateAttribute
|
3 |
+
{
|
4 |
+
// Returns true if we recommend showing this attribute as a link.
|
5 |
+
public function getDisplayAsLink();
|
6 |
+
// Gets the name of this attribute. This is for display/user purposes. It is not used when sorting through the actual data.
|
7 |
+
public function getName();
|
8 |
+
// Gets the amount of products which this attribute applies to.
|
9 |
+
public function getProductCount();
|
10 |
+
// Gets the type of attribute this is. (Color, Size, Product Type, etc)
|
11 |
+
public function getType();
|
12 |
+
// Gets the valueType contained within this INavigateAttribute. The data used to sort/seperate.
|
13 |
+
function getValueType();
|
14 |
+
// Gets the value contained within this INavigateAttribute. The data used to sort/seperate.
|
15 |
+
public function getValue();
|
16 |
+
// Returns ths node location which this attribute is located under.
|
17 |
+
public function getNodeString();
|
18 |
+
// Removes references to this node from the given path.
|
19 |
+
public function removeFromPath($path);
|
20 |
+
// Returns the min Value of the selection.
|
21 |
+
public function getMinValue();
|
22 |
+
// Returns the max Value of the selection.
|
23 |
+
public function getMaxValue();
|
24 |
+
// Returns the min Value of the range.
|
25 |
+
public function getMinRangeValue();
|
26 |
+
// Returns the max Value of the range.
|
27 |
+
public function getMaxRangeValue();
|
28 |
+
// Returns the round value of the range.
|
29 |
+
public function getRangeRound();
|
30 |
+
// Returns ths dispaly name of this attribute.
|
31 |
+
public function getDisplayName();
|
32 |
+
}
|
33 |
+
?>
|
lib/EasyAsk/INavigateCategory.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iNavigateCategory
|
3 |
+
{
|
4 |
+
// Returns a list of ids (as Strings) that correspond to the category named in this object
|
5 |
+
// The list will contain at least 1 entry and possibly more if there are multiple categories with the same name at the same level.
|
6 |
+
// The ids will be only from categories that are referenced by products in the result set, that is,
|
7 |
+
// if there are 5 categories with the same name, but only 3 of them are referenced in the result set,
|
8 |
+
// then the list will contain 3 Strings not 5
|
9 |
+
public function getIDs();
|
10 |
+
// Returns the category name.
|
11 |
+
public function getName();
|
12 |
+
// Returns the number of products that have this category. Returns -1 if the product count is unknown
|
13 |
+
public function getProductCount();
|
14 |
+
// Returns a list of NavigateCategory corresponding to the subcategories of this node
|
15 |
+
public function getSubCategories();
|
16 |
+
// Returns a string corresponding to the path segment for this category. See NavigateNode.toString()
|
17 |
+
public function getNodeString();
|
18 |
+
// Returns a string corresponding to the full path to this category
|
19 |
+
public function getSEOPath();
|
20 |
+
}
|
21 |
+
?>
|
lib/EasyAsk/INavigateHierarchy.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iNavigateHierarchy
|
3 |
+
{
|
4 |
+
// The hierarchy node name, that is, the category name corresponding to this node.
|
5 |
+
public function getName();
|
6 |
+
// The category path from root node to this node. The path is seperated by the standard path delimiter (////).
|
7 |
+
// The path can be used to perform a category expand to this node.
|
8 |
+
public function getPath();
|
9 |
+
// Returns a list of NavigateHierarchy corresponding to the sub nodes of this node. A node will have sub nodes if it is
|
10 |
+
// the selected node and that category has children, or if it is a sibling node that is on the path to the selected node.
|
11 |
+
public function getSubNodes();
|
12 |
+
// Whether this node corresponds to the current suggested category.
|
13 |
+
public function isSelected();
|
14 |
+
// Returns a list of IDs (as Strings) that correspong to the category named in this object. The list will contain at least
|
15 |
+
// 1 entry and possibibly more if there are multiple categories with the same name at the same level. The lsit can be
|
16 |
+
// empty for the toplevel node 'All Products'
|
17 |
+
public function getIDs();
|
18 |
+
}
|
19 |
+
?>
|
lib/EasyAsk/INavigateNode.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iNavigateNode
|
3 |
+
{
|
4 |
+
// Returns the value of the node. In the case of a category, this will return the category name.
|
5 |
+
// For an attribute, this will return the value of the attribue (COLOR='Brown') will return brown.
|
6 |
+
// For a user search entry, will return whatever the user typed in.
|
7 |
+
public function getValue();
|
8 |
+
// Returns the full path of this node, including this node.
|
9 |
+
public function getPath();
|
10 |
+
// Returns the full path of this node without additional information about each node.
|
11 |
+
public function getPurePath();
|
12 |
+
// Returns the Search Engine Optimimization version of the path of this node.
|
13 |
+
public function getSEOPath();
|
14 |
+
// Returns the type of this node.
|
15 |
+
public function getType();
|
16 |
+
// returns ths english representation of this node.
|
17 |
+
// eg: if toString returns attribselect=COLOR = 'Brown', this will return "COLOR = 'BROWN'"
|
18 |
+
public function getEnglishName();
|
19 |
+
// Returns the label of this node.
|
20 |
+
public function getLabel();
|
21 |
+
}
|
22 |
+
?>
|
lib/EasyAsk/INavigateResults.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// This interface provides access to 'navigation' results. This result set contains three sets of data:
|
3 |
+
// 1) a product listing 2) a list of categories related to the products 3) a list of attributes related
|
4 |
+
// to the products. NOTE: Depending on the query or action performed, category and/or attribute data
|
5 |
+
// may not be present.
|
6 |
+
interface EasyAsk_iNavigateResults
|
7 |
+
{
|
8 |
+
public function getReturnCode();
|
9 |
+
public function getCatPath();
|
10 |
+
// Returns the current list of ResultCategory based on the displaymode
|
11 |
+
public function getDetailedCategories($nDisplayMode);
|
12 |
+
// Returns the current list of ResultCategory
|
13 |
+
public function getDetailedCategoriesFull();
|
14 |
+
// Returns initial display limit for categories.
|
15 |
+
public function getInitDisplayLimitForCategories();
|
16 |
+
// Return a string for the suggested category name (common parent)
|
17 |
+
public function getSuggestedCategoryTitle();
|
18 |
+
// Returns to total number of pages needed to hold the results of the INavigateResults.
|
19 |
+
public function getPageCount();
|
20 |
+
// Gets the index of the current page of results that the INavigateResults is displaying.
|
21 |
+
public function getCurrentPage();
|
22 |
+
public function getIsDrillDown();
|
23 |
+
// Gets the total number of items currently contained within the INavigateResults.
|
24 |
+
public function getTotalItems();
|
25 |
+
// Returns the current results per page.
|
26 |
+
public function getResultsPerPage();
|
27 |
+
// Returns the index of the first item on the page.
|
28 |
+
public function getFirstItem();
|
29 |
+
// Returns the index of the last item on the page.
|
30 |
+
public function getLastItem();
|
31 |
+
// Returns the current sort order being used by INavigateResults.
|
32 |
+
public function getSortOrder();
|
33 |
+
public function getDataDescriptions();
|
34 |
+
// Returns the numerical index of a column.
|
35 |
+
public function getColumnIndex($colName);
|
36 |
+
// Gets Gets the data contained within a specific location of the results.
|
37 |
+
public function getCellData($row, $col);
|
38 |
+
// Gets the breadcrumb trail for the current path.
|
39 |
+
public function getBreadCrumbTrail();
|
40 |
+
// Returns true if the current path is at the top or root node of all products.
|
41 |
+
public function getAtTopNode();
|
42 |
+
public function getProductsFromGlobalSearch();
|
43 |
+
// Returns true if products could not be found in the current context, but were found by modifying the user query.
|
44 |
+
public function getItemsFoundByModifyingQuery();
|
45 |
+
// Returns true if products/items were found through a secondary search.
|
46 |
+
public function getItemsFoundWIthSecondarySearch();
|
47 |
+
// Returns the method in which the product listing was obtained.
|
48 |
+
public function getProductRetrievalMethod();
|
49 |
+
// Returns the method in which the attribute listing was obtained.
|
50 |
+
public function getAttributeRetrievalMethod();
|
51 |
+
public function getQuestion();
|
52 |
+
public function getIsCommand();
|
53 |
+
// Returns a NavigateHierarchyNode that corresponds to the current Navigate Hierarchy if it exists A hiearchy exists if the results options requests it.
|
54 |
+
public function getNavigateHierarchy();
|
55 |
+
// Returns true if the initial display is limited for attribute names.
|
56 |
+
public function isInitialDispLimitedForAttrNames();
|
57 |
+
// Returns the initial display limit for attribute names
|
58 |
+
public function getInitialDispLimitForAttrNames();
|
59 |
+
// Returns a list of attribute names for a specified group. Returns the full list.
|
60 |
+
public function getAttributeNamesFull();
|
61 |
+
// Returns a list of attribute names of the specified type.
|
62 |
+
public function getAttributeNames($filter, $displayMode);
|
63 |
+
// Returns true if the initial display is limited for attribute values for the specified attribute name.
|
64 |
+
public function isInitialDispLimitedForAttrValues($attrName);
|
65 |
+
// Returns the initial display limit. -1 means no limit.
|
66 |
+
public function getInitialDispLimitForAttrValues($attrName);
|
67 |
+
// Returns a list of NavigateAttribute objects for the specified attribute name. NavigateAttribute objects contain additional information
|
68 |
+
// about each attribute value. Returns the full list.
|
69 |
+
public function getDetailedAttributeValuesFull($attrName);
|
70 |
+
// Returns a vector of NavigateAttribute objects for the specified attribute name for a specified group.
|
71 |
+
// NavigateAttribute objects contain additional information about each attribute value.
|
72 |
+
public function getDetailedAttributeValues($attrName, $displayMode);
|
73 |
+
// Returns a vector of the attribute names that are common to the results and normally not displayed. The combination
|
74 |
+
// of getAttributeNames and getCommonAttributeNames covers all the attributes for the set.
|
75 |
+
public function getCommonAttributeNames($onlySelected);
|
76 |
+
// Returns a list of NavigateAttribute objects for the specified common attribute name. NavigateAttribute objects
|
77 |
+
// conatin additional information about each attribute value.
|
78 |
+
public function getDetailedCommonAttributeValuesFull($attrName);
|
79 |
+
// Returns a list of NavigateAttribute objects for the specified common attribute name. NavigateAttribute objects
|
80 |
+
// conatin additional information about each attribute value.
|
81 |
+
public function getDetailedCommonAttributeValues($attrName, $displayMode);
|
82 |
+
public function getCommentary();
|
83 |
+
public function getSpellCorrections();
|
84 |
+
public function getCorrectedWords();
|
85 |
+
public function getCorrection($word);
|
86 |
+
public function getRelaxedTerms();
|
87 |
+
public function isPresentationError();
|
88 |
+
public function isRedirect();
|
89 |
+
public function getRedirect();
|
90 |
+
public function isGroupedResult();
|
91 |
+
// Returns the grouped result set from the results if any. Null otherwise.
|
92 |
+
public function getGroupedResult();
|
93 |
+
// Returns a row from the currently displayed page.
|
94 |
+
public function getRow($pageRow);
|
95 |
+
// Returns a list of carveout objects.
|
96 |
+
public function getCarveOuts();
|
97 |
+
// Returns a ResultsRowGroup that contains the featured products. Null means none.
|
98 |
+
public function getFeaturedProducts();
|
99 |
+
// Returns a list of possible arrange by by choices. The result set can be arranged by one of these choices.
|
100 |
+
// The value GroupedResultSet.GROUP_NO_GROUPING is returned as a choice for not grouping.
|
101 |
+
public function getArrangeByChoices();
|
102 |
+
// Returns if there is a banner associated with this Category/Attribute
|
103 |
+
public function hasBanner($type);
|
104 |
+
//Return Banner Information
|
105 |
+
public function getBanner($type);
|
106 |
+
// Returns if the attribute is a range filter
|
107 |
+
public function isRangeFilter($attrName);
|
108 |
+
}
|
109 |
+
?>
|
lib/EasyAsk/IOptions.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iOptions
|
3 |
+
{
|
4 |
+
// Sets the dictionary file (.dxp) name that this EasyAsk instance will reference.
|
5 |
+
public function setDictionary($name);
|
6 |
+
// Gets the dictionary file name that this EasyAsk instance is referencing.
|
7 |
+
public function getDictionary();
|
8 |
+
// Sets the boolean value of navigation hierarchy for this EasyAsk instance.
|
9 |
+
public function setNavigateHierarchy($val);
|
10 |
+
// Gets the boolean value of navigation hierarchy for this EasyAsk instance.
|
11 |
+
public function getNavigateHierarchy();
|
12 |
+
// Sets the boolean value of subcategories for this EasyAsk instance.
|
13 |
+
public function setSubCategories($val);
|
14 |
+
// Gets the boolean value of subcategories for this EasyAsk instance.
|
15 |
+
public function getSubCategories();
|
16 |
+
// Sets the boolean value of top level products for this EasyAsk instance.
|
17 |
+
public function setToplevelProducts($val);
|
18 |
+
// Gets the boolean value of top level products for this EasyAsk instance.
|
19 |
+
public function getToplevelProducts();
|
20 |
+
// Sets the number of results to be displayed per page of the EasyAsk display.
|
21 |
+
public function setResultsPerPage($val);
|
22 |
+
// Gets the current number of results to be displayed per page.
|
23 |
+
public function getResultsPerPage();
|
24 |
+
// Sets the order which governs how the results will be sorted (by price, by name, etc)
|
25 |
+
public function setSortOrder($val);
|
26 |
+
// The current sort order being implemented by the EasyAsk instance.
|
27 |
+
public function getSortOrder();
|
28 |
+
// Sets the boolean value to return SKUs for this EasyAsk instance.
|
29 |
+
public function setReturnSKUs($val);
|
30 |
+
// Gets the boolean value to return SKUs for this EasyAsk instance.
|
31 |
+
public function getReturnSKUs();
|
32 |
+
// Sets the grouping term
|
33 |
+
public function setGrouping($val);
|
34 |
+
// Gets the grouping term
|
35 |
+
public function getGrouping();
|
36 |
+
// Sets the callout params value
|
37 |
+
public function setCallOutParam($val);
|
38 |
+
// Gets the call out params value
|
39 |
+
public function getCallOutParam();
|
40 |
+
// Sets the groupid parameter for the current instance.
|
41 |
+
public function setGroupId($groupId);
|
42 |
+
// Gets the groupid parameter for the current instance
|
43 |
+
public function getGroupId();
|
44 |
+
// Sets the customerid parameter for the current instance.
|
45 |
+
public function setCustomerId($customerId);
|
46 |
+
// Gets the customerid parameter for the current instance
|
47 |
+
public function getCustomerId();
|
48 |
+
// Sets the customer parameter for the current instance.
|
49 |
+
public function setCustomer($customer);
|
50 |
+
// Gets the customer parameter for the current instance
|
51 |
+
public function getCustomer();
|
52 |
+
}
|
53 |
+
?>
|
lib/EasyAsk/IRemoteEasyAsk.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iRemoteEasyAsk
|
3 |
+
{
|
4 |
+
// Returns INavigateResults for when the user performs a search.
|
5 |
+
public function userSearch($path, $question);
|
6 |
+
// Returns INavigateResults for when the user does a page operation
|
7 |
+
public function userPageOp($path, $curPage, $pageOp);
|
8 |
+
// Returns INavigateResults for when the user changes results pages
|
9 |
+
public function userGoToPage($path, $page);
|
10 |
+
// Returns INavigateResults for a click on a category
|
11 |
+
public function userCategoryClick($path, $cat);
|
12 |
+
// Returns INavigateResults for a click on the BreadCrumb Path
|
13 |
+
public function userBreadCrumbClick($path);
|
14 |
+
// Returns INavigateResults for a click on an attribute value
|
15 |
+
public function userAttributeClick($path, $attr);
|
16 |
+
// Sets the options for the RemoteEasyAsk
|
17 |
+
public function setOptions($val);
|
18 |
+
// Gets the current Options being used by the RemoteEasyAsk
|
19 |
+
public function getOptions();
|
20 |
+
}
|
21 |
+
?>
|
lib/EasyAsk/IResultRow.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface EasyAsk_iResultRow
|
3 |
+
{
|
4 |
+
// Gets the data in a column of the row
|
5 |
+
public function getCellData($col);
|
6 |
+
// The number of columns in the row.
|
7 |
+
public function size();
|
8 |
+
}
|
9 |
+
?>
|
lib/EasyAsk/Impl/AttributeInfo.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains the info which pertain to a specific EasyAsk attribute.
|
3 |
+
class EasyAsk_Impl_AttributeInfo
|
4 |
+
{
|
5 |
+
private $m_xmlNode = null;
|
6 |
+
private $m_name;
|
7 |
+
private $m_isLimited = false;
|
8 |
+
private $m_limit = -1;
|
9 |
+
private $m_initialList = null;
|
10 |
+
private $m_fullList = null;
|
11 |
+
private $m_attrType = 11;
|
12 |
+
private $m_isRangeFilter = false;
|
13 |
+
|
14 |
+
// Creates the AttributeInfo for a node and pulls
|
15 |
+
function __construct($node){
|
16 |
+
$this->m_xmlNode = $node;
|
17 |
+
$this->m_name = $node->name;
|
18 |
+
$this->m_isLimited = isset($node->isInitDispLimited)?$node->isInitDispLimited:false;
|
19 |
+
$this->m_limit = isset($node->initDispLimit)?$node->initDispLimit:'';
|
20 |
+
$this->m_attrType = isset($node->attributeValueList[0]->attrType)?
|
21 |
+
$node->attributeValueList[0]->attrType : 11;
|
22 |
+
$this->m_fullList = isset($node->attributeValueList)?
|
23 |
+
$this->formList($this->m_xmlNode->attributeValueList):null;
|
24 |
+
$this->m_initialList = isset($node->initialAttributeValueList)?
|
25 |
+
$this->formList($this->m_xmlNode->initialAttributeValueList):null;
|
26 |
+
$this->m_isRangeFilter = isset($node->attributeValueList)?
|
27 |
+
$this->getRangeAttribute($this->m_xmlNode->attributeValueList):null;
|
28 |
+
}
|
29 |
+
|
30 |
+
// Creates a list of INavigateAttributes from a list of XMLnodes.
|
31 |
+
function formList($attrVals){
|
32 |
+
$result = array();
|
33 |
+
if ($attrVals){
|
34 |
+
foreach ($attrVals as $attrVal){
|
35 |
+
$result[] = new EasyAsk_Impl_NavigateAttribute($this->m_name,$attrVal);
|
36 |
+
}
|
37 |
+
}
|
38 |
+
return $result;
|
39 |
+
}
|
40 |
+
|
41 |
+
// Returns the initial list of NavigateAttributes that correspond to this xml node
|
42 |
+
function getInitialList() {
|
43 |
+
return $this->m_initialList;
|
44 |
+
}
|
45 |
+
|
46 |
+
// Returns the full and current list of NavigateAttributes corresponding to this xmlNode
|
47 |
+
function getFullList() {
|
48 |
+
return $this->m_fullList;
|
49 |
+
}
|
50 |
+
|
51 |
+
// Returns the name of the attribute.
|
52 |
+
function getName() {
|
53 |
+
return $this->m_name;
|
54 |
+
}
|
55 |
+
|
56 |
+
// Returns whether this attribute is limited for certain displays.
|
57 |
+
function getIsLimited() {
|
58 |
+
return $this->m_isLimited;
|
59 |
+
}
|
60 |
+
|
61 |
+
// Returns the size limit of this attribute
|
62 |
+
function getLimit() {
|
63 |
+
return $this->m_limit;
|
64 |
+
}
|
65 |
+
|
66 |
+
// Returns the attribute type
|
67 |
+
function getAttrType() {
|
68 |
+
return $this->m_attrType;
|
69 |
+
}
|
70 |
+
|
71 |
+
// Returns the value of range filter
|
72 |
+
function getIsRangeFilter() {
|
73 |
+
return $this->m_isRangeFilter;
|
74 |
+
}
|
75 |
+
|
76 |
+
// Returns if the attribute is a range attribute
|
77 |
+
function getRangeAttribute($attrVals) {
|
78 |
+
$result = false;
|
79 |
+
if ($attrVals){
|
80 |
+
foreach ($attrVals as $attrVal){
|
81 |
+
$attribute = new EasyAsk_Impl_NavigateAttribute($this->m_name,$attrVal);
|
82 |
+
// if (isset($attribute->getValueType())){
|
83 |
+
$result = ($attribute->getValueType() == 2) ? true : false;
|
84 |
+
// }
|
85 |
+
}
|
86 |
+
}
|
87 |
+
return $result;
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
?>
|
lib/EasyAsk/Impl/AttributesInfo.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EasyAsk_Impl_AttributesInfo
|
3 |
+
{
|
4 |
+
private $m_bInitialDispLimitedForAttrNames = false;
|
5 |
+
private $m_initialDispLimitForAttrNames = 1;
|
6 |
+
private $m_initialAttributeNames = array();
|
7 |
+
private $m_attributes = array();
|
8 |
+
|
9 |
+
// Builds a list of attributesinfo based off of an appropriate xml node.
|
10 |
+
function __construct($node){
|
11 |
+
if ($node){
|
12 |
+
$this->m_attributes = $this->getAttributeInfo($node);
|
13 |
+
$this->m_bInitialDispLimitedForAttrNames = isset($node->isInitDispLimited)?$node->isInitDispLimited:false;
|
14 |
+
$this->m_initialDispLimitForAttrNames = isset($node->initDispLimit)?$node->initDispLimit:'';
|
15 |
+
$initLists = isset($node->initialAttrNameOrder)?$node->initialAttrNameOrder:null;
|
16 |
+
if ($initLists != null){
|
17 |
+
foreach ($initLists as $initList){
|
18 |
+
$attrType = $initList->attrType;
|
19 |
+
$initNames = $initList->attributeName;
|
20 |
+
if (0 < sizeof($initNames)){
|
21 |
+
$vals = array();
|
22 |
+
foreach ($initNames as $name){
|
23 |
+
$vals[] = $name;
|
24 |
+
}
|
25 |
+
$this->m_initialAttributeNames[$attrType] = $vals;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
// Returns a list of AttributeInfo that contains all the attributes contained within an xml node
|
33 |
+
private function getAttributeInfo($node){
|
34 |
+
$results = array();
|
35 |
+
if ($node){
|
36 |
+
$attrs = isset($node->attribute) ? $node->attribute : $node;
|
37 |
+
foreach ($attrs as $attr){
|
38 |
+
$results[] = new EasyAsk_Impl_AttributeInfo($attr);
|
39 |
+
}
|
40 |
+
}
|
41 |
+
return $results;
|
42 |
+
}
|
43 |
+
|
44 |
+
// Returns whether the attribute list is limited to the initial display
|
45 |
+
public function isInitialDispLimitedForAttrNames(){
|
46 |
+
return $this->m_bInitialDispLimitedForAttrNames;
|
47 |
+
}
|
48 |
+
|
49 |
+
// Returns initial display limit for the attribute list.
|
50 |
+
public function getInitialDispLimitForAttrNames() {
|
51 |
+
return $this->m_initialDispLimitForAttrNames;
|
52 |
+
}
|
53 |
+
|
54 |
+
// Returns a list attribute names which correspond to a certain attribute type.
|
55 |
+
public function getInitialDisplayList($attrType){
|
56 |
+
return $this->m_initialAttributeNames[$attrType];
|
57 |
+
}
|
58 |
+
|
59 |
+
// Returns a list of attribute names for a certain display mode which are also of a certain attribute type.
|
60 |
+
public function getAttributeNames($attrFilter, $displayMode){
|
61 |
+
if ($displayMode == 1){
|
62 |
+
return $this->m_initialAttributeNames[$attrFilter];
|
63 |
+
}else{
|
64 |
+
$result = array();
|
65 |
+
foreach ($this->m_attributes as $attrInfo){
|
66 |
+
if (0 != ($attrInfo->getAttrType() & $attrFilter)){
|
67 |
+
$result[] = $attrInfo->getName();
|
68 |
+
}
|
69 |
+
}
|
70 |
+
return $result;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
// Returns the AttributeInfo object for a certain attribute.
|
75 |
+
private function getAttrInfo($attrName){
|
76 |
+
foreach ($this->m_attributes as $attrInfo){
|
77 |
+
if (strcmp($attrName, $attrInfo->getName()) == 0){
|
78 |
+
return $attrInfo;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
return null;
|
82 |
+
}
|
83 |
+
|
84 |
+
// Returns whether a specific attribute is limited the initial display or not.
|
85 |
+
public function isInitialDispLimitedForAttrValues($attrName){
|
86 |
+
$attrInfo = $this->getAttrInfo($attrName);
|
87 |
+
return null == $attrInfo ? false : $attrInfo->getIsLimited();
|
88 |
+
}
|
89 |
+
|
90 |
+
// Returns the initial display limit integer for a specific attribute.
|
91 |
+
public function getInitialDispLimitForAttrValues($attrName){
|
92 |
+
$attrInfo = $this->getAttrInfo($attrName);
|
93 |
+
return null == $attrInfo ? -1 : $attrInfo->getLimit();
|
94 |
+
}
|
95 |
+
|
96 |
+
// Returns if the attribute is a range filter.
|
97 |
+
public function isRangeFilter($attrName){
|
98 |
+
$attrInfo = $this->getAttrInfo($attrName);
|
99 |
+
return null == $attrInfo ? -1 : $attrInfo->getIsRangeFilter();
|
100 |
+
}
|
101 |
+
|
102 |
+
// Returns a list of NavigateAttributes for a certain display mode that correspond to a certain attribute name.
|
103 |
+
public function getDetailedAttributeValues($attrName, $displayMode){
|
104 |
+
$result = array();
|
105 |
+
$attrInfo = $this->getAttrInfo($attrName);
|
106 |
+
if (null != $attrInfo){
|
107 |
+
if($displayMode == 1 && !$attrInfo->getIsLimited()){
|
108 |
+
$displayMode = 0;
|
109 |
+
}
|
110 |
+
$result = $displayMode == 0 ? $attrInfo->getFullList() : $attrInfo->getInitialList();
|
111 |
+
}
|
112 |
+
return $result;
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
116 |
+
?>
|
lib/EasyAsk/Impl/Banner.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains data about banner
|
3 |
+
class EasyAsk_Impl_Banner
|
4 |
+
{
|
5 |
+
private $m_Type = 0;
|
6 |
+
private $m_BlockIdentifier = '';
|
7 |
+
private $m_TriggerType = 0;
|
8 |
+
private $m_TriggerValue = '';
|
9 |
+
|
10 |
+
// Builds a display from an appripriate xml node
|
11 |
+
function __construct($node){
|
12 |
+
if ($node){
|
13 |
+
$this->m_Type = $node->type;
|
14 |
+
$this->m_BlockIdentifier = $node->blockIdentifier;
|
15 |
+
$this->m_TriggerType = $node->triggerType;
|
16 |
+
$this->m_TriggerValue = $node->triggerValue;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
// Returns a numeric representation of the type
|
21 |
+
function getType() { return $this->m_Type; }
|
22 |
+
|
23 |
+
// Returns a string representation of the blockIdentifier
|
24 |
+
function getBlockIdentifier() { return $this->m_BlockIdentifier; }
|
25 |
+
|
26 |
+
// Returns a numeric representation of the trigger Type
|
27 |
+
function getTriggerType() { return $this->m_TriggerType; }
|
28 |
+
|
29 |
+
// Returns a string representation of the trigger Value
|
30 |
+
function getTriggerValue() { return $this->m_TriggerValue; }
|
31 |
+
}
|
32 |
+
|
33 |
+
?>
|
lib/EasyAsk/Impl/Banners.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains data about all the banners
|
3 |
+
class EasyAsk_Impl_Banners
|
4 |
+
{
|
5 |
+
private $m_banners = array();
|
6 |
+
|
7 |
+
// Builds a list of attributesinfo based off of an appropriate xml node.
|
8 |
+
function __construct($node){
|
9 |
+
if ($node){
|
10 |
+
$this->m_banners = $this->getBanners($node);
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
14 |
+
// Returns a list of Banner objects that contains all the attributes contained within an xml node
|
15 |
+
private function getBanners($node){
|
16 |
+
$results = array();
|
17 |
+
if ($node){
|
18 |
+
$banners = isset($node->banner) ? $node->attribute : $node;
|
19 |
+
foreach ($banners as $banner){
|
20 |
+
$results[] = new EasyAsk_Impl_Banner($banner);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
return $results;
|
24 |
+
}
|
25 |
+
|
26 |
+
// Returns the Banner object for a certain type.
|
27 |
+
public function getBanner($type){
|
28 |
+
foreach ($this->m_banners as $banner){
|
29 |
+
if (strcmp($type, $banner->getType()) == 0){
|
30 |
+
return $banner;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
return null;
|
34 |
+
}
|
35 |
+
|
36 |
+
// Returns the Banner object for a certain type.
|
37 |
+
public function hasBanner($type){
|
38 |
+
foreach ($this->m_banners as $banner){
|
39 |
+
if (strcmp($type, $banner->getType()) == 0){
|
40 |
+
return true;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
lib/EasyAsk/Impl/BreadCrumbTrail.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Used to keep track of where the INavigateResults has been.
|
3 |
+
class EasyAsk_Impl_BreadCrumbTrail implements EasyAsk_IBreadCrumbTrail
|
4 |
+
{
|
5 |
+
private $m_fullPath = null;
|
6 |
+
private $m_pureCategoryPath = null;
|
7 |
+
private $m_navNodes = array();
|
8 |
+
|
9 |
+
// Builds the Breadcrumbtrail from top node to the provided xml node, to the Category node
|
10 |
+
function __construct($node){
|
11 |
+
if ($node != null){
|
12 |
+
$this->m_fullPath = $node->fullPath;
|
13 |
+
$this->m_pureCategoryPath = $node->pureCategoryPath;
|
14 |
+
$nodes = $node->navPathNodeList;
|
15 |
+
if ($nodes){
|
16 |
+
foreach($nodes as $navNode){
|
17 |
+
$this->m_navNodes[] = new EasyAsk_Impl_NavigateNode($navNode);
|
18 |
+
}
|
19 |
+
}
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
// Returns the full path from the top node to the current node location.
|
24 |
+
function getFullPath(){ return $this->m_fullPath; }
|
25 |
+
|
26 |
+
// Returns the path from the top node to the category node.
|
27 |
+
function getPureCategoryPath() { return $this->m_pureCategoryPath; }
|
28 |
+
|
29 |
+
// Returns the path being used by the current search.
|
30 |
+
function getSearchPath() { return $this->m_navNodes; }
|
31 |
+
}
|
32 |
+
|
33 |
+
?>
|
lib/EasyAsk/Impl/CarveOut.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Represents a Search Advisor Carve Out - a subset of the current result set that share the same attribute.
|
3 |
+
class EasyAsk_Impl_CarveOut implements EasyAsk_ICarveOut
|
4 |
+
{
|
5 |
+
private $m_node = null;
|
6 |
+
private $m_res = null;
|
7 |
+
|
8 |
+
private $m_items = null;
|
9 |
+
private $m_maximum = -1;
|
10 |
+
private $m_displayFormat = null;
|
11 |
+
private $m_productCount = -1;
|
12 |
+
|
13 |
+
function __construct($res, $node){
|
14 |
+
$this->m_node = $node;
|
15 |
+
$this->m_res = $res;
|
16 |
+
$this->m_maximum = $node->maximum;
|
17 |
+
$this->m_displayFormat = $node->displayFormat;
|
18 |
+
$this->m_productCount = count($node->items);
|
19 |
+
$this->processItems();
|
20 |
+
}
|
21 |
+
|
22 |
+
private function processItems(){
|
23 |
+
if ($this->m_items == null){
|
24 |
+
$this->m_items = array();
|
25 |
+
foreach ($this->m_node->items as $item){
|
26 |
+
$this->m_items[] = new EasyAsk_Impl_ItemRow($this->m_res->getDataDescriptions(), $item);
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getMaximum(){
|
32 |
+
return $this->m_maximum;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getDisplayFormat(){
|
36 |
+
return $this->m_displayFormat;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getItems(){
|
40 |
+
return $this->m_items;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getProductCount(){
|
44 |
+
return $this->m_productCount;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
?>
|
lib/EasyAsk/Impl/CategoriesInfo.php
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains a list of EasyAsk categories and provides methods to easily access
|
3 |
+
// the categories and pertaining data for the current search as well as the intial values.
|
4 |
+
class EasyAsk_Impl_CategoriesInfo
|
5 |
+
{
|
6 |
+
private $m_node = null;
|
7 |
+
private $m_categories = array();
|
8 |
+
private $m_initialCategories = array();
|
9 |
+
private $m_suggestedCategoryTitle = "Categories";
|
10 |
+
private $m_suggestedCategoryID = "";
|
11 |
+
private $m_detailedSuggestedCategory = "Categories";
|
12 |
+
private $m_detailedSuggestedProductCount = -1;
|
13 |
+
private $m_detailedSuggestedIDs = "";
|
14 |
+
private $m_detailedSuggestedNodeString = "";
|
15 |
+
private $m_detailedSuggestedSEOPath = "";
|
16 |
+
private $m_initialDisplayLimitForCategories = -1;
|
17 |
+
|
18 |
+
// Builds the category info off of a category node
|
19 |
+
function __construct($node){
|
20 |
+
$this->m_node = $node;
|
21 |
+
$this->processCategories();
|
22 |
+
}
|
23 |
+
|
24 |
+
// Processes the category node and adds the node to a list of existing categories
|
25 |
+
// As well as maintains a list of initial categories for when the user is on the main page.
|
26 |
+
private function processCategories(){
|
27 |
+
if ($this->m_node != null){
|
28 |
+
$catNode = $this->m_node->categories;
|
29 |
+
if ($catNode != null){
|
30 |
+
$temp = $catNode->suggestedCategoryTitle;
|
31 |
+
if ($temp != null){
|
32 |
+
$this->m_suggestedCategoryTitle = $temp;
|
33 |
+
}
|
34 |
+
$temp = $catNode->suggestedCategoryID;
|
35 |
+
if ($temp != null){
|
36 |
+
$this->m_suggestedCategoryID = $temp;
|
37 |
+
}
|
38 |
+
$temp = isset($catNode->detailedSuggestedCategory)?$catNode->detailedSuggestedCategory:null;
|
39 |
+
if ($temp != null){
|
40 |
+
$this->m_detailedSuggestedCategory = $temp;
|
41 |
+
$this->m_detailedSuggestedProductCount = $temp->productCount;
|
42 |
+
$this->m_detailedSuggestedIDs = $temp->ids;
|
43 |
+
$this->m_detailedSuggestedNodeString = $temp->nodeString;
|
44 |
+
$this->m_detailedSuggestedSEOPath = $temp->seoPath;
|
45 |
+
}
|
46 |
+
$cats = isset($catNode->categoryList)?$catNode->categoryList:null;
|
47 |
+
if ($cats != null && sizeof($cats) > 0){
|
48 |
+
foreach ($cats as $cat){
|
49 |
+
$this->m_categories[] = new EasyAsk_Impl_NavigateCategory($cat);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
$cats = isset($catNode->initialCategoryList)?$catNode->initialCategoryList:null;
|
53 |
+
if ($cats != null && sizeof($cats) > 0){
|
54 |
+
$this->m_initialDisplayLimitForCategories = $catNode->InitDispLimit;
|
55 |
+
foreach ($cats as $cat){
|
56 |
+
$this->m_initialCategories[] = new EasyAsk_Impl_NavigateCategory($cat);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
// Returns a list of categories nodes.
|
64 |
+
// Will return the initial list of nodes if the Displaymode is still initial.
|
65 |
+
// Otherwise, will return the current list of categories.
|
66 |
+
public function getDetailedCategories($nDisplayMode){
|
67 |
+
if ($nDisplayMode == 1){
|
68 |
+
return $this->m_initialCategories;
|
69 |
+
}else{
|
70 |
+
return $this->m_categories;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
// Gets a list of the current category nodes
|
75 |
+
public function getDetailedCategoriesFull(){
|
76 |
+
return $this->getDetailedCategories(0);
|
77 |
+
}
|
78 |
+
|
79 |
+
// Returns a suggested category title based off of parent nodes
|
80 |
+
public function getSuggestedCategoryTitle(){
|
81 |
+
return $this->m_suggestedCategoryTitle;
|
82 |
+
}
|
83 |
+
|
84 |
+
// Returns a suggested category ID based off of parent nodes
|
85 |
+
public function getSuggestedCategoryID(){
|
86 |
+
return $this->m_suggestedCategoryID;
|
87 |
+
}
|
88 |
+
|
89 |
+
// Returns a detailed suggested category based off of parent nodes
|
90 |
+
public function getDetailedSuggestedCategory(){
|
91 |
+
return $this->m_detailedSuggestedCategory;
|
92 |
+
}
|
93 |
+
|
94 |
+
// Returns a detailed suggested category count based off of parent nodes
|
95 |
+
public function getDetailedSuggestedProductCount(){
|
96 |
+
return $this->m_detailedSuggestedProductCount;
|
97 |
+
}
|
98 |
+
|
99 |
+
// Returns a detailed suggested category IDs based off of parent nodes
|
100 |
+
public function getDetailedSuggestedIDs(){
|
101 |
+
return $this->m_detailedSuggestedIDs;
|
102 |
+
}
|
103 |
+
|
104 |
+
// Returns a detailed suggested category node string based off of parent nodes
|
105 |
+
public function getDetailedSuggestedNodeString(){
|
106 |
+
return $this->m_detailedSuggestedNodeString;
|
107 |
+
}
|
108 |
+
|
109 |
+
// Returns a detailed suggested Search Enginer Optimization path based off of parent nodes
|
110 |
+
public function getDetailedSuggestedSEOPath(){
|
111 |
+
return $this->m_detailedSuggestedSEOPath;
|
112 |
+
}
|
113 |
+
|
114 |
+
// Returns the display limit for initial list
|
115 |
+
public function getInitDisplayLimitForCategories(){
|
116 |
+
return $this->m_initialDisplayLimitForCategories;
|
117 |
+
}
|
118 |
+
|
119 |
+
}
|
120 |
+
?>
|
lib/EasyAsk/Impl/DataDescription.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Implements IDataDescription
|
3 |
+
// Contains various information about the current data in a node
|
4 |
+
class EasyAsk_Impl_DataDescription implements EasyAsk_iDataDescription{
|
5 |
+
|
6 |
+
private $m_colType;
|
7 |
+
private $m_htmlType;
|
8 |
+
private $m_displayable;
|
9 |
+
private $m_decoded;
|
10 |
+
private $m_format;
|
11 |
+
private $m_tagName;
|
12 |
+
private $m_colName;
|
13 |
+
|
14 |
+
// Builds the DataDescription of a certain node
|
15 |
+
function __construct($node){
|
16 |
+
$this->m_colType = $node->colType;
|
17 |
+
$this->m_htmlType = $node->htmlType;
|
18 |
+
$this->m_displayable = isset($node->displayable)?$node->displayable:'';
|
19 |
+
$this->m_decoded = $node->decoded;
|
20 |
+
$this->m_format = isset($node->format)?$node->format:'';
|
21 |
+
$this->m_tagName = $node->tagName;
|
22 |
+
$this->m_colName = $node->columnName;
|
23 |
+
}
|
24 |
+
|
25 |
+
// Returns whether the data is displayable or not.
|
26 |
+
function getDisplayable() { return $this->m_displayable; }
|
27 |
+
|
28 |
+
// Returns whether the data is decoded or not.
|
29 |
+
function getDecoded() { return $this->m_decoded; }
|
30 |
+
|
31 |
+
// Returns the column type of the current data.
|
32 |
+
function getColType() { return $this->m_colType; }
|
33 |
+
|
34 |
+
// Returns the HTML type of the current data.
|
35 |
+
function getHTMLType() { return $this->m_htmlType; }
|
36 |
+
|
37 |
+
// Returns the format type of the current data.
|
38 |
+
function getFormat() { return $this->m_format; }
|
39 |
+
|
40 |
+
// Returns the tag name of the current data.
|
41 |
+
function getTagName() { return $this->m_tagName; }
|
42 |
+
|
43 |
+
// Returns the column name of the current data.
|
44 |
+
function getColName() { return $this->m_colName; }
|
45 |
+
}
|
46 |
+
?>
|
lib/EasyAsk/Impl/DisplayFormat.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains data about display errors
|
3 |
+
class EasyAsk_Impl_DisplayFormat
|
4 |
+
{
|
5 |
+
private $m_OutputEngine = 0;
|
6 |
+
private $m_Presentation = 0;
|
7 |
+
private $m_Error = 0;
|
8 |
+
|
9 |
+
// Builds a display from an appripriate xml node
|
10 |
+
function __construct($node){
|
11 |
+
if ($node){
|
12 |
+
$this->m_OutputEngine = $node->outputEngine;
|
13 |
+
$this->m_Presentation = $node->presentation;
|
14 |
+
$this->m_Error = $node->error;
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
// Returns a numeric representation of the output engine
|
19 |
+
function getOutputEngine() { return $this->m_OutputEngine; }
|
20 |
+
|
21 |
+
// Returns a numeric representation of the Presentation
|
22 |
+
function getPresentation() { return $this->m_Presentation; }
|
23 |
+
|
24 |
+
// Returns a numeric representation of any errors that occur
|
25 |
+
function getError() { return $this->m_Error; }
|
26 |
+
|
27 |
+
// Determines if an error has occured within the presentation
|
28 |
+
function isPresentationError() { return $this->getPresentation() == -1; }
|
29 |
+
|
30 |
+
// Determines if the current page view is from a redirect or not.
|
31 |
+
function isRedirect() { return $this->getError() == 5; }
|
32 |
+
}
|
33 |
+
|
34 |
+
?>
|
lib/EasyAsk/Impl/DomUtilities.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains a list of EasyAsk categories and provides methods to easily access
|
3 |
+
// the categories and pertaining data for the current search as well as the intial values.
|
4 |
+
class EasyAsk_Impl_DomUtilities
|
5 |
+
{
|
6 |
+
public static function findAttribute($object, $attribute) {
|
7 |
+
$return = null;
|
8 |
+
if ($object && sizeof($object) > 0){
|
9 |
+
foreach($object->attributes() as $a => $b) {
|
10 |
+
if ($a == $attribute) {
|
11 |
+
$return = $b;
|
12 |
+
}
|
13 |
+
}
|
14 |
+
}
|
15 |
+
if($return) {
|
16 |
+
return $return;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
21 |
+
?>
|
lib/EasyAsk/Impl/FeaturedProducts.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains the featured products
|
3 |
+
class EasyAsk_Impl_FeaturedProducts implements EasyAsk_iFeaturedProducts
|
4 |
+
{
|
5 |
+
private $m_node = null;
|
6 |
+
private $m_res = null;
|
7 |
+
private $m_items = null;
|
8 |
+
private $m_productCount = -1;
|
9 |
+
|
10 |
+
// Builds a featured items instance off of an appropriate xml node
|
11 |
+
function __construct($res, $node){
|
12 |
+
$this->m_node = $node;
|
13 |
+
$this->m_res = $res;
|
14 |
+
if ($this->m_node != null){
|
15 |
+
$this->m_productCount = $node->productCount;
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
// Adds all featured products contained within the xml node to a list.
|
20 |
+
// There will be no data in this instance until this method is run.
|
21 |
+
private function processItems(){
|
22 |
+
if ($this->m_items == null){
|
23 |
+
$this->m_items = array();
|
24 |
+
if($this->m_node != null){
|
25 |
+
foreach ($this->m_node->item as $item){
|
26 |
+
$this->m_items[] = new EasyAsk_Impl_ItemRow($this->m_res->getDataDescriptions(), $item);
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
// Returns the list of featured items
|
33 |
+
public function getItems(){
|
34 |
+
$this->processItems();
|
35 |
+
return $this->m_items;
|
36 |
+
}
|
37 |
+
|
38 |
+
// Returns a count of the current featured products.
|
39 |
+
public function getProductCount(){
|
40 |
+
return $this->m_productCount;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
?>
|
lib/EasyAsk/Impl/GroupInfo.php
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Containts attribute and category information for a certain node.
|
3 |
+
class EasyAsk_Impl_GroupInfo implements EasyAsk_iGroupedResult
|
4 |
+
{
|
5 |
+
private $m_node = null;
|
6 |
+
private $m_res = null;
|
7 |
+
private $m_name = null;
|
8 |
+
private $m_count;
|
9 |
+
private $m_totalRows = 0;
|
10 |
+
private $m_items;
|
11 |
+
private $m_catInfo = null;
|
12 |
+
private $m_attributes = null;
|
13 |
+
private $m_set = null;
|
14 |
+
|
15 |
+
function __construct($res, $node, $set){
|
16 |
+
$this->m_res = $res;
|
17 |
+
$this->m_node = $node;
|
18 |
+
$this->m_set = $set;
|
19 |
+
$this->m_name = $node->name;
|
20 |
+
$this->m_count = $node->productCount;
|
21 |
+
$this->m_totalRows = $node->totalRows;
|
22 |
+
}
|
23 |
+
|
24 |
+
// Creates a CategoriesInfo instance off of the xml node.
|
25 |
+
private function processCategories(){
|
26 |
+
if (null == $this->m_catInfo){
|
27 |
+
$this->m_catInfo = new EasyAsk_Impl_CategoriesInfo($this->m_node);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
// Creates an AttributeInfo list off of the xml node.
|
32 |
+
private function processAttributes(){
|
33 |
+
if (null == $this->m_attributes){
|
34 |
+
$attrNodes = $this->m_node->attribute;
|
35 |
+
$this->m_attributes = array();
|
36 |
+
foreach ($attrNodes as $attr){
|
37 |
+
$this->m_attributes[] = new EasyAsk_Impl_AttributeInfo($attr);
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
// Creates a list of ItemRows based off of the nodes relative to the node provided in the constructor.
|
43 |
+
private function processItems(){
|
44 |
+
if (null == $this->m_items){
|
45 |
+
$this->m_items = array();
|
46 |
+
$items = $this->m_node->item;
|
47 |
+
if ($items != null){
|
48 |
+
$dd = $this->m_res->getDataDescriptions();
|
49 |
+
foreach ($items as $item){
|
50 |
+
$this->m_items[] = new EasyAsk_Impl_ItemRow($dd, $item);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
// Returns a list of NavigateCategories made from the CategoryInfo instance for the node.
|
57 |
+
protected function getDetailedCategories($nDisplayMode){
|
58 |
+
$this->processCategories();
|
59 |
+
return $this->m_catInfo->getDetailedCategories($nDisplayMode);
|
60 |
+
}
|
61 |
+
|
62 |
+
// Returns the list of all NavigateCategories made from instance for this node
|
63 |
+
public function getAllCategoryDetails(){
|
64 |
+
return $this->getDetailedCategories(0);
|
65 |
+
}
|
66 |
+
|
67 |
+
// Returns a list of category names.
|
68 |
+
public function getCategories(){
|
69 |
+
$result = array();
|
70 |
+
foreach ($this->getAllCategoryDetails() as $navCat){
|
71 |
+
$result[] = $navCat['content'];
|
72 |
+
}
|
73 |
+
return $result;
|
74 |
+
}
|
75 |
+
|
76 |
+
// Returns the suggested category title created by the CategoryInfo instance.
|
77 |
+
public function getSuggestedCategoryTitle(){
|
78 |
+
$this->processCategories();
|
79 |
+
return $this->m_catInfo->getSuggestedCategoryTitle();
|
80 |
+
}
|
81 |
+
|
82 |
+
// Returns a list of attribute names.
|
83 |
+
public function getAttributeNames(){
|
84 |
+
$this->processAttributes();
|
85 |
+
$result = array();
|
86 |
+
foreach ($this->m_attributes as $info){
|
87 |
+
$result[] = $info['content'];
|
88 |
+
}
|
89 |
+
return $result;
|
90 |
+
}
|
91 |
+
|
92 |
+
// Returnes the AttributeInfo instance for a certain attribute.
|
93 |
+
// Returns null if this attribute is not contained within this instance.
|
94 |
+
private function getAttrInfo($attrName){
|
95 |
+
$this->processAttributes();
|
96 |
+
foreach($this->m_attributes as $attrInfo){
|
97 |
+
if(0 == strcmp($attrName, $attrInfo['content'])){
|
98 |
+
return $attrInfo;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
return null;
|
102 |
+
}
|
103 |
+
|
104 |
+
// Returns a list of NavigateAttributes from the xml node.
|
105 |
+
public function getDetailedAttributeValues($attrName, $displayMode){
|
106 |
+
$attrInfo = $this->getAttrInfo($attrName);
|
107 |
+
if (null != $attrInfo){
|
108 |
+
if ($displayMode == 1 && !$attrInfo->getIsLimited() ){
|
109 |
+
$displayMode = 0;
|
110 |
+
}
|
111 |
+
return $displayMode == 0 ? $attrInfo->getFullList() : $attrInfo->getInitialList();
|
112 |
+
}
|
113 |
+
return array();
|
114 |
+
}
|
115 |
+
|
116 |
+
// Returns the number of ItemRows contained within this GroupInfo
|
117 |
+
public function getNumberOfRows(){
|
118 |
+
$this->processItems();
|
119 |
+
return sizeof($this->m_items);
|
120 |
+
}
|
121 |
+
|
122 |
+
// Returns the total number of rows for the GroupInfo
|
123 |
+
public function getTotalNumberOfRows(){
|
124 |
+
return $this->m_totalRows;
|
125 |
+
}
|
126 |
+
|
127 |
+
public function getSuggestedCategoryID(){
|
128 |
+
return ""; //todo
|
129 |
+
}
|
130 |
+
|
131 |
+
public function getDetailedSuggestedCategory(){
|
132 |
+
return null; //todo
|
133 |
+
}
|
134 |
+
|
135 |
+
// Returns the count of items that match a certain attribute value.
|
136 |
+
public function getAttributeValueCount($attr, $val){
|
137 |
+
$this->processAttributes();
|
138 |
+
foreach ($this->getDetailedAttributeValues($attr, 0) as $navAttr){
|
139 |
+
if (strcmp($navAttr->getValue,$val) == 0){
|
140 |
+
return $navAttr->getProductCount();
|
141 |
+
}
|
142 |
+
}
|
143 |
+
return -1;
|
144 |
+
}
|
145 |
+
|
146 |
+
// Returns the cell data from a specific location in the GroupInfo.
|
147 |
+
public function getCellData($row, $col){
|
148 |
+
$this->processItems();
|
149 |
+
return $this->m_items[$row]->getFormattedText($col);
|
150 |
+
}
|
151 |
+
|
152 |
+
// Returns the index of the last row in the current page.
|
153 |
+
public function getEndRow(){
|
154 |
+
return $this->m_set->getGroupEndRow($this);
|
155 |
+
}
|
156 |
+
|
157 |
+
// Returns the index of the first row in the current page.
|
158 |
+
public function getStartRow(){
|
159 |
+
return $this->m_set->getGroupStartRow($this);
|
160 |
+
}
|
161 |
+
|
162 |
+
// Returns the name of this GroupInfo.
|
163 |
+
public function getGroupValue(){
|
164 |
+
return $this->m_name;
|
165 |
+
}
|
166 |
+
|
167 |
+
// Returns the ResultRow at the specified index.
|
168 |
+
public function getItem($row){
|
169 |
+
$this->processItems();
|
170 |
+
return $this->m_items[$row];
|
171 |
+
}
|
172 |
+
}
|
173 |
+
?>
|
lib/EasyAsk/Impl/GroupedPageLayout.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains info and objects pertinent to the the results that will be displayed
|
3 |
+
// on the screen for a certain search.
|
4 |
+
class EasyAsk_Impl_GroupedPageLayout
|
5 |
+
{
|
6 |
+
private $m_groupStart = null;
|
7 |
+
private $m_groupEnd = null;
|
8 |
+
private $m_startRow = -1;
|
9 |
+
private $m_endRow = -1;
|
10 |
+
|
11 |
+
// Creates a list of GroupedPageLayouts that represent the 'pages' of a search result.
|
12 |
+
public static function layoutPages($pageSize, $groups, $breakGroups){
|
13 |
+
$result = array();
|
14 |
+
if ($pageSize > 0){
|
15 |
+
for ($i = 0; $i < sizeof($groups); $i++){
|
16 |
+
$gr = $groups[i];
|
17 |
+
$groupStart = $gr;
|
18 |
+
$startRow = 1;
|
19 |
+
$totalRows = 0;
|
20 |
+
$groupRows = $gr->getNumberOfRows();
|
21 |
+
while (gr != null){
|
22 |
+
while ($totalRows + $groupRows < $pageSize){
|
23 |
+
$totalRows = $totalRows + $groupRows;
|
24 |
+
if (($i + 1) < sizeof($groups)){
|
25 |
+
$gr = $groups[$i++];
|
26 |
+
$groupRows = $gr->getNumberOfRows();
|
27 |
+
}else{
|
28 |
+
$gpl = new EasyAsk_Impl_GroupedPageLayout();
|
29 |
+
$gpl->m_groupStart = $groupStart;
|
30 |
+
$gpl->m_startRow = $startRow;
|
31 |
+
$gpl->m_groupEnd = $gr;
|
32 |
+
$gpl->m_endRow = $gr->getNumberOfRows();
|
33 |
+
$result[] = $gpl;
|
34 |
+
$gr = null;
|
35 |
+
break;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
if ($gr != null){
|
39 |
+
$gpl = new EasyAsk_Impl_GroupedPageLayout();
|
40 |
+
$gpl->m_groupStart = $groupStart;
|
41 |
+
$gpl->m_startRow = $startRow;
|
42 |
+
$gpl->m_groupEnd = $gr;
|
43 |
+
if ($breakGroups){
|
44 |
+
if ($gr == $groupStart){
|
45 |
+
$gpl->m_endRow = $pageSize - $totalRows + $startRow - 1;
|
46 |
+
}else{
|
47 |
+
$gpl->m_endRow = $pageSize - $totalRows;
|
48 |
+
}
|
49 |
+
}else{
|
50 |
+
$gpl->m_endRow = $gr->getNumberOfRows();
|
51 |
+
}
|
52 |
+
$result[] = $gpl;
|
53 |
+
$totalRows = 0;
|
54 |
+
if ($gpl->m_startRow == $gr->getNumberOfRows()){
|
55 |
+
if (($i + 1) < sizeof($groups)){
|
56 |
+
$gr = $groups[$i++];
|
57 |
+
$groupRows = $gr->getNumberOfRows();
|
58 |
+
$startRow = 1;
|
59 |
+
$groupStart = $gr;
|
60 |
+
}else{
|
61 |
+
$gr = null;
|
62 |
+
}
|
63 |
+
}else{
|
64 |
+
$groupStart = $gr;
|
65 |
+
$startRow = $gpl->m_endRow + 1;
|
66 |
+
$groupRows = $gr->getNumberOfRows() - ($startRow - 1);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}else{
|
72 |
+
if (sizeof($groups) > 0){
|
73 |
+
$gpl = new EasyAsk_Impl_GroupedPageLayout();
|
74 |
+
$gr = $groups[0];
|
75 |
+
$gpl->m_groupStart = $gr;
|
76 |
+
$gpl->m_startRow = 1;
|
77 |
+
$gr = $groups[sizeof($groups) - 1];
|
78 |
+
$gpl->m_groupEnd = $gr;
|
79 |
+
$gpl->m_endRow = $gr->getNumberOfRows90;
|
80 |
+
$result[] = $gpl;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
return $result;
|
84 |
+
}
|
85 |
+
|
86 |
+
public function getStartGroup() {
|
87 |
+
return $this->m_groupStart;
|
88 |
+
}
|
89 |
+
|
90 |
+
public function getEndGroup(){
|
91 |
+
return $this->m_groupEnd;
|
92 |
+
}
|
93 |
+
|
94 |
+
public function getStartRow(){
|
95 |
+
return $this->m_startRow;
|
96 |
+
}
|
97 |
+
|
98 |
+
public function getEndRow(){
|
99 |
+
return $this->m_endRow;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
?>
|
lib/EasyAsk/Impl/GroupedSetInfo.php
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains info about a set of IGroupedResults
|
3 |
+
class EasyAsk_Impl_GroupedSetInfo implements EasyAsk_iGroupedResultSet
|
4 |
+
{
|
5 |
+
private $m_node;
|
6 |
+
private $m_res = null;
|
7 |
+
private $m_groups = null;
|
8 |
+
private $m_layout = null;
|
9 |
+
private $m_type;
|
10 |
+
private $m_criteria = null;
|
11 |
+
private $m_totalGorups;
|
12 |
+
private $m_paginate = false;
|
13 |
+
private $m_breakGroups = false;
|
14 |
+
private $m_maxRowsPerGroup = -1;
|
15 |
+
private $m_totalRows = 0;
|
16 |
+
|
17 |
+
// Creates a GroupedSetInfo instance. Pulls defualt information from an attribute node and the results.
|
18 |
+
function __construct($node, $res){
|
19 |
+
$this->m_node = $node;
|
20 |
+
$this->m_res = $res;
|
21 |
+
$this->m_type = $node->type;
|
22 |
+
$this->m_criteria = $node->name;
|
23 |
+
$this->m_totalGorups = $node->totalGroups;
|
24 |
+
$this->m_paginate = $node->paginate;
|
25 |
+
$this->m_breakGroups = $node->breakGroups;
|
26 |
+
$this->m_maxRowsPerGroup = $node->maxRows;
|
27 |
+
}
|
28 |
+
|
29 |
+
// If the GroupedSetInfo is empty, it is populated with GroupResult instances from nodes
|
30 |
+
// related to the xml node provided in the constructor.
|
31 |
+
private function processGroups(){
|
32 |
+
if ($this->m_groups == null){
|
33 |
+
$this->m_groups = array();
|
34 |
+
foreach($this->m_node->group as $grpNode){
|
35 |
+
$this->m_groups[] = new EasyAsk_Impl_GroupInfo($this->m_res, $grpNode, $this);
|
36 |
+
}
|
37 |
+
$this->m_layout = EasyAsk_Impl_GroupedPageLayout::layoutPages($this->m_paginate ? $this->m_res->getResultsPerPage() : -1,
|
38 |
+
$this->m_groups, $this->m_breakGroups);
|
39 |
+
$this->m_totalRows = 0;
|
40 |
+
foreach ($this->m_groups as $group){
|
41 |
+
$this->m_totalRows += $group->getTotalNumberOfRows();
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
// Returns a GroupedResult located at index i.
|
47 |
+
public function getGroup($i){
|
48 |
+
$this->processGroups();
|
49 |
+
return $this->m_groups[$i];
|
50 |
+
}
|
51 |
+
|
52 |
+
// Returns the total number of groups in the set.
|
53 |
+
public function getNumberOfGroups(){
|
54 |
+
return $this->m_totalGorups;
|
55 |
+
}
|
56 |
+
|
57 |
+
// Returns the type of search
|
58 |
+
public function getGroupCriteriaType(){
|
59 |
+
return $this->m_type;
|
60 |
+
}
|
61 |
+
|
62 |
+
// Returns the criteria of the GroupedResultSet, either the name of the attribute or current category level.
|
63 |
+
public function getGroupCriteria(){
|
64 |
+
return $this->m_criteria;
|
65 |
+
}
|
66 |
+
|
67 |
+
// Returns the maximum number of rows of IGroupedResults this set can hold
|
68 |
+
public function getMaximumRowsPerGroup(){
|
69 |
+
return $this->m_maxRowsPerGroup;
|
70 |
+
}
|
71 |
+
|
72 |
+
// Returns the index of the first group on the current page.
|
73 |
+
public function getStartGroup(){
|
74 |
+
$this->processGroups();
|
75 |
+
$values = array();
|
76 |
+
$values[] = $this->m_res->getCurrentPage();
|
77 |
+
$values[] = sizeof($this->m_layout);
|
78 |
+
$page = min($values);
|
79 |
+
$group = $this->m_layout[$page - 1]->getStartGroup();
|
80 |
+
return $this->m_groups->IndexOf($group);
|
81 |
+
}
|
82 |
+
|
83 |
+
// Returns the index of the last group on the current page.
|
84 |
+
public function getEndGroup(){
|
85 |
+
$this->processGroups();
|
86 |
+
$values = array();
|
87 |
+
$values[] = $this->m_res->getCurrentPage();
|
88 |
+
$values[] = sizeof($this->m_layout);
|
89 |
+
$page = min($values);
|
90 |
+
$group = $this->m_layout[$page - 1]->getEndGroup();
|
91 |
+
return $this->m_groups->IndexOf($group);
|
92 |
+
}
|
93 |
+
|
94 |
+
// Returns the index of the last row contained within the provided group on the current page.
|
95 |
+
public function getGroupEndRow($group){
|
96 |
+
$this->processGroups();
|
97 |
+
$page = $this->m_res->getCurrentPage();
|
98 |
+
$gr = $this->m_layout[$page - 1]->getEndGroup();
|
99 |
+
if ($gr == $group){
|
100 |
+
return $this->m_layout[$page - 1]->getEndRow();
|
101 |
+
}
|
102 |
+
return $group->getNumberOfRows();
|
103 |
+
}
|
104 |
+
|
105 |
+
// Returns the index of the first row contained within the provided group on the current page.
|
106 |
+
public function getGroupStartRow($group){
|
107 |
+
$this->processGroups();
|
108 |
+
$page = $this->m_res->getCurrentPage();
|
109 |
+
$gr = $this->m_layout[$page - 1]->getStartGroup();
|
110 |
+
if ($gr == $group){
|
111 |
+
return $this->m_layout[$page - 1]->getStartRow();
|
112 |
+
}
|
113 |
+
return 1;
|
114 |
+
}
|
115 |
+
|
116 |
+
// Returns the total number of pages that the current GroupedResults have.
|
117 |
+
public function getPageCount(){
|
118 |
+
$this->processGroups();
|
119 |
+
return sizeof($this->m_layout);
|
120 |
+
}
|
121 |
+
|
122 |
+
// Returns the total number of rows contained within the current GroupedResults.
|
123 |
+
public function getTotalNumberOfRows(){
|
124 |
+
$this->processGroups();
|
125 |
+
return $this->m_totalRows;
|
126 |
+
}
|
127 |
+
|
128 |
+
// Returns the node string for a specific group within the set.
|
129 |
+
public function getNodeString($group){
|
130 |
+
$criteria = $group->getGroupValue();
|
131 |
+
if ($this->m_type == 1){
|
132 |
+
foreach ($this->m_res->getDetailedCategories() as $cat){
|
133 |
+
if (strcasecmp($criteria, $cat->getName)){
|
134 |
+
return $cat->getNodeString();
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}else if ($this->m_type == 2){
|
138 |
+
foreach ($this->m_res->getDetailedAttributeValues($this->getGroupCriteria()) as $attr){
|
139 |
+
if (strcasecmp($criteria, $attr->getValue())){
|
140 |
+
return $attr->getNodeString();
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
}
|
146 |
+
?>
|
lib/EasyAsk/Impl/ItemDescriptions.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains information about the current product items.
|
3 |
+
class EasyAsk_Impl_ItemDescriptions{
|
4 |
+
|
5 |
+
private $m_isDrillDownActive = false;
|
6 |
+
private $m_pageCount = -1;
|
7 |
+
private $m_currentPage = -1;
|
8 |
+
private $m_totalItems = -1;
|
9 |
+
private $m_resultsPerPage = -1;
|
10 |
+
private $m_firstItem = -1;
|
11 |
+
private $m_lastItem = -1;
|
12 |
+
private $m_sortOrder = "";
|
13 |
+
private $m_descs = null;
|
14 |
+
|
15 |
+
// Makes a new list of item descriptions and populates from an xml node
|
16 |
+
function __construct($node){
|
17 |
+
if (!$node){
|
18 |
+
$this->m_descs = array();
|
19 |
+
}else{
|
20 |
+
$this->m_isDrillDownActive = $node->isDrillDownActive;
|
21 |
+
$this->m_pageCount = $node->pageCount;
|
22 |
+
$this->m_currentPage = $node->currentPage;
|
23 |
+
$this->m_totalItems = $node->totalItems;
|
24 |
+
$this->m_resultsPerPage = $node->resultsPerPage;
|
25 |
+
$this->m_firstItem = $node->firstItem;
|
26 |
+
$this->m_lastItem = $node->lastItem;
|
27 |
+
$this->m_sortOrder = isset($node->sortOrder)? $node->sortOrder : '';
|
28 |
+
|
29 |
+
$itemDescs = $node->dataDescription;
|
30 |
+
$this->m_descs = array();
|
31 |
+
foreach ($itemDescs as $desc){
|
32 |
+
$this->m_descs[] = new EasyAsk_Impl_DataDescription($desc);
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
function getIsDrillDown() { return $this->m_isDrillDownActive; }
|
38 |
+
|
39 |
+
// Returns the total number of results pages
|
40 |
+
function getPageCount() { return $this->m_pageCount; }
|
41 |
+
|
42 |
+
// Returns the current displayed result page
|
43 |
+
function getCurrentPage() { return $this->m_currentPage; }
|
44 |
+
|
45 |
+
// Returns the total number of product items
|
46 |
+
function getTotalItems() { return $this->m_totalItems; }
|
47 |
+
|
48 |
+
// Returns the current number of items per page
|
49 |
+
function getResultsPerPage() { return $this->m_resultsPerPage; }
|
50 |
+
|
51 |
+
// Returns the index of the first item on the current results page
|
52 |
+
function getFirstItem() { return $this->m_firstItem; }
|
53 |
+
|
54 |
+
// Returns the index of the last item on the current results page
|
55 |
+
function getLastItem() { return $this->m_lastItem; }
|
56 |
+
|
57 |
+
// Returns the sort order currently emplyed by the results
|
58 |
+
function getSortOrder() { return $this->m_sortOrder; }
|
59 |
+
|
60 |
+
// Returns a list containing the descriptions for all the items
|
61 |
+
function getDataDescriptions() { return $this->m_descs; }
|
62 |
+
|
63 |
+
// Returns the index of a specific item description within the list
|
64 |
+
// Returns -1 if the item description is not found
|
65 |
+
function getColumnIndex($colName){
|
66 |
+
for ($i = 0; $i < count($this->m_descs); $i++){
|
67 |
+
$desc = $this->m_descs[$i];
|
68 |
+
if (0 == strcmp($colName, $desc->getColName())){
|
69 |
+
return $i;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
return -1;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
?>
|
lib/EasyAsk/Impl/ItemRow.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains product data in columns. Used to display products.
|
3 |
+
class EasyAsk_Impl_ItemRow implements EasyAsk_iResultRow
|
4 |
+
{
|
5 |
+
private $m_items;
|
6 |
+
|
7 |
+
// Creates the ItemRow
|
8 |
+
function __construct($desc, $item)
|
9 |
+
{
|
10 |
+
$this->m_items = array();
|
11 |
+
foreach($desc as $dd){
|
12 |
+
$tagname = $dd->getTagName();
|
13 |
+
$val = isset($item->$tagname)?$item->$tagname:'';
|
14 |
+
if ($val){
|
15 |
+
$this->m_items[] = $val;
|
16 |
+
}else{
|
17 |
+
$this->m_items[] = "";
|
18 |
+
}
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
// Returns the data contained in a specific column
|
23 |
+
function getFormattedText($col)
|
24 |
+
{
|
25 |
+
return $col >= 0?(String)$this->m_items[$col]:'';
|
26 |
+
}
|
27 |
+
|
28 |
+
// Returns the data contained in a specific column
|
29 |
+
public function getCellData($col){
|
30 |
+
return $this->m_items[$col];
|
31 |
+
}
|
32 |
+
|
33 |
+
// Returns the amount of columns contained within the row
|
34 |
+
public function size(){
|
35 |
+
return sizeof($this->m_items);
|
36 |
+
}
|
37 |
+
}
|
38 |
+
?>
|
lib/EasyAsk/Impl/NavigateAttribute.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Represents a seach advisor attribute.
|
3 |
+
class EasyAsk_Impl_NavigateAttribute implements EasyAsk_iNavigateAttribute{
|
4 |
+
private $m_displayAsLink = false;
|
5 |
+
private $m_name;
|
6 |
+
private $m_productCount;
|
7 |
+
private $m_type;
|
8 |
+
private $m_value;
|
9 |
+
private $m_nodeString;
|
10 |
+
private $m_valueType;
|
11 |
+
private $m_minValue;
|
12 |
+
private $m_maxValue;
|
13 |
+
private $m_minRangeValue;
|
14 |
+
private $m_maxRangeValue;
|
15 |
+
private $m_rangeRound;
|
16 |
+
|
17 |
+
// Generates a NavigateAttribute based off of an attribute xml node
|
18 |
+
function __construct($name, $node){
|
19 |
+
$this->m_name = $name;
|
20 |
+
$this->m_displayAsLink = $node->displayAsLink;
|
21 |
+
$this->m_productCount = $node->productCount;
|
22 |
+
$this->m_type = $node->attrType;
|
23 |
+
$this->m_nodeString = $node->nodeString;
|
24 |
+
$this->m_valueType = $node->valueType;
|
25 |
+
$this->m_minValue = isset($node->minValue) ? $node->minValue : 0;
|
26 |
+
$this->m_maxValue = isset($node->maxValue) ? $node->maxValue : 0;
|
27 |
+
$this->m_minRangeValue = isset($node->minRangeValue) ? $node->minRangeValue : 0;
|
28 |
+
$this->m_maxRangeValue = isset($node->maxRangeValue) ? $node->maxRangeValue : 0;
|
29 |
+
$this->m_rangeRound = isset($node->rangeRound) ? $node->rangeRound : 0;
|
30 |
+
$this->m_value = $node;
|
31 |
+
}
|
32 |
+
|
33 |
+
// Whether this attribute should be displayed as a link
|
34 |
+
function getDisplayAsLink() { return $this->m_displayAsLink; }
|
35 |
+
|
36 |
+
// Gets the name of the attribute
|
37 |
+
function getName() { return $this->m_name; }
|
38 |
+
|
39 |
+
// The number of products contained within this attribute
|
40 |
+
function getProductCount() { return $this->m_productCount; }
|
41 |
+
|
42 |
+
// Gets the type of attribute this is. (Color, Size, Product Type, etc)
|
43 |
+
function getType() { return $this->m_type; }
|
44 |
+
|
45 |
+
// Gets the value contained within this INavigateAttribute. The data used to sort/seperate.
|
46 |
+
function getValue() { return $this->m_value; }
|
47 |
+
|
48 |
+
// Gets the valueType contained within this INavigateAttribute. The data used to sort/seperate.
|
49 |
+
function getValueType() { return $this->m_valueType; }
|
50 |
+
|
51 |
+
// Returns ths node location which this attribute is located under.
|
52 |
+
public function getNodeString(){ return $this->m_nodeString; }
|
53 |
+
|
54 |
+
// Returns the min Value of the selection.
|
55 |
+
public function getMinValue(){ return $this->m_minValue; }
|
56 |
+
|
57 |
+
// Returns the max Value of the selection.
|
58 |
+
public function getMaxValue(){ return $this->m_maxValue; }
|
59 |
+
|
60 |
+
// Returns the min Value of the range.
|
61 |
+
public function getMinRangeValue(){ return $this->m_minRangeValue; }
|
62 |
+
|
63 |
+
// Returns the max Value of the range.
|
64 |
+
public function getMaxRangeValue(){ return $this->m_maxRangeValue; }
|
65 |
+
|
66 |
+
// Returns the round value of the range.
|
67 |
+
public function getRangeRound(){ return $this->m_rangeRound; }
|
68 |
+
|
69 |
+
// Returns ths dispaly name of this attribute.
|
70 |
+
public function getDisplayName(){
|
71 |
+
return $this->m_value->attributeValue;
|
72 |
+
}
|
73 |
+
|
74 |
+
private $splitPathSep = "////";
|
75 |
+
private $splitValSep = ";;;;";
|
76 |
+
|
77 |
+
// removes references to this node from the path sent in.
|
78 |
+
function removeFromPath($path){
|
79 |
+
$nodes = split($splitPathSep, $path);
|
80 |
+
$sb;
|
81 |
+
$key = getName() . " = '" . getValue() . "'";
|
82 |
+
for ($i = 0; $i < sizeof($nodes); $i++)
|
83 |
+
{
|
84 |
+
if (strpos($nodes[i],"AttribSelect=")){
|
85 |
+
$sbNewVal = "";
|
86 |
+
$nodeVal = strstr($nodes[i],sizeof("AttribSelect="));
|
87 |
+
$vals = split($splitValSep, $nodeVal);
|
88 |
+
for ($j = 0; $j < size($vals); $j++){
|
89 |
+
if (strcmp($vals[j],$key) != 0){
|
90 |
+
if (0 < size($sbNewVal)){
|
91 |
+
$sbNewVal = $sbNewVal . ";;;;";
|
92 |
+
}
|
93 |
+
$sbNewVal = $sbNewVal . $vals[j];
|
94 |
+
}
|
95 |
+
}
|
96 |
+
if (0 < sizeof($sbNewVal)){
|
97 |
+
if (0 < sizeof($sb)){
|
98 |
+
$sb = $sb . "////";
|
99 |
+
}
|
100 |
+
$sb = $sb . "AttribSelect=";
|
101 |
+
$sb = $sb . $sbNewVal;
|
102 |
+
}
|
103 |
+
}else{
|
104 |
+
if (0 < sizeof($sb)){
|
105 |
+
$sb = $sb . "////";
|
106 |
+
}
|
107 |
+
$sb = $sb . $nodes[i];
|
108 |
+
}
|
109 |
+
}
|
110 |
+
return $sb;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
?>
|
lib/EasyAsk/Impl/NavigateCategory.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Represents a search advisor category
|
3 |
+
class EasyAsk_Impl_NavigateCategory implements EasyAsk_iNavigateCategory
|
4 |
+
{
|
5 |
+
private $m_productCount = -1;
|
6 |
+
private $m_name;
|
7 |
+
private $m_ids = null;
|
8 |
+
private $m_subCategories = null;
|
9 |
+
private $m_nodeString = null;
|
10 |
+
private $m_seoPath = null;
|
11 |
+
|
12 |
+
// Generates the Navigate Category based off of a category xml node
|
13 |
+
function __construct($def){
|
14 |
+
$this->m_name = $def->name;
|
15 |
+
$this->m_productCount = $def->productCount;
|
16 |
+
$this->m_nodeString = $def->nodeString;
|
17 |
+
$this->m_seoPath = $def->seoPath;
|
18 |
+
|
19 |
+
$attrIDs = $def->ids;
|
20 |
+
if (null != $attrIDs){
|
21 |
+
$ids = explode(",", $attrIDs);
|
22 |
+
$this->m_ids = array();
|
23 |
+
foreach($ids as $id){
|
24 |
+
$this->m_ids[] = $id;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
$subCats = isset($def->subCategories->category)?$def->subCategories->category:null;
|
28 |
+
if (null != $subCats){
|
29 |
+
$this->m_subCategories = array();
|
30 |
+
foreach($subCats as $sub)
|
31 |
+
{
|
32 |
+
$this->m_subCategories[] = new EasyAsk_Impl_NavigateCategory($sub);
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
// Returns the category name
|
38 |
+
public function getName() { return $this->m_name; }
|
39 |
+
|
40 |
+
// Returns the total number of products that have this category. Returns -1 if this is unkown.
|
41 |
+
public function getProductCount() { return $this->m_productCount; }
|
42 |
+
|
43 |
+
// returns a list of ids (as Strings) that correspond to the category named in this object.
|
44 |
+
//The list will contain at least 1 entry and possibly more if there are multiple categories
|
45 |
+
//with the same name at the same level. The ids will be only from categories that are referenced by
|
46 |
+
//products in the result set, that is, if there are 5 categories with the same name, but only 3 of them are
|
47 |
+
//referenced in the result set, then the list will contain 3 Strings not 5
|
48 |
+
public function getIDs() { return $this->m_ids; }
|
49 |
+
|
50 |
+
// Returns a list of NavigateCategory corresponding to the subcategories of this node
|
51 |
+
// (if any exist and the AdvisorOptions requested that the be generated) or null.
|
52 |
+
public function getSubCategories() { return $this->m_subCategories; }
|
53 |
+
|
54 |
+
// Returns a string corresponding to the path segment for this category. See NavigateNode.toString()
|
55 |
+
public function getNodeString(){
|
56 |
+
return $this->m_nodeString;
|
57 |
+
}
|
58 |
+
|
59 |
+
// Returns a string corresponding to the full path to this category
|
60 |
+
public function getSEOPath(){
|
61 |
+
return $this->m_seoPath;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
?>
|
lib/EasyAsk/Impl/NavigateHierarchy.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Represents a search advisor category hierarchy node.
|
3 |
+
class EasyAsk_Impl_NavigateHierarchy implements EasyAsk_iNavigateHierarchy{
|
4 |
+
private $m_name;
|
5 |
+
private $m_path;
|
6 |
+
private $m_subNodes;
|
7 |
+
private $m_isSelected;
|
8 |
+
private $m_ids = null;
|
9 |
+
|
10 |
+
// Builds the navigate hierarchy based off of an appropriate xml node
|
11 |
+
function __construct($node){
|
12 |
+
$this->m_name = $node;
|
13 |
+
$this->m_path = $node->navHierPath;
|
14 |
+
$this->m_isSelected = $node->isSelected;
|
15 |
+
$subNodes = $node->navSubNodes->navHierNode;
|
16 |
+
|
17 |
+
$this->m_subNodes = array();
|
18 |
+
if ($subNodes != null){
|
19 |
+
foreach ($subNodes as $sub){
|
20 |
+
$this->m_subNodes[] = new EasyAsk_Impl_NavigateHierarchy($sub);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
$idList = $node->ids;
|
24 |
+
$this->m_ids = array();
|
25 |
+
if ($idList){
|
26 |
+
$ids = split(',', $idList);
|
27 |
+
foreach($ids as $id){
|
28 |
+
$this->m_ids[] = $id;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
// The hierarchy node name, that is, the category name corresponding to this node.
|
34 |
+
function getName() { return $this->m_name; }
|
35 |
+
|
36 |
+
// The category path from root node to this node. The path is seperated by the standard path delimiter (////).
|
37 |
+
// The path can be used to perform a category expand to this node.
|
38 |
+
function getPath() { return $this->m_path; }
|
39 |
+
|
40 |
+
// Returns a list of NavigateHierarchy corresponding to the sub nodes of this node. A node will have sub nodes if it is
|
41 |
+
// the selected node and that category has children, or if it is a sibling node that is on the path to the selected node.
|
42 |
+
function getSubNodes() { return $this->m_subNodes; }
|
43 |
+
|
44 |
+
// Whether this node corresponds to the current suggested category.
|
45 |
+
function isSelected() { return $this->m_isSelected; }
|
46 |
+
|
47 |
+
// Returns a list of IDs (as Strings) that correspong to the category named in this object. The list will contain at least
|
48 |
+
// 1 entry and possibibly more if there are multiple categories with the same name at the same level. The list can be
|
49 |
+
// empty for the toplevel node 'All Products'
|
50 |
+
function getIDs() { return $this->m_ids; }
|
51 |
+
}
|
52 |
+
|
53 |
+
?>
|
lib/EasyAsk/Impl/NavigateNode.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// A specific node within the product heirarchy.
|
3 |
+
class EasyAsk_Impl_NavigateNode implements EasyAsk_iNavigateNode
|
4 |
+
{
|
5 |
+
private $m_value;
|
6 |
+
private $m_path;
|
7 |
+
private $m_purePath;
|
8 |
+
private $m_SEOPath;
|
9 |
+
private $m_type;
|
10 |
+
private $m_englishName;
|
11 |
+
|
12 |
+
// Builds a node based off of the xml node provided
|
13 |
+
function __construct($node){
|
14 |
+
$this->m_value = $node->value;
|
15 |
+
$this->m_path = $node->path;
|
16 |
+
$this->m_purePath = $node->purePath;
|
17 |
+
$this->m_SEOPath = isset($node->seoPath)?$node->seoPath:'';
|
18 |
+
$this->m_type = $node->navNodePathType;
|
19 |
+
$this->m_englishName = $node->englishName;
|
20 |
+
}
|
21 |
+
|
22 |
+
// Gets the value contained in the node.
|
23 |
+
function getValue() { return $this->m_value; }
|
24 |
+
|
25 |
+
// Gets the path to the node in the hierarchy
|
26 |
+
function getPath() { return $this->m_path; }
|
27 |
+
|
28 |
+
// Gets the pure path to the node in the hierarchy
|
29 |
+
function getPurePath() { return $this->m_purePath; }
|
30 |
+
|
31 |
+
// Gets the Search Engine Optimization path for the node
|
32 |
+
function getSEOPath() { return $this->m_SEOPath; }
|
33 |
+
|
34 |
+
// Returns the type of node
|
35 |
+
function getType() { return $this->m_type; }
|
36 |
+
|
37 |
+
// Returns the natural language english version of the node name
|
38 |
+
function getEnglishName() { return $this->m_englishName; }
|
39 |
+
|
40 |
+
// Returns the label associated with this node
|
41 |
+
// eg: Item Category, User Search, Color, etc
|
42 |
+
public function getLabel(){
|
43 |
+
if ($this->m_type == 2){
|
44 |
+
substr($this->m_englishName, 1, (strrpos("=", $this->m_englishName) - 1));
|
45 |
+
} else if ($this->m_type == 1){
|
46 |
+
return "Item Category";
|
47 |
+
} else if ($this->m_type == 3){
|
48 |
+
return "User Search";
|
49 |
+
}
|
50 |
+
return null;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
?>
|
lib/EasyAsk/Impl/Options.php
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Used by RemoteEasyAsk to set global values for the instance.
|
3 |
+
class EasyAsk_Impl_Options implements EasyAsk_iOptions
|
4 |
+
{
|
5 |
+
private $m_dictionary = null;
|
6 |
+
private $m_navigateHierarcy = false;
|
7 |
+
private $m_subCategories = false;
|
8 |
+
private $m_toplevelProducts = false;
|
9 |
+
private $m_returnSKUs = false;
|
10 |
+
private $m_resultsPerPage = -1;
|
11 |
+
private $m_sortOrder = null;
|
12 |
+
private $m_grouping = null;
|
13 |
+
private $m_calloutParam = null;
|
14 |
+
// groupid and customerid are added for the sake of customized pricing
|
15 |
+
private $m_groupId = null;
|
16 |
+
private $m_customerId = null;
|
17 |
+
private $m_customer = null;
|
18 |
+
|
19 |
+
// Builds the options based off of the current dictionary
|
20 |
+
function __construct($dictionary){
|
21 |
+
$this->m_dictionary = $dictionary;
|
22 |
+
}
|
23 |
+
|
24 |
+
// Sets the dictionary for the EasyAsk instance.
|
25 |
+
public function setDictionary($name){
|
26 |
+
$this->m_dictionary = $name;
|
27 |
+
}
|
28 |
+
|
29 |
+
// Gets the dictionary for the EasyAsk instance.
|
30 |
+
public function getDictionary(){
|
31 |
+
return $this->m_dictionary;
|
32 |
+
}
|
33 |
+
|
34 |
+
// Sets whether the instance has a Navigation Hierarchy
|
35 |
+
public function setNavigateHierarchy($val){
|
36 |
+
$this->m_navigateHierarcy = $val;
|
37 |
+
}
|
38 |
+
|
39 |
+
// Returns if the instance has a Navigation Hierarchy
|
40 |
+
public function getNavigateHierarchy(){
|
41 |
+
return $this->m_navigateHierarcy;
|
42 |
+
}
|
43 |
+
|
44 |
+
// Sets whether the instance has sub categories
|
45 |
+
public function setSubCategories($val){
|
46 |
+
$this->m_subCategories = $val;
|
47 |
+
}
|
48 |
+
|
49 |
+
// Returns if the instance has sub categories
|
50 |
+
public function getSubCategories(){
|
51 |
+
return $this->m_subCategories;
|
52 |
+
}
|
53 |
+
|
54 |
+
// Set whether the instance has top level products
|
55 |
+
public function setToplevelProducts($val){
|
56 |
+
$this->m_toplevelProducts = $val;
|
57 |
+
}
|
58 |
+
|
59 |
+
// Returns if the instance has top level products
|
60 |
+
public function getToplevelProducts(){
|
61 |
+
return $this->m_toplevelProducts;
|
62 |
+
}
|
63 |
+
|
64 |
+
// Sets the current results per page
|
65 |
+
public function setResultsPerPage($val){
|
66 |
+
$this->m_resultsPerPage = $val;
|
67 |
+
}
|
68 |
+
|
69 |
+
// Returns the current results per page
|
70 |
+
public function getResultsPerPage(){
|
71 |
+
return $this->m_resultsPerPage;
|
72 |
+
}
|
73 |
+
|
74 |
+
// Sets a sort order for the current results
|
75 |
+
public function setSortOrder($val){
|
76 |
+
$this->m_sortOrder = $val;
|
77 |
+
}
|
78 |
+
|
79 |
+
// Gets the sort order of the current results
|
80 |
+
public function getSortOrder(){
|
81 |
+
return urlencode($this->m_sortOrder);
|
82 |
+
}
|
83 |
+
|
84 |
+
// Sets the Stock Keeping Unit for the instance
|
85 |
+
public function setReturnSKUs($val){
|
86 |
+
$this->m_returnSKUs = $val;
|
87 |
+
}
|
88 |
+
|
89 |
+
// Return the Stock Keeping Unit for the instance
|
90 |
+
public function getReturnSKUs(){
|
91 |
+
return $this->m_returnSKUs;
|
92 |
+
}
|
93 |
+
|
94 |
+
// Set the grouping for the current results
|
95 |
+
public function setGrouping($val){
|
96 |
+
$this->m_grouping = $val;
|
97 |
+
}
|
98 |
+
|
99 |
+
// Gets the grouping of the current result
|
100 |
+
public function getGrouping(){
|
101 |
+
return $this->m_grouping;
|
102 |
+
}
|
103 |
+
|
104 |
+
// Sets the Call out Parameter for the current instance
|
105 |
+
public function setCallOutParam($val){
|
106 |
+
$this->m_calloutParam = $val;
|
107 |
+
}
|
108 |
+
|
109 |
+
// Gets the call out parameter for the current instance
|
110 |
+
public function getCallOutParam(){
|
111 |
+
return $this->m_calloutParam;
|
112 |
+
}
|
113 |
+
|
114 |
+
// Sets the groupid parameter for the current instance.
|
115 |
+
public function setGroupId($groupId){
|
116 |
+
$this->m_groupId = $groupId;
|
117 |
+
}
|
118 |
+
|
119 |
+
// Gets the groupid parameter for the current instance
|
120 |
+
public function getGroupId(){
|
121 |
+
return $this->m_groupId;
|
122 |
+
}
|
123 |
+
|
124 |
+
// Sets the customerid parameter for the current instance.
|
125 |
+
public function setCustomerId($customerId){
|
126 |
+
$this->m_customerId = $customerId;
|
127 |
+
}
|
128 |
+
|
129 |
+
// Gets the customerid parameter for the current instance
|
130 |
+
public function getCustomerId(){
|
131 |
+
return $this->m_customerId;
|
132 |
+
}
|
133 |
+
|
134 |
+
// Sets the customer parameter for the current instance.
|
135 |
+
public function setCustomer($customer){
|
136 |
+
$this->m_customer = $customer;
|
137 |
+
}
|
138 |
+
|
139 |
+
// Gets the customer parameter for the current instance
|
140 |
+
public function getCustomer(){
|
141 |
+
return $this->m_customer;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
?>
|
lib/EasyAsk/Impl/RemoteEasyAsk.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// The Easy Ask Session
|
3 |
+
class EasyAsk_Impl_RemoteEasyAsk implements EasyAsk_iRemoteEasyAsk{
|
4 |
+
// connection info
|
5 |
+
private $m_sHostName = "";
|
6 |
+
private $m_nPort = -1;
|
7 |
+
|
8 |
+
private $m_sProtocol = "http";
|
9 |
+
private $m_sRootUri = "EasyAsk/apps/Advisor.jsp";
|
10 |
+
|
11 |
+
private $m_options = null;
|
12 |
+
|
13 |
+
// Creates the EasyAsk instance.
|
14 |
+
function __construct($sHostName, $nPort, $dictionary){
|
15 |
+
$this->m_sHostName = $sHostName;
|
16 |
+
$this->m_nPort = $nPort;
|
17 |
+
$this->m_options = new EasyAsk_Impl_Options($dictionary);
|
18 |
+
}
|
19 |
+
|
20 |
+
// Creates the generic URL for the website.
|
21 |
+
private function formBaseURL(){
|
22 |
+
$port = ($this->m_nPort || sizeof($this->m_nPort) > 0) ? ":" . $this->m_nPort : "";
|
23 |
+
return $this->m_sProtocol . "://" . $this->m_sHostName . $port . "/" . $this->m_sRootUri . "?disp=json&oneshot=1&defarrangeby=///NONE///";//&defarrangeby=ARRANGE_BY_NONE";
|
24 |
+
}
|
25 |
+
|
26 |
+
// Converts a string parameter to a format usable by the website URL
|
27 |
+
private function addParam($name, $val){
|
28 |
+
return (null != $val && strlen($val) > 0) ? "&" . $name . "=" . $val : "";
|
29 |
+
}
|
30 |
+
|
31 |
+
// Converts a boolean parameter to a format usable by the website URL
|
32 |
+
private function addTrueParam($name, $val){
|
33 |
+
return $val ? "&" . $name . "=" . $val : "";
|
34 |
+
}
|
35 |
+
|
36 |
+
// Coverts a value without a name to a format usable by the website URL
|
37 |
+
private function addNonNullVal($val){
|
38 |
+
return $val != null ? $val : "";
|
39 |
+
}
|
40 |
+
|
41 |
+
// Creates a url for the current host settings and EasyAsk options
|
42 |
+
private function formURL(){
|
43 |
+
return $this->formBaseURL() . "&dct=" . $this->m_options->getDictionary() . "&indexed=1" .
|
44 |
+
"&ResultsPerPage=" . $this->m_options->getResultsPerPage() .
|
45 |
+
$this->addParam("defsortcols", $this->m_options->getSortOrder()) .
|
46 |
+
$this->addTrueParam("subcategories", $this->m_options->getSubCategories()) .
|
47 |
+
$this->addTrueParam("rootprods", $this->m_options->getToplevelProducts()) .
|
48 |
+
$this->addTrueParam("navigatehierarchy", $this->m_options->getNavigateHierarchy()) .
|
49 |
+
$this->addTrueParam("returnskus", $this->m_options->getReturnSKUs()) .
|
50 |
+
$this->addParam("defarrangeby", $this->m_options->getGrouping()) .
|
51 |
+
$this->addParam("eap_GroupID", $this->m_options->getGroupId()) .
|
52 |
+
$this->addParam("eap_CustomerID", $this->m_options->getCustomerId()) .
|
53 |
+
$this->addParam("customer", $this->m_options->getCustomer()) .
|
54 |
+
$this->addNonNullVal($this->m_options->getCallOutParam());
|
55 |
+
}
|
56 |
+
|
57 |
+
// User performs a search. Creates a URL based off of the search and then creates a RemoteResults and
|
58 |
+
// loads the URL into it.
|
59 |
+
function userSearch($path, $question){
|
60 |
+
$url = $this->formURL() . "&RequestAction=advisor&CatPath=" . urlencode($path) . "&RequestData=CA_Search&q=" . urlencode($question);
|
61 |
+
return $this->urlPost($url);
|
62 |
+
}
|
63 |
+
|
64 |
+
// User clicks on a category. Creates a URL based off of the action and then creates a RemoteResults and
|
65 |
+
// loads the URL into it.
|
66 |
+
function userCategoryClick($path, $cat){
|
67 |
+
$pathToCat = ($path != null && strlen($path) > 0 ? ($path . "/") : "") . $cat;
|
68 |
+
$url = $this->formURL() . "&RequestAction=advisor&CatPath=" . urlencode($pathToCat) . "&RequestData=CA_CategoryExpand";
|
69 |
+
return $this->urlPost($url);
|
70 |
+
}
|
71 |
+
|
72 |
+
// User clicks on a breadcrumb. Creates a URL based off of the action and then creates a RemoteResults and
|
73 |
+
// loads the URL into it.
|
74 |
+
function userBreadCrumbClick($path){
|
75 |
+
$url = $this->formURL() . "&RequestAction=advisor&CatPath=" . urlencode($path) . "&RequestData=CA_BreadcrumbSelect";
|
76 |
+
return $this->urlPost($url);
|
77 |
+
}
|
78 |
+
|
79 |
+
// User clicks on a attribute. Creates a URL based off of the action and then creates a RemoteResults and
|
80 |
+
// loads the URL into it.
|
81 |
+
function userAttributeClick($path, $attr){
|
82 |
+
$url = $this->formURL() . "&RequestAction=advisor&CatPath=" . urlencode($path) . "&RequestData=CA_AttributeSelected&AttribSel=" . urlencode($attr);
|
83 |
+
return $this->urlPost($url);
|
84 |
+
}
|
85 |
+
|
86 |
+
// User performs a page operation. Creates a URL based off of the action and then creates a RemoteRsults
|
87 |
+
// instance and loads the URL into it.
|
88 |
+
function userPageOp($path, $curPage, $pageOp){
|
89 |
+
$url = $this->formURL() . "&RequestAction=navbar&CatPath=" . urlencode($path) . "&RequestData=" . urlencode($pageOp);
|
90 |
+
if ($curPage != null && strlen($curPage) > 0){
|
91 |
+
$url += "¤tpage=" . $curPage;
|
92 |
+
}
|
93 |
+
return $this->urlPost($url);
|
94 |
+
}
|
95 |
+
|
96 |
+
// User requests to go to a specific page. Creates a URL based off of the action and then creates a RemoteResults
|
97 |
+
// instance and loads the URL into it.
|
98 |
+
function userGoToPage($path, $pageNumber){
|
99 |
+
$url = $this->formURL() . "&RequestAction=navbar&CatPath=" . urlencode($path) . "&RequestData=page" . $pageNumber;
|
100 |
+
return $this->urlPost($url);
|
101 |
+
}
|
102 |
+
|
103 |
+
// Sets the protocol. By default it is http.
|
104 |
+
function setProtocol($protocol){
|
105 |
+
$this->m_sProtocol = $protocol;
|
106 |
+
}
|
107 |
+
|
108 |
+
// Sets the EasyAsk options to an Options instance
|
109 |
+
function setOptions($val){
|
110 |
+
$this->m_options = $val;
|
111 |
+
}
|
112 |
+
|
113 |
+
// Gets the current EasyAsk Options
|
114 |
+
function getOptions(){
|
115 |
+
return $this->m_options;
|
116 |
+
}
|
117 |
+
|
118 |
+
// User Post does an http POST. Creates a RemoteResults instance and
|
119 |
+
// and Posts the URL to get results from the EasyAsk server.
|
120 |
+
public function urlPost($url){
|
121 |
+
echo $url;
|
122 |
+
$res = new EasyAsk_Impl_RemoteResults();
|
123 |
+
$res->load($url);
|
124 |
+
return $res;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
?>
|
lib/EasyAsk/Impl/RemoteFactory.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Create a new RemoteEasyAsk instance on website startup
|
3 |
+
class EasyAsk_Impl_RemoteFactory
|
4 |
+
{
|
5 |
+
public static function create($hostName, $port, $dictionary){
|
6 |
+
return new EasyAsk_Impl_RemoteEasyAsk($hostName, $port, $dictionary);
|
7 |
+
}
|
8 |
+
}
|
9 |
+
?>
|
lib/EasyAsk/Impl/RemoteResults.php
ADDED
@@ -0,0 +1,616 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Serves as the xml document that holds search results
|
3 |
+
class EasyAsk_Impl_RemoteResults implements EasyAsk_iNavigateResults{
|
4 |
+
private $m_doc;
|
5 |
+
private $m_attrsInfo = null;
|
6 |
+
private $m_catPath = null;
|
7 |
+
private $m_itemDescriptions = null;
|
8 |
+
private $m_items;
|
9 |
+
private $m_bct = null;
|
10 |
+
private $m_bHierarachyProcessed = false;
|
11 |
+
private $m_navHier = null;
|
12 |
+
private $m_commonAttributes = null;
|
13 |
+
private $m_commentary = null;
|
14 |
+
private $m_displayFormat = null;
|
15 |
+
private $m_catInfo = null;
|
16 |
+
private $m_groupSet = null;
|
17 |
+
private $m_isGrouped = false;
|
18 |
+
private $m_featuredProducts = null;
|
19 |
+
private $m_carveOuts = null;
|
20 |
+
private $m_arrangedByChoices = null;
|
21 |
+
private $m_banners = null;
|
22 |
+
|
23 |
+
// Creates a new instance.
|
24 |
+
function __construct(){
|
25 |
+
$this->m_doc = new DOMDocument();
|
26 |
+
}
|
27 |
+
|
28 |
+
// Loads a URL into the instance, then determines the appropriate results and layout.
|
29 |
+
function load($url){
|
30 |
+
$start = microtime(true);
|
31 |
+
//$xml = file_get_contents($url);
|
32 |
+
$xml = $this->url_get_contents($url);
|
33 |
+
$xmltime = microtime(true);
|
34 |
+
Mage::log("Profile Info: Time to get EasyAsk xml " . ($xmltime - $start));
|
35 |
+
$this->m_doc = json_decode($xml);
|
36 |
+
$objecttime = microtime(true);
|
37 |
+
Mage::log("Profile Info: Time to make EasyAsk xml object " . ($objecttime - $xmltime));
|
38 |
+
$this->determineLayout();
|
39 |
+
}
|
40 |
+
|
41 |
+
function url_get_contents ($Url) {
|
42 |
+
if (!function_exists('curl_init')){
|
43 |
+
die('CURL is not installed!');
|
44 |
+
}
|
45 |
+
$ch = curl_init();
|
46 |
+
curl_setopt($ch, CURLOPT_URL, $Url);
|
47 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
48 |
+
$output = curl_exec($ch);
|
49 |
+
curl_close($ch);
|
50 |
+
return $output;
|
51 |
+
}
|
52 |
+
|
53 |
+
// If there is a code xml node in the xmlDoc, returns the contained code.
|
54 |
+
function getReturnCode(){
|
55 |
+
$nodeRC = $this->m_doc->returnCode;
|
56 |
+
if ($nodeRC >= 0){
|
57 |
+
$rc = $nodeRC;
|
58 |
+
return $rc;
|
59 |
+
}
|
60 |
+
return -1;
|
61 |
+
}
|
62 |
+
|
63 |
+
// If an error message currently exists in the RemoteRestults, returns it.
|
64 |
+
function getErrorMsg(){
|
65 |
+
$node = $this->m_doc->errorMsg;
|
66 |
+
return null != $node ? $node : null;
|
67 |
+
}
|
68 |
+
|
69 |
+
// Returns the Search Engine Optimization path based off of the current bread crumb trail.
|
70 |
+
function getCatPath(){
|
71 |
+
$purePath = $this->m_doc->source->navPath->navPathNodeList[sizeof($this->m_doc->source->navPath->navPathNodeList) - 1]->purePath;
|
72 |
+
return $this->m_catPath = ($purePath ? $purePath : "All Products");
|
73 |
+
}
|
74 |
+
|
75 |
+
function getPath(){
|
76 |
+
return $this->getCatPath();
|
77 |
+
}
|
78 |
+
|
79 |
+
// Creates a new CategoriesInfo instance based off of the xml doc
|
80 |
+
private function processCategories(){
|
81 |
+
if ($this->m_catInfo == null){
|
82 |
+
$this->m_catInfo = new EasyAsk_Impl_CategoriesInfo($this->m_doc->source);
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
// Returns the current list of ResultCategory
|
87 |
+
function getDetailedCategories($nDisplayMode){
|
88 |
+
$this->processCategories();
|
89 |
+
return $this->m_catInfo->getDetailedCategories($nDisplayMode);
|
90 |
+
}
|
91 |
+
|
92 |
+
// Returns the current list of ResultCategory
|
93 |
+
function getDetailedCategoriesFull(){
|
94 |
+
return $this->getDetailedCategories(0);
|
95 |
+
}
|
96 |
+
|
97 |
+
// Returns the initial list size for categories
|
98 |
+
function getInitDisplayLimitForCategories(){
|
99 |
+
$this->processCategories();
|
100 |
+
return $this->m_catInfo->getInitDisplayLimitForCategories();
|
101 |
+
}
|
102 |
+
|
103 |
+
// Return a string for the suggested category name (common parent)
|
104 |
+
function getSuggestedCategoryTitle(){
|
105 |
+
$this->processCategories();
|
106 |
+
return $this->m_catInfo->getSuggestedCategoryTitle();
|
107 |
+
}
|
108 |
+
|
109 |
+
function getSuggestedCategoryID(){
|
110 |
+
$this->processCategories();
|
111 |
+
return $this->m_catInfo->getSuggestedCategoryID();
|
112 |
+
}
|
113 |
+
|
114 |
+
// Creates an ItemDecriptions instance for the xmlDoc
|
115 |
+
private function processItemDescriptions(){
|
116 |
+
if ($this->m_itemDescriptions == null){
|
117 |
+
if (isset($this->m_doc->source->products)){
|
118 |
+
$node = $this->m_doc->source->products->itemDescription;
|
119 |
+
if ($node){
|
120 |
+
$this->m_itemDescriptions = new EasyAsk_Impl_ItemDescriptions($node);
|
121 |
+
}else{
|
122 |
+
$this->m_itemDescriptions = new EasyAsk_Impl_ItemDescriptions(null);
|
123 |
+
}
|
124 |
+
} else {
|
125 |
+
$this->m_itemDescriptions = new EasyAsk_Impl_ItemDescriptions(null);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
// Returns an ItemDescriptions instance for the xmlDoc
|
131 |
+
function getItemDescriptions() {
|
132 |
+
$this->processItemDescriptions();
|
133 |
+
return $this->m_itemDescriptions;
|
134 |
+
}
|
135 |
+
|
136 |
+
// Returns to total number of pages needed to hold the results of the INavigateResults.
|
137 |
+
function getPageCount() { return $this->getItemDescriptions()->getPageCount(); }
|
138 |
+
|
139 |
+
// Gets the index of the current page of results that the INavigateResults is displaying.
|
140 |
+
function getCurrentPage() { return $this->getItemDescriptions()->getCurrentPage(); }
|
141 |
+
function getIsDrillDown() { return $this->getItemDescriptions()->getIsDrillDown(); }
|
142 |
+
|
143 |
+
// Gets the total number of items currently contained within the INavigateResults.
|
144 |
+
function getTotalItems() { return $this->getItemDescriptions()->getTotalItems(); }
|
145 |
+
|
146 |
+
// Returns the current number of results per page.
|
147 |
+
function getResultsPerPage() { return $this->getItemDescriptions()->getResultsPerPage(); }
|
148 |
+
|
149 |
+
// Returns the index of the first result item.
|
150 |
+
function getFirstItem() { return $this->getItemDescriptions()->getFirstItem(); }
|
151 |
+
|
152 |
+
// Returns the index of the last result item.
|
153 |
+
function getLastItem() { return $this->getItemDescriptions()->getLastItem(); }
|
154 |
+
|
155 |
+
// Returns the current sort order, if any, for the results
|
156 |
+
function getSortOrder() { return $this->getItemDescriptions()->getSortOrder(); }
|
157 |
+
|
158 |
+
// Returns a list of data descriptions for the xmlDoc
|
159 |
+
function getDataDescriptions() { return $this->getItemDescriptions()->getDataDescriptions(); }
|
160 |
+
function getResultCount() {return $this->getTotalItems();}
|
161 |
+
|
162 |
+
// Creates a list of itemRows based off of the search.
|
163 |
+
function processItems(){
|
164 |
+
if ($this->m_items == null){
|
165 |
+
$this->m_items = array();
|
166 |
+
if (!$this->m_isGrouped){
|
167 |
+
$items = $this->m_doc->source->products->items;
|
168 |
+
if ($items){
|
169 |
+
foreach ($items as $item){
|
170 |
+
$this->m_items[] = new EasyAsk_Impl_ItemRow($this->getDataDescriptions(),$item);
|
171 |
+
}
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
// Retrieves the data stored within an itemrow from the current page.
|
178 |
+
function getCellData($row, $col){
|
179 |
+
$this->processItems();
|
180 |
+
$adjust = ($this->getCurrentPage()-1)*$this->getResultsPerPage();
|
181 |
+
return $this->m_items[$row - $adjust]->getFormattedText($col);
|
182 |
+
}
|
183 |
+
|
184 |
+
// Returns the index of a column contained within the ItemDescriptions
|
185 |
+
function getColumnIndex($colName) {
|
186 |
+
return $this->getItemDescriptions()->getColumnIndex($colName);
|
187 |
+
}
|
188 |
+
|
189 |
+
// Processes the bread crumb trail for the current search.
|
190 |
+
function processBreadCrumbTrail(){
|
191 |
+
$node = $this->m_doc->source->navPath;
|
192 |
+
if ($node){
|
193 |
+
$this->m_bct = new EasyAsk_Impl_BreadCrumbTrail($node);
|
194 |
+
}else{
|
195 |
+
$this->m_bct = new EasyAsk_Impl_BreadCrumbTrail(null);
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
// Returns the bread crumb trail for the current search.
|
200 |
+
function getBreadCrumbTrail() {
|
201 |
+
$this->processBreadCrumbTrail();
|
202 |
+
return $this->m_bct;
|
203 |
+
}
|
204 |
+
|
205 |
+
// Whether the use is currently looking at the top level of the search
|
206 |
+
function getAtTopNode() {
|
207 |
+
return $this->m_doc->source->atTopNode;
|
208 |
+
}
|
209 |
+
|
210 |
+
function getProductsFromGlobalSearch() {
|
211 |
+
return $this->m_doc->source->productsFromGlobalSearch;
|
212 |
+
}
|
213 |
+
|
214 |
+
// Returns true if products could not be found in the current context, but were found by modifying the user query.
|
215 |
+
function getItemsFoundByModifyingQuery() {
|
216 |
+
return $this->m_doc->source->itemsFoundByModifyingQuery;
|
217 |
+
}
|
218 |
+
|
219 |
+
// Returns true if products/items were found through a secondary search.
|
220 |
+
function getItemsFoundWIthSecondarySearch() {
|
221 |
+
return $this->m_doc->source->itemsFoundWithSecondarySearch;
|
222 |
+
}
|
223 |
+
|
224 |
+
// Returns the method in which the product listing was obtained.
|
225 |
+
function getProductRetrievalMethod() {
|
226 |
+
return $this->m_doc->source->productRetrievalMethod;
|
227 |
+
}
|
228 |
+
|
229 |
+
// Returns the method in which the attribute listing was obtained.
|
230 |
+
function getAttributeRetrievalMethod() {
|
231 |
+
return $this->m_doc->source->attributeRetrievalMethod;
|
232 |
+
}
|
233 |
+
|
234 |
+
function getQuestion() {
|
235 |
+
return $this->m_doc->source->question;
|
236 |
+
}
|
237 |
+
|
238 |
+
function getOriginalQuestion() {
|
239 |
+
return isset($this->m_doc->source->originalQuestion)?$this->m_doc->source->originalQuestion:'';
|
240 |
+
}
|
241 |
+
|
242 |
+
function getIsCommand() {
|
243 |
+
return $this->m_doc->source->question->isCommand;
|
244 |
+
}
|
245 |
+
|
246 |
+
// Processes a NavigateHierarchy based off of the xmlDoc
|
247 |
+
function processNavigateHierarchy(){
|
248 |
+
if (!$this->m_bHierarachyProcessed){
|
249 |
+
$hier = $this->m_doc->source->navigateHierarchy->navHierNode;
|
250 |
+
if ($hier){
|
251 |
+
$this->m_navHier = new EasyAsk_Impl_NavigateHierarchy($hier);
|
252 |
+
}
|
253 |
+
$this->m_bHierarachyProcessed = true;
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
// Returns the current NavigateHierarchy for the search.
|
258 |
+
function getNavigateHierarchy() {
|
259 |
+
$this->processNavigateHierarchy();
|
260 |
+
return $this->m_navHier;
|
261 |
+
}
|
262 |
+
|
263 |
+
// Processes the attributes into an AttributeInfo for the current search.
|
264 |
+
function processAttributes(){
|
265 |
+
if ($this->m_attrsInfo == null){
|
266 |
+
$this->m_attrsInfo = isset($this->m_doc->source->attributes)? new EasyAsk_Impl_AttributesInfo($this->m_doc->source->attributes):new EasyAsk_Impl_AttributesInfo(null);
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
// Returns the AttributeInfor for the current search based off of the xmlDoc.
|
271 |
+
function getAttributeInfo($attrNode){
|
272 |
+
$results = array();
|
273 |
+
if ($attrNode){
|
274 |
+
$attrs = $attrNode->attribute;
|
275 |
+
foreach ($attrs as $attr){
|
276 |
+
$results[] = new EasyAsk_Impl_AttributeInfo($attr);
|
277 |
+
}
|
278 |
+
}
|
279 |
+
return $results;
|
280 |
+
}
|
281 |
+
|
282 |
+
// Creates an AttributeInfo for
|
283 |
+
function processCommonAttributes(){
|
284 |
+
if ($this->m_commonAttributes == null){
|
285 |
+
$this->m_commonAttributes = isset($this->m_doc->source->commonAttribute)? new EasyAsk_Impl_AttributesInfo($this->m_doc->source->commonAttribute):new EasyAsk_Impl_AttributesInfo(null);
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
// Returns whether the Initial Display settings is limited against displaying a certain attribute.
|
290 |
+
function isInitialDispLimitedForAttrNames() {
|
291 |
+
$this->processAttributes();
|
292 |
+
return $this->m_attrsInfo->isInitialDispLimitedForAttrNames();
|
293 |
+
}
|
294 |
+
|
295 |
+
// Returns the initial display mode for an attribute's value
|
296 |
+
function getInitialDispLimitForAttrNames() {
|
297 |
+
$this->processAttributes();
|
298 |
+
return $this->m_attrsInfo->getInitialDispLimitForAttrNames();
|
299 |
+
}
|
300 |
+
|
301 |
+
function getInitialDisplayList($attrType) {
|
302 |
+
$this->processAttributes();
|
303 |
+
return $this->m_attrsInfo->getInitialDisplayList($attrType);
|
304 |
+
}
|
305 |
+
|
306 |
+
// Returns a list of attribute names of the specified type.
|
307 |
+
function getAttributeNames($attrFilter, $displayMode){
|
308 |
+
$this->processAttributes();
|
309 |
+
return $this->m_attrsInfo->getAttributeNames($attrFilter, $displayMode);
|
310 |
+
}
|
311 |
+
|
312 |
+
// Returns a vector of NavigateAttribute objects for the specified attribute name for a specified group.
|
313 |
+
// NavigateAttribute objects contain additional information about each attribute value.
|
314 |
+
function isInitialDispLimitedForAttrValues($attrName){
|
315 |
+
$this->processAttributes();
|
316 |
+
return $this->m_attrsInfo->isInitialDispLimitedForAttrValues($attrName);
|
317 |
+
}
|
318 |
+
|
319 |
+
// Returns the initial display mode for an attribute's value
|
320 |
+
function getInitialDispLimitForAttrValues($attrName){
|
321 |
+
$this->processAttributes();
|
322 |
+
return $this->m_attrsInfo->getInitialDispLimitForAttrValues($attrName);
|
323 |
+
}
|
324 |
+
|
325 |
+
// Returns if the attribute is a range filter
|
326 |
+
public function isRangeFilter($attrName){
|
327 |
+
$this->processAttributes();
|
328 |
+
return $this->m_attrsInfo->isRangeFilter($attrName);
|
329 |
+
}
|
330 |
+
|
331 |
+
// Returns a vector of NavigateAttribute objects for the specified attribute name for a specified group.
|
332 |
+
// NavigateAttribute objects contain additional information about each attribute value.
|
333 |
+
function getDetailedAttributeValues($attrName, $displayMode){
|
334 |
+
$this->processAttributes();
|
335 |
+
return $this->m_attrsInfo->getDetailedAttributeValues($attrName, $displayMode);
|
336 |
+
}
|
337 |
+
|
338 |
+
// Returns a list of all attribute names in the current search
|
339 |
+
public function getAttributeNamesFull(){
|
340 |
+
return $this->getAttributeNames(1, 0);
|
341 |
+
}
|
342 |
+
|
343 |
+
// Returns a list of NavigateAttribute objects for the specified attribute name.
|
344 |
+
// NavigateAttribute objects contain additional information about each attribute value.
|
345 |
+
// Returns the full list.
|
346 |
+
function getDetailedAttributeValuesFull($attrName){
|
347 |
+
$this->processAttributes();
|
348 |
+
return $this->m_attrsInfo->getDetailedAttributeValues($attrName, 0);
|
349 |
+
}
|
350 |
+
|
351 |
+
// Returns a corresponding AttributeInfo instance for an attribute
|
352 |
+
function getCommonAttrInfo($attrName){
|
353 |
+
$this->processCommonAttributes();
|
354 |
+
if (isset($this->m_commonAttributes)){
|
355 |
+
return $this->m_commonAttributes->getDetailedAttributeValues($attrName, 0);
|
356 |
+
}
|
357 |
+
return null;
|
358 |
+
}
|
359 |
+
|
360 |
+
private $NODE_ATTRIB_SELECT = "////AttribSelect=";
|
361 |
+
private $splitValSep = ";;;;";
|
362 |
+
|
363 |
+
// Returns whehter an attribute was selected by the user.
|
364 |
+
function wasAttributeSelected($attrName){
|
365 |
+
foreach ($this->getBreadCrumbTrail()->getSearchPath() as $node){
|
366 |
+
if (2 == $node->getType()){
|
367 |
+
$path = $node->getPath();
|
368 |
+
$idx = strpos($path, $this->NODE_ATTRIB_SELECT);
|
369 |
+
if (0 <= $idx){
|
370 |
+
// $vals = path.Substring(idx + NODE_ATTRIB_SELECT.Length).Split(splitValSep, StringSplitOptions.None);
|
371 |
+
$vals = explode($this->splitValSep, substr($path, $idx + sizeof($this->NODE_ATTRIB_SELECT)));
|
372 |
+
for ($i = 0; $i < sizeof($vals); $i++){
|
373 |
+
if (stripos($vals[$i], $attrName . " = '") == 0){
|
374 |
+
return true;
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
}
|
379 |
+
}
|
380 |
+
return false;
|
381 |
+
}
|
382 |
+
|
383 |
+
// Returns a vector of the attribute names that are common to the results and normally not displayed.
|
384 |
+
// The combination of getAttributeNames and getCommonAttributeNames covers all the attributes for the set.
|
385 |
+
function getCommonAttributeNames($onlySelected){
|
386 |
+
$this->processCommonAttributes();
|
387 |
+
$results = array();
|
388 |
+
|
389 |
+
return $this->m_commonAttributes->getAttributeNames(1,0);
|
390 |
+
}
|
391 |
+
|
392 |
+
// Returns a list of NavigateAttribute objects for the specified common attribute name.
|
393 |
+
// NavigateAttribute objects conatin additional information about each attribute value.
|
394 |
+
function getDetailedCommonAttributeValues($attrName, $displayMode){
|
395 |
+
// $attrInfo = $this->getCommonAttrInfo($attrName);
|
396 |
+
// if ($attrInfo){
|
397 |
+
// if (1 == $displayMode && !($attrInfo->getIsLimited())){
|
398 |
+
// $displayMode = 0;
|
399 |
+
// }
|
400 |
+
// return 0 == $displayMode ? $attrInfo->getFullList() : $attrInfo->getInitialList();
|
401 |
+
// }
|
402 |
+
// return array();
|
403 |
+
$this->processCommonAttributes();
|
404 |
+
if (isset($this->m_commonAttributes)){
|
405 |
+
return $this->m_commonAttributes->getDetailedAttributeValues($attrName, 0);
|
406 |
+
}
|
407 |
+
return null;
|
408 |
+
|
409 |
+
}
|
410 |
+
|
411 |
+
// Returns a list of NavigateAttribute objects for the specified common attribute name.
|
412 |
+
// NavigateAttribute objects conatin additional information about each attribute value.
|
413 |
+
function getDetailedCommonAttributeValuesFull($attrName){
|
414 |
+
return $this->getDetailedCommonAttributeValues($attrName, 0);
|
415 |
+
}
|
416 |
+
|
417 |
+
function getCommentary(){
|
418 |
+
if (!$this->m_commentary){
|
419 |
+
$node = isset($this->m_doc->source->commentary)?$this->m_doc->source->commentary:'';
|
420 |
+
$this->m_commentary = $node;
|
421 |
+
}
|
422 |
+
return $this->m_commentary;
|
423 |
+
}
|
424 |
+
|
425 |
+
function splitCommentary($key, $end){
|
426 |
+
$commentary = $this->getCommentary();
|
427 |
+
$result = "";
|
428 |
+
$idx = strpos($commentary, $key);
|
429 |
+
if ($idx !== false){
|
430 |
+
$result = substr($commentary, $idx + sizeof(key));
|
431 |
+
$idx = strpos($result, $end);
|
432 |
+
if ($idx !== false){
|
433 |
+
$result = substr($result, 0, $idx);
|
434 |
+
}
|
435 |
+
}
|
436 |
+
return $result;
|
437 |
+
}
|
438 |
+
|
439 |
+
private $SPELL_CORRECTION_PREFACE = "Corrected Words:";
|
440 |
+
private $COMMENTARY_SECTION_END = ';';
|
441 |
+
|
442 |
+
// Gets suggested spell corrections for the current search terms
|
443 |
+
function getSpellCorrections() {
|
444 |
+
return $this->splitCommentary($this->SPELL_CORRECTION_PREFACE,$this->COMMENTARY_SECTION_END);
|
445 |
+
}
|
446 |
+
|
447 |
+
private $LIST_SEP = ',';
|
448 |
+
private $CORRECTION_SEP = " is ";
|
449 |
+
|
450 |
+
// Gets a list of any words that were corrected in the search
|
451 |
+
function getCorrectedWords(){
|
452 |
+
$spells = explode($this->LIST_SEP, $this->getSpellCorrections());
|
453 |
+
$results = array();
|
454 |
+
for($i = 0; $i < sizeof(spells); $i++){
|
455 |
+
$parts = explode($spells[$i], $this->CORRECTION_SEP);
|
456 |
+
$results[] = trim($parts[0]);
|
457 |
+
}
|
458 |
+
return $results;
|
459 |
+
}
|
460 |
+
|
461 |
+
// Checks for a correction for a search word. Will return null if there are no corrections.
|
462 |
+
function getCorrection($word){
|
463 |
+
$spells = explode($this->getSpellCorrections(),$this->LIST_SEP);
|
464 |
+
for($i = 0; $i < sizeof($spells); $i++){
|
465 |
+
$parts = explode($spells[$i], $this->CORRECTION_SEP);
|
466 |
+
if (0 == strcmp(trim($parts[0]),$word)){
|
467 |
+
return trim($parts[1]);
|
468 |
+
}
|
469 |
+
}
|
470 |
+
return null;
|
471 |
+
}
|
472 |
+
|
473 |
+
private $RELAXATION_PREFACE = "Ignored:";
|
474 |
+
|
475 |
+
function getRelaxedTerms(){
|
476 |
+
$terms = explode($this->splitCommentary($this->RELAXATION_PREFACE,$this->COMMENTARY_SECTION_END), $this->LIST_SEP);
|
477 |
+
$results = array();
|
478 |
+
for($i = 0; $i < sizeof($terms); $i++){
|
479 |
+
$results[] = trim($terms[$i]);
|
480 |
+
}
|
481 |
+
return $results;
|
482 |
+
}
|
483 |
+
|
484 |
+
// Sets the RemoteResult display format to that contained within the xmlDoc
|
485 |
+
function processDisplayFormat(){
|
486 |
+
if (!$this->m_displayFormat){
|
487 |
+
$this->m_displayFormat = $this->getReturnCode() === 0 ? new EasyAsk_Impl_DisplayFormat($this->m_doc->source->displayFormat) : new EasyAsk_Impl_DisplayFormat($this->m_doc->displayFormat);
|
488 |
+
}
|
489 |
+
}
|
490 |
+
|
491 |
+
function isPresentationError() {
|
492 |
+
$this->processDisplayFormat();
|
493 |
+
return !$this->m_displayFormat ? false : $this->m_displayFormat->isPresentationError();
|
494 |
+
}
|
495 |
+
|
496 |
+
function isRedirect() {
|
497 |
+
$this->processDisplayFormat();
|
498 |
+
return !$this->m_displayFormat ? false : $this->m_displayFormat->isRedirect();
|
499 |
+
}
|
500 |
+
|
501 |
+
function getRedirect() {
|
502 |
+
$this->processDisplayFormat();
|
503 |
+
return $this->isRedirect() ? $this->getErrorMsg() : null;
|
504 |
+
}
|
505 |
+
|
506 |
+
private function getFirstChild($node){
|
507 |
+
foreach ($node->children() as $child){
|
508 |
+
if($child){
|
509 |
+
return $child;
|
510 |
+
}
|
511 |
+
}
|
512 |
+
return null;
|
513 |
+
}
|
514 |
+
|
515 |
+
// Figures the layout of the results. How to group them, etc.
|
516 |
+
public function determineLayout(){
|
517 |
+
$this->m_isGrouped = !empty($this->m_doc->source->products->groups);
|
518 |
+
}
|
519 |
+
|
520 |
+
// Is this RemoteResult a GroupedResult
|
521 |
+
public function isGroupedResult(){
|
522 |
+
return $this->m_isGrouped;
|
523 |
+
}
|
524 |
+
|
525 |
+
// Creates a GroupedSetInfo instance for the current instance.
|
526 |
+
public function processGroups(){
|
527 |
+
if ($this->m_groupSet == null && $this->m_isGrouped){
|
528 |
+
$this->m_groupSet = new EasyAsk_Impl_GroupedSetInfo($node, $res);
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
// Returns a GroupedSetInfo for the current search results
|
533 |
+
public function getGroupedResult(){
|
534 |
+
$this->processGroups();
|
535 |
+
return $this->m_groupSet;
|
536 |
+
}
|
537 |
+
|
538 |
+
// Returns an ItemRow from the currently displayed page
|
539 |
+
public function getRow($pageRow){
|
540 |
+
$this->processItems();
|
541 |
+
return $this->m_items[$pageRow];
|
542 |
+
}
|
543 |
+
|
544 |
+
// Returns a list of carveout objects for the current search result
|
545 |
+
public function getCarveOuts(){
|
546 |
+
if ($this->m_carveOuts == null){
|
547 |
+
$this->m_carveOuts = array();
|
548 |
+
foreach ($this->m_doc->source->carveOuts as $carveOut){
|
549 |
+
$this->m_carveOuts[] = new EasyAsk_Impl_CarveOut($this, $carveOut);
|
550 |
+
}
|
551 |
+
}
|
552 |
+
return $this->m_carveOuts;
|
553 |
+
}
|
554 |
+
|
555 |
+
// Returns a ResultsRowGroup that contains the featured products. Null means none.
|
556 |
+
public function getFeaturedProducts(){
|
557 |
+
if ($this->m_featuredProducts == null){
|
558 |
+
$this->m_featuredProducts = new EasyAsk_Impl_FeaturedProducts($this, $this->m_doc->source->featuredProducts);
|
559 |
+
}
|
560 |
+
return $this->m_featuredProducts;
|
561 |
+
}
|
562 |
+
|
563 |
+
// Returns a list of possible arrange by by choices. The result set can be arranged by one of these choices.
|
564 |
+
// The value GroupedResultSet.GROUP_NO_GROUPING is returned as a choice for not grouping.
|
565 |
+
public function getArrangeByChoices(){
|
566 |
+
if($this->m_arrangedByChoices == null){
|
567 |
+
$this->m_arrangedByChoices = array();
|
568 |
+
$cats = $this->getDetailedCategoriesFull();
|
569 |
+
if (sizeof($cats) > 0){
|
570 |
+
$this->m_arrangedByChoices[] = "Category";
|
571 |
+
}
|
572 |
+
$attrNames = $this->getAttributeNamesFull();
|
573 |
+
foreach($attrNames as $name){
|
574 |
+
$vals = $this->getDetailedAttributeValuesFull($name);
|
575 |
+
if (sizeof($vals) > 1){
|
576 |
+
$this->m_arrangedByChoices[] = $name;
|
577 |
+
}else if (sizeof($vals) == 1 && $vals[0]->getProductCount() < $this->getTotalItems()){
|
578 |
+
$this->m_arrangedByChoices[] = $name;
|
579 |
+
}
|
580 |
+
}
|
581 |
+
}
|
582 |
+
return $this->m_arrangedByChoices;
|
583 |
+
}
|
584 |
+
|
585 |
+
// Returns the original question asked.
|
586 |
+
public function getOriginalQuestionAsked(){
|
587 |
+
$originalQuestionAsked = '';
|
588 |
+
$searchPath = $this->getBreadCrumbTrail()->getSearchPath();
|
589 |
+
foreach ($searchPath as $path){
|
590 |
+
if ($path->getType() === 3){
|
591 |
+
$originalQuestionAsked = $path->getValue();
|
592 |
+
}
|
593 |
+
}
|
594 |
+
return $originalQuestionAsked;
|
595 |
+
}
|
596 |
+
|
597 |
+
// Processes the banners into an Banners for the current search.
|
598 |
+
private function processBanners(){
|
599 |
+
if ($this->m_banners == null){
|
600 |
+
$this->m_banners = isset($this->m_doc->source->banners)? new EasyAsk_Impl_Banners($this->m_doc->source->banners) : null;
|
601 |
+
}
|
602 |
+
}
|
603 |
+
|
604 |
+
// Returns if there is a banner associated with this Category/Attribute
|
605 |
+
public function hasBanner($type){
|
606 |
+
$this->processBanners();
|
607 |
+
return isset($this->m_banners) ? $this->m_banners->hasBanner($type) : false;
|
608 |
+
}
|
609 |
+
|
610 |
+
//Return Banner Information
|
611 |
+
public function getBanner($type){
|
612 |
+
$this->processBanners();
|
613 |
+
return isset($this->m_banners) ? $this->m_banners->getBanner($type) : null;
|
614 |
+
}
|
615 |
+
}
|
616 |
+
?>
|
lib/EasyAsk/constants.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
//INavigateNode types
|
4 |
+
define( 'NODE_TYPE_CATEGORY', 1 );
|
5 |
+
define( 'NODE_TYPE_ATTRIBUTE', 2 );
|
6 |
+
define( 'NODE_TYPE_USER_SEARCH', 3 );
|
7 |
+
|
8 |
+
//INavigateResults parameters
|
9 |
+
define( 'CATEGORY_DISPLAY_MODE_FULL', 0 );
|
10 |
+
define( 'CATEGORY_DISPLAY_MODE_INITIAL', 1 );
|
11 |
+
|
12 |
+
define( 'ATTR_DISPLAY_MODE_FULL', 0 );
|
13 |
+
define( 'ATTR_DISPLAY_MODE_INITIAL', 1 );
|
14 |
+
define( 'ATTR_FILTER_NORMAL', 1 );
|
15 |
+
define( 'ATTR_FILTER_MERCHANDISER', 2 );
|
16 |
+
define( 'ATTR_FILTER_ALL', (1 | 2) );
|
17 |
+
|
18 |
+
// INavigateAttribute node types
|
19 |
+
define( 'ATTR_TYPE_NORMAL', 11 );
|
20 |
+
define( 'ATTR_TYPE_MERCHANDISER', 21 );
|
21 |
+
|
22 |
+
?>
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>EasyAsk_Search</name>
|
4 |
+
<version>1.2.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>proprietary</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>EasyAsk is the leading e-commerce search, navigation & merchandising solution for e-retail, mobile commerce and B2B commerce, driving higher conversion rates and increased online revenue.</summary>
|
10 |
+
<description>EasyAsk is the industry leading e-commerce search solution, providing the most intuitive site search, flexible navigation and easiest to use merchandising capability for your e-commerce site. The EasyAsk solution goes far beyond traditional site search, delivering unprecedented accuracy and precision to deliver the products customers on the first page every time. With EasyAsk, customers find the products they are seeking faster and more easily, driving increased conversion rates and a superior shopping experience.</description>
|
11 |
+
<notes>The EasyAsk Search module (EAS module) is designed to let customers leverage the considerable development investment in their website user interface. All enhancements are made to the layer beneath the UI code. Hence there are minimal changes to the design code.
|
12 |
+

|
13 |
+
The only changes made to the templates was for SAYT (Search As You Type) and multi attribute selection in addition to price slider.</notes>
|
14 |
+
<authors><author><name>Srinivas Kotamreddy</name><user>skotamreddy</user><email>skotamreddy@easyask.com</email></author></authors>
|
15 |
+
<date>2016-03-11</date>
|
16 |
+
<time>16:02:06</time>
|
17 |
+
<contents><target name="magelocal"><dir name="EasyAsk"><dir name="Search"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Testconnection.php" hash="ece2ff8263481c178f92b7d4938985f2"/><file name="vssver.scc" hash="6420b0b534ad44fb3b2e6e13a86bafdf"/></dir></dir></dir><dir name="Catalog"><file name="Breadcrumbs.php" hash="c4748bd0f44397b7eed1cae62b4a45b4"/><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="d681d3d52ec450a735e0d15d55d4a958"/><file name="vssver.scc" hash="79a60214c048b876dbf9329af7e566a4"/></dir><file name="State.php" hash="14cb0b06bb13501c5a18c7508883a46c"/><file name="vssver.scc" hash="5af024857745356bb84675f29d4b5378"/></dir><file name="Layer.php" hash="46d7caa8e6f00e67ba6b8c20127fec70"/><file name="Layer.php.bak" hash="e736ce3c2737aa681b57c07ab59e2ba9"/><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="01f753af5836bf7c820abf9b6aa8cffc"/><file name="vssver.scc" hash="3f4ae4e53fda2833db2bdf51ddda4a1f"/></dir><file name="List.php" hash="1e172a712a0930de934fc8b6ba835cc1"/><file name="vssver.scc" hash="07c1b9aa03a13515c41ce3ccaff33852"/></dir><file name="vssver.scc" hash="dc62a01778e304df61ece7d1e656ecab"/></dir><dir name="CatalogSearch"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="0fc8dc20d6b859772d33a3888145ccd0"/><file name="vssver.scc" hash="724b4e36d676fa4f3fe4b0c223df69fa"/></dir><file name="State.php" hash="2fa0d79eb8aba9dc88bbae600a6848c7"/><file name="vssver.scc" hash="8c41362ecef217f0d7dd901859beecb6"/></dir><file name="Layer.php" hash="423a74a9b49c7bf30fca645f646e944e"/><file name="Result.php" hash="c14e6de67b60c64a64455c28feb247cd"/><file name="vssver.scc" hash="0c7851660b94f839c5c25d65289c9fc3"/></dir><dir name="Html"><file name="Pager.php" hash="24090351c4dce3afc10a8fdad233c803"/><file name="vssver.scc" hash="68c2e0e4c271d070c1775f17368dd73b"/></dir></dir><dir name="Helper"><file name="Category.php" hash="75c68858f719111caac582fa5b45a4ba"/><file name="Data.php" hash="b06bd6514e23d5fab7ac8be0ea5871c0"/><file name="Eae.php" hash="1bdeab29a1b9f6304cfcaa4130ae2087"/><file name="Eae.php.bak" hash="9f352660d888e3d40184b457158154b9"/><file name="vssver.scc" hash="82e3a33338a384744154d51e0af25636"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Engine.php" hash="7135a265a3b616d340efc74e1addb910"/><file name="vssver.scc" hash="a82fe51d523f47a7cd9e41462a2fed5f"/></dir><dir name="Source"><file name="Engine.php" hash="af800496d95a2ecdb694086990bfe13b"/><file name="vssver.scc" hash="89a3fb9b450d552c4b0877dbbc5d1d24"/></dir></dir></dir></dir><dir name="Catalog"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="b26bb62bdcc4afffee12d0581035078c"/><file name="Attribute.php.bak" hash="881f3d8a9760fb430c1dab9277d99e70"/><file name="Category.php" hash="abe79171f040c61564b4cee6ff2f0bb1"/><file name="Item.php" hash="906abeb4a129835428690147a5368fa0"/><file name="vssver.scc" hash="22d0ddf5d03b2d4b30888efee9a47172"/></dir></dir><file name="Layer.php" hash="f79088a34dd9c0fb996a1bed1b072584"/><file name="Layer.php.bak" hash="b5cec159f3420cc2b698459f615b45a2"/><file name="vssver.scc" hash="8ee574d6d5f0d8d7148f855028faced2"/></dir><dir name="CatalogSearch"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="198cc87ce3cf90698822c9fea6d3f8d7"/><file name="vssver.scc" hash="5f11d94622d9fd0fd3a723c6bb006c3c"/></dir></dir><file name="Layer.php" hash="dc9ae4da485c1271f62443d2bc4a622c"/><file name="vssver.scc" hash="12fa4437de4541d95541505d30189970"/></dir><file name="Observer.php" hash="1bdddaa264379e61cb3308840e00e67b"/><dir name="Resource"><dir name="Catalog"><dir name="Product"><file name="Collection.php" hash="9db93f23749c514d1d6bcd67a9526398"/><file name="vssver.scc" hash="5992e4cf83b6a8ca38c8690739b52c5d"/></dir></dir><dir name="CatalogSearch"><dir name="Fulltext"><file name="Collection.php" hash="c231d9df2c293b47e071f1d8518e9863"/><file name="vssver.scc" hash="154c612310ec59e8a70fc440f417a28e"/></dir></dir></dir><file name="vssver.scc" hash="d7dea341bfc7037ef6ea13ffbb5104a2"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Search"><dir name="System"><dir name="Config"><file name="TestconnectionController.php" hash="aabee22e44e14938719d50b49f9629f5"/><file name="vssver.scc" hash="28498affc9557d6903a31471ffba8c76"/></dir></dir></dir></dir><file name="IndexController.php" hash="98147573dd3a6665465d84986aed9972"/><file name="ResultController.php" hash="a4762fbd257052cef35cf46140d3cd7b"/><file name="vssver.scc" hash="ed8df6b4ce64b446c7a13572b4a3e087"/></dir><dir name="etc"><file name="attrib.xml" hash="f57053449b53252092336b897cb3b2ac"/><file name="config.xml" hash="09af2c10e2ff812d335cdb723ffbc905"/><file name="system.xml" hash="b1dec1c31af810fa8c7b82566539b90d"/><file name="vssver.scc" hash="d94076f59acb417cbd9b2c41e9d49321"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EasyAsk_Search.xml" hash="cf1c36de68bc75c27e359bc0c7b8e688"/></dir></target><target name="magelib"><dir name="EasyAsk"><file name="IBreadCrumbTrail.php" hash="e27143647460ccbb1bff64eeb8489f02"/><file name="ICarveOut.php" hash="e4b5b233e3dfebdeb4976953bd63f375"/><file name="IDataDescription.php" hash="4856a4b3af2d07d5d5b329a4cda2f3d2"/><file name="IFeaturedProducts.php" hash="a7844a3ba48e80cfd4c090019864c312"/><file name="IGroupedResult.php" hash="f018f26097e5bdcb5291ef5cc57997de"/><file name="IGroupedResultSet.php" hash="699cac01e5dc0d72b931b686189a66eb"/><file name="INavigateAttribute.php" hash="a815f2fc7c4c7904b63b53ad528d6f65"/><file name="INavigateCategory.php" hash="b999e1a309bf88e4b46f127b911f33c0"/><file name="INavigateHierarchy.php" hash="99a1e0e867627bb7e8d85c0cd47c47bb"/><file name="INavigateNode.php" hash="d3581cbb2e5da5f802c379e8e1fbd1fa"/><file name="INavigateResults.php" hash="8eb22bf834335afad96f8ea5ca6e83a2"/><file name="IOptions.php" hash="4179dfb363e236cb67640892ce9a2b33"/><file name="IRemoteEasyAsk.php" hash="87274c3985a9313a02036500c0b518f9"/><file name="IResultRow.php" hash="a7cf1eced66357e3c433692cbdfdd01c"/><dir name="Impl"><file name="AttributeInfo.php" hash="333b9adc15be90968cc7fc237f5ee442"/><file name="AttributesInfo.php" hash="96684fe75ddca7f718e255983b889153"/><file name="Banner.php" hash="4475545124546e01c1761fedee9a205a"/><file name="Banners.php" hash="a5c0d06209984ec34b6cfc5542bd952f"/><file name="BreadCrumbTrail.php" hash="0c701703ad25a916252cf91841b2c19d"/><file name="CarveOut.php" hash="a54a6b4a4c6517b80be49d04ce22b564"/><file name="CategoriesInfo.php" hash="3e59bc780a946ce0845c62e22f1574ef"/><file name="DataDescription.php" hash="711e83137da395cfc6fd180b493ab09b"/><file name="DisplayFormat.php" hash="37a006719c3fdd11f04446fc143ba10d"/><file name="DomUtilities.php" hash="e5822cdd7be3d15e134fa5ee749a6a2d"/><file name="FeaturedProducts.php" hash="74b068cf14fe105b0e36f18888b8a714"/><file name="GroupInfo.php" hash="11d3f5c74cad50cc07f954cdde3f9397"/><file name="GroupedPageLayout.php" hash="b4871869775773411805ebf8b2f7799f"/><file name="GroupedSetInfo.php" hash="7f6bd162b8a481124e79211d050d170e"/><file name="ItemDescriptions.php" hash="829c980a959a9f9769abc9f1690236a4"/><file name="ItemRow.php" hash="428439dab11a26d3929457d1749a3749"/><file name="NavigateAttribute.php" hash="ef46ba2cdad778a5a94c37876cf94381"/><file name="NavigateCategory.php" hash="a19904ca9a3a3f7dd7aebfaeb65c4d6e"/><file name="NavigateHierarchy.php" hash="eacf5e930ff88a827b846f9d98d02173"/><file name="NavigateNode.php" hash="d4da0c7657fa40d2de198207e27df3b9"/><file name="Options.php" hash="0388cc61034744046ff9a4971129bc5d"/><file name="RemoteEasyAsk.php" hash="b9fdae41e81a7c489d0110b9368049bb"/><file name="RemoteFactory.php" hash="cf3a73c51b031ac3c4337086bd22c169"/><file name="RemoteResults.php" hash="3b73c210eec7dc1fd55450df657fc054"/></dir><file name="constants.php" hash="e90aa82a97ab5d2422c471131efd3d5b"/></dir></target><target name="mageweb"><dir name="js"><dir name="easyask"><dir name="2.0"><file name="ea-autocomplete-2.0.1.css" hash="d29eb10cac85ed10709240518e606d01"/><file name="ea-autocomplete-2.0.1.js" hash="b0ca356673a4f742708cf027fb651efb"/><file name="ea-autocomplete-2.0.1.js_save" hash="4262463354a277dd9e8da26916c233e7"/><dir name="images"><file name="sug-title-gradient.gif" hash="6a47dad4014d144c9a25cf9b38b8f5e7"/><file name="tm-logo.png" hash="130ee5a923d4c6b5eff37e94ccbbdc5c"/></dir></dir><dir name="images"><file name="price_filter.png" hash="b3f6fd39a9647471677488740761d69a"/></dir><file name="sayt20_search.html" hash="fd897571bd21f44ca37e67c239565065"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="easyask"><dir name="search"><file name="js.phtml" hash="bef17903f5821ca3c7d2e76f1b0e6c50"/><dir name="system"><dir name="config"><file name="testconnection.phtml" hash="d3fbc01158f9d492865404671f309f39"/><file name="vssver.scc" hash="631675e8b93fff525006af42cd0c5c4d"/></dir></dir><file name="vssver.scc" hash="97d418dc4e9f16485abb9634a48cc2ce"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="catalog"><dir name="layer"><file name="filter.phtml" hash="b7a1f4d6c2c0132f228fb4a8744fa60d"/><file name="view.phtml" hash="ef39fb39a3e0a505d90a5013e103f57c"/></dir></dir><dir name="catalogsearch"><file name="form.mini.phtml" hash="1500ea61f7a4fa7b76b40e305fa750dd"/><file name="result.phtml" hash="9fec9a8d7c3020603443f9cf878ca93c"/></dir></dir></dir></dir></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.1.0</min><max>5.6.19</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.8.0</min><max>1.9.2</max></package></required></dependencies>
|
20 |
+
</package>
|