diff --git a/website_sale_advanced_search/README.md b/website_sale_advanced_search/README.md new file mode 100644 index 000000000..0cb23d146 --- /dev/null +++ b/website_sale_advanced_search/README.md @@ -0,0 +1,36 @@ +# Ecommerce Advanced Search + +Ecommerce Advanced Search is an odoo e-commerse based addon, which enhance the searching criterias including category selector. + + - E-commerce product search + - Can Select Category + - New drop down with product website categories + - Find all products related to searching content according to category selected + - Display results as drop down + - Selection of results redirects to product description page + +### Depends +Ecommerce Advanced Search addon depends on Odoo website and website_sale +### Tech + +* [jQuery] - Search AutoComplete +* [Python] - Controllers +* [XML] - Odoo website templates + +### Installation +- www.odoo.com/documentation/9.0/setup/install.html +- Install our custom addon, which also installs its depends [website, website_sale] + +### Usage +>Select categories from the search drop down +>First Install our custom addon, then go to website and select Shop menu. +On the product search bar type any key, then it will make searching hints as dropdown box under the bar. +Selecting one of results will redirect to the current product description page. + +License +---- +GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (LGPLv3) +(http://www.gnu.org/licenses/agpl.html) + + + diff --git a/website_sale_advanced_search/__init__.py b/website_sale_advanced_search/__init__.py new file mode 100644 index 000000000..fed31b2c5 --- /dev/null +++ b/website_sale_advanced_search/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Hilar AK() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +import controllers diff --git a/website_sale_advanced_search/__openerp__.py b/website_sale_advanced_search/__openerp__.py new file mode 100644 index 000000000..6e425bb8d --- /dev/null +++ b/website_sale_advanced_search/__openerp__.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Hilar AK() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': "Advanced Search in ECommerce ", + 'version': '9.0.1.0.0', + 'summary': """Odoo e-commerce advanced search.""", + 'description': """ + Odoo e-commerce advanced search. Autocomplete search product with category and display name + """, + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': "http://www.cybrosys.com", + 'category': 'Website', + 'depends': ['base', + 'website', + 'website_sale', + ], + 'data': [ + 'views/assets.xml', + 'views/template.xml' + ], + 'demo': [], + 'images': ['static/description/banner.jpg'], + 'license': 'LGPL-3', + 'installable': True, + 'auto_install': False, +} diff --git a/website_sale_advanced_search/controllers/__init__.py b/website_sale_advanced_search/controllers/__init__.py new file mode 100644 index 000000000..208d5da07 --- /dev/null +++ b/website_sale_advanced_search/controllers/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Hilar AK() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +import main diff --git a/website_sale_advanced_search/controllers/main.py b/website_sale_advanced_search/controllers/main.py new file mode 100644 index 000000000..a57d47dc6 --- /dev/null +++ b/website_sale_advanced_search/controllers/main.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Hilar AK() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +import json +from openerp import http +from openerp.http import request + + +class WebsiteSearch(http.Controller): + @http.route('/shop/search', csrf=False, type="http", methods=['POST', 'GET'], auth="public", website=True) + def search_contents(self, **kw): + """ + Searches products according to the category selected on front, + :param kw: dict contains the category and search key + :return: Dict with params as name, res_id, value + """ + strings = '%' + kw.get('name') + '%' + category = int(kw.get('category')) if not kw.get('category') == 'all' else '' + try: + domain = [('public_categ_ids', 'child_of', [category])] if category else [] + product_as_category = request.env['product.template'].search(domain) + sql = """select id as res_id, name as name, name as value from product_template where name ILIKE %s""" + extra_query = '' + if product_as_category: + extra_query = " and id in %s" + limit = " limit 15" + request.cr.execute(sql+extra_query+limit,\ + (tuple([strings]), tuple(product_as_category and product_as_category.ids))) + name = request.cr.dictfetchall() + except: + name = {'name': 'None', 'value': 'None'} + return json.dumps(name) diff --git a/website_sale_advanced_search/static/description/banner.jpg b/website_sale_advanced_search/static/description/banner.jpg new file mode 100644 index 000000000..bbe7428af Binary files /dev/null and b/website_sale_advanced_search/static/description/banner.jpg differ diff --git a/website_sale_advanced_search/static/description/cybro_logo.png b/website_sale_advanced_search/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/website_sale_advanced_search/static/description/cybro_logo.png differ diff --git a/website_sale_advanced_search/static/description/icon.png b/website_sale_advanced_search/static/description/icon.png new file mode 100644 index 000000000..22d4b3ce0 Binary files /dev/null and b/website_sale_advanced_search/static/description/icon.png differ diff --git a/website_sale_advanced_search/static/description/index.html b/website_sale_advanced_search/static/description/index.html new file mode 100644 index 000000000..90af3ebb1 --- /dev/null +++ b/website_sale_advanced_search/static/description/index.html @@ -0,0 +1,109 @@ + + + + +
+

E-commerce Search Advanced

+
+
+
+
+ +
+
+
+
+
+

E-commerce Advanced Search

+

Gives search results as dropdown while typing on search bar.

+
+

Features:

+
    +
  • E-commerce product search
  • +
  • Can Select Category
  • +
  • New dropdown with product website categories
  • +
  • Find all products related to searching content according to category selected
  • +
  • Display results as dropdown
  • +
  • Selection of results redirects to product description page
  • +
+
+
+
+
+

Need Any Help?

+ + +
+ \ No newline at end of file diff --git a/website_sale_advanced_search/static/images/categories.png b/website_sale_advanced_search/static/images/categories.png new file mode 100644 index 000000000..2a9c7f18d Binary files /dev/null and b/website_sale_advanced_search/static/images/categories.png differ diff --git a/website_sale_advanced_search/static/images/cybro_logo.png b/website_sale_advanced_search/static/images/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/website_sale_advanced_search/static/images/cybro_logo.png differ diff --git a/website_sale_advanced_search/static/images/screen2.png b/website_sale_advanced_search/static/images/screen2.png new file mode 100644 index 000000000..a5510eb59 Binary files /dev/null and b/website_sale_advanced_search/static/images/screen2.png differ diff --git a/website_sale_advanced_search/static/images/screen3.png b/website_sale_advanced_search/static/images/screen3.png new file mode 100644 index 000000000..5f5da6aef Binary files /dev/null and b/website_sale_advanced_search/static/images/screen3.png differ diff --git a/website_sale_advanced_search/static/images/search_occurance.png b/website_sale_advanced_search/static/images/search_occurance.png new file mode 100644 index 000000000..4d2b114f6 Binary files /dev/null and b/website_sale_advanced_search/static/images/search_occurance.png differ diff --git a/website_sale_advanced_search/static/js/product_search.js b/website_sale_advanced_search/static/js/product_search.js new file mode 100644 index 000000000..c50b8c067 --- /dev/null +++ b/website_sale_advanced_search/static/js/product_search.js @@ -0,0 +1,45 @@ +odoo.define('website_sale_advanced_search.product_search', function (require) { +"use strict"; +var ajax = require('web.ajax'); +var core = require('web.core'); +var session = require('web.session'); +var base = require('web_editor.base'); +var _t = core._t; +base.url_translations = '/website/translations'; +var _t = core._t; +$(function() { + $('.search-panel .dropdown-menu').find('a').click(function(e) { + e.preventDefault(); + var param = $(this).attr("href").replace("#",""); + var concept = $(this).text(); + $('.search-panel span#search_concept').text(concept); + $('.input-group #search_param').val(param); + }); + $(".oe_search_box").autocomplete({ + source: function(request, response) { + $.ajax({ + url: "/shop/search", + method: "POST", + dataType: "json", + data: { name: request.term, category: $('.input-group #search_param').val()}, + success: function( data ) { + response( $.map( data, function( item ) { + return { + label: item.name, + value: item.name, + id: item.res_id, + } + })); + }, + error: function (error) { + alert('error: ' + error); + } + }); + }, + select:function(suggestion,term,item){ + window.location.href= "/shop/product/"+term.item.id + }, + minLength: 1 + }); +}); +}); \ No newline at end of file diff --git a/website_sale_advanced_search/views/assets.xml b/website_sale_advanced_search/views/assets.xml new file mode 100644 index 000000000..f3a64b0b7 --- /dev/null +++ b/website_sale_advanced_search/views/assets.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/website_sale_advanced_search/views/template.xml b/website_sale_advanced_search/views/template.xml new file mode 100644 index 000000000..61808d014 --- /dev/null +++ b/website_sale_advanced_search/views/template.xml @@ -0,0 +1,32 @@ + + + + + \ No newline at end of file