diff --git a/dfTools.class.php b/dfTools.class.php index ff6996b..652452c 100644 --- a/dfTools.class.php +++ b/dfTools.class.php @@ -437,8 +437,8 @@ public static function getAvailableProductsForLanguage($id_lang, $id_shop, $limi m.name AS manufacturer, - p.__MPN__ AS mpn, - p.ean13 AS ean13, + pa.__MPN__ AS mpn, + pa.ean13 AS ean13, pl.name, pl.description, diff --git a/doofinder.php b/doofinder.php index 784b431..086aa8e 100644 --- a/doofinder.php +++ b/doofinder.php @@ -56,11 +56,12 @@ class Doofinder extends Module const GS_SHORT_DESCRIPTION = 1; const GS_LONG_DESCRIPTION = 2; - const VERSION = "2.3"; + const VERSION = "2.2.8"; const YES = 1; const NO = 0; var $ps_layered_full_tree = true; + var $searchBanner = false; public function __construct() { @@ -106,6 +107,7 @@ public function install() if (!parent::install() || !$this->registerHook('header') || + !$this->registerHook('displayFooter') || !$this->registerHook('displayMobileTopSiteMap')) return false; @@ -126,6 +128,10 @@ private function configureHookCommon($params) 'productLinks' => $this->_productLinks, 'self' => dirname(__FILE__), )); + $appendTo = Configuration::get('DF_APPEND_BANNER'); + if($appendTo){ + $this->smarty->assign('doofinder_banner_append', $appendTo); + } return true; } @@ -160,16 +166,16 @@ public function hookHeader($params) $this->context->controller->addJS(($this->_path) . 'js/doofinder_facets.js'); } $this->context->controller->addJS(($this->_path) . 'js/js.cookie.js'); - $this->context->controller->addJS(($this->_path) . 'js/doofinder-links.js'); $this->context->controller->addJQueryUI('ui.slider'); $this->context->controller->addJQueryUI('ui.accordion'); $this->context->controller->addJqueryPlugin('multiaccordion'); $this->context->controller->addJQueryUI('ui.sortable'); $this->context->controller->addJqueryPlugin('jscrollpane'); - $this->context->controller->addJQueryPlugin('scrollTo'); } + $this->context->controller->addJS(($this->_path) . 'js/doofinder-links.js'); } + if(version_compare(_PS_VERSION_, '1.7', '<')){ return $this->display(__FILE__, 'views/templates/front/script_16.tpl'); } @@ -329,7 +335,8 @@ protected function _updateConfiguration() $cfgCodeStrValues = array( 'DF_EXTRA_CSS', 'DF_API_KEY', - 'DF_CUSTOMEXPLODEATTR' + 'DF_CUSTOMEXPLODEATTR', + 'DF_APPEND_BANNER' ); foreach ($cfgCodeStrValues as $optname) @@ -486,6 +493,17 @@ protected function _displayForm() $fields[] = $field; $helper->fields_value[$optname] = $this->cfg($optname, self::NO); + // DF_APPEND_BANNER + $optname = 'DF_APPEND_BANNER'; + $fields[] = array( + 'label' => $this->l('"Append after" banner on Overwrite Search Page'), + 'desc' => $this->l('Need to write "jQuery" identifier where to append after the banner. If empty or not valid, not banner will show. Example: "#content-wrapper #main h2"'), + 'type' => 'text', + 'name' => $optname, + 'required' => false, + ); + $helper->fields_value[$optname] = $this->cfg($optname); + // DF_ENABLE_HASH $optname = 'DF_ENABLE_HASH'; $field = $this->getYesNoSelectFor($optname, $this->l('Enable security hash on feed URL')); @@ -936,6 +954,7 @@ function cb($entry){ $result_properties = $result; } } + $this->searchBanner = $dfResults->getBanner(); if($return_facets){ return array('doofinder_results' => $dfResultsArray, 'total' => $dfResults->getProperty('total'),'result' => $result_properties, 'facets' => $dfResults->getFacets(), 'filters'=> $df->getFilters(),'df_query_name' => $dfResults->getProperty('query_name')); @@ -1279,9 +1298,9 @@ function getSQLOnlyProductsWithAttributes(){ __ID_CATEGORY_DEFAULT__, m.name AS manufacturer, - - p.__MPN__ AS mpn, - p.ean13 AS ean13, + + IF(isnull(pa.id_product), p.__MPN__ , GROUP_CONCAT(DISTINCT pa.__MPN__ SEPARATOR '/')) AS mpn, + IF(isnull(pa.id_product), p.ean13 , GROUP_CONCAT(DISTINCT pa.ean13 SEPARATOR '/')) AS ean13, pl.name, pl.description, @@ -1361,5 +1380,22 @@ function slugify($text) return $text; } + + public function hookDisplayFooter($params=false) + { + if(isset($this->context->controller->php_self) && $this->context->controller->php_self == 'search' ){ + $appendTo = Configuration::get('DF_APPEND_BANNER'); + if(!empty($this->searchBanner) && !empty($appendTo)){ + $this->context->smarty->assign(array( + 'doofinder_banner_image' => $this->searchBanner['image'], + 'doofinder_banner_blank' => $this->searchBanner['blank'], + 'doofinder_banner_id' => $this->searchBanner['id'], + 'doofinder_banner_link' => $this->searchBanner['link'], + )); + return $this->display(__FILE__, 'views/templates/hook/footer.tpl'); + } + } + return false; + } } diff --git a/js/doofinder-links.js b/js/doofinder-links.js index 71668d0..7224cb2 100644 --- a/js/doofinder-links.js +++ b/js/doofinder-links.js @@ -22,7 +22,8 @@ $(document).on('ready', function() { }); }); } -}); - - - + if(doofinderAppendAfterBanner.length !== undefined && doofinderAppendAfterBanner.length > 0 && $(doofinderAppendAfterBanner).length !== undefined){ + $(doofinderAppendAfterBanner).after($('.doofinder_dinamic_banner')); + $('.doofinder_dinamic_banner').show(); + } +}); \ No newline at end of file diff --git a/lib/doofinder_api.php b/lib/doofinder_api.php index 85ceafc..51bcd6d 100644 --- a/lib/doofinder_api.php +++ b/lib/doofinder_api.php @@ -595,6 +595,7 @@ class DoofinderResults{ private $results = null; private $facets = null; private $filter = null; + private $banner = null; public $status = null; /** @@ -620,6 +621,11 @@ function __construct($jsonString){ { $this->results = $rawResults['results']; } + + if(isset($rawResults['banner']) && is_array($rawResults['banner'])) + { + $this->banner = $rawResults['banner']; + } // build a friendly filter array $this->filter = array(); @@ -807,6 +813,10 @@ public function getAppliedFilters(){ public function isOk(){ return $this->status == self::SUCCESS; } + + public function getBanner(){ + return $this->banner; + } } diff --git a/views/templates/front/script.tpl b/views/templates/front/script.tpl index c7939e1..0b07afb 100644 --- a/views/templates/front/script.tpl +++ b/views/templates/front/script.tpl @@ -14,6 +14,7 @@ {/if} diff --git a/views/templates/front/script_16.tpl b/views/templates/front/script_16.tpl index c7939e1..0b07afb 100644 --- a/views/templates/front/script_16.tpl +++ b/views/templates/front/script_16.tpl @@ -14,6 +14,7 @@ {/if} diff --git a/views/templates/hook/footer.tpl b/views/templates/hook/footer.tpl new file mode 100644 index 0000000..21d185a --- /dev/null +++ b/views/templates/hook/footer.tpl @@ -0,0 +1,4 @@ +
+