diff --git a/website_sale_advanced_search/README.rst b/website_sale_advanced_search/README.rst new file mode 100644 index 000000000..268323d4c --- /dev/null +++ b/website_sale_advanced_search/README.rst @@ -0,0 +1,46 @@ +E-commerce Advanced Search v10 +============================== + +* 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 +======= +[website] addon Odoo +[website_sale] addon Odoo + +Tech +==== +* [jQuery] - Search AutoComplete +* [Python] - Controllers +* [XML] - Odoo website templates + +Installation +============ +- www.odoo.com/documentation/10.0/setup/install.html +- Install our custom addon + + +Bug Tracker +=========== +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Credits +======= +* Cybrosys Techno Solutions + +Author +------ + +Developer: Hilar AK @ cybrosys, hilar@cybrosys.in + +Maintainer +---------- + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com. diff --git a/website_sale_advanced_search/__init__.py b/website_sale_advanced_search/__init__.py new file mode 100644 index 000000000..7f2d145f1 --- /dev/null +++ b/website_sale_advanced_search/__init__.py @@ -0,0 +1,25 @@ +# -*- 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 . +# +############################################################################## + +from . import controllers + diff --git a/website_sale_advanced_search/__manifest__.py b/website_sale_advanced_search/__manifest__.py new file mode 100644 index 000000000..648e8fd34 --- /dev/null +++ b/website_sale_advanced_search/__manifest__.py @@ -0,0 +1,48 @@ +# -*- 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': '10.0.1.0.0', + 'summary': """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': "https://www.cybrosys.com", + 'category': 'eCommerce', + '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..65a8c1201 --- /dev/null +++ b/website_sale_advanced_search/controllers/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . 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..68c358277 --- /dev/null +++ b/website_sale_advanced_search/controllers/main.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +import json +from odoo import http +from odoo.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..dab307078 Binary files /dev/null and b/website_sale_advanced_search/static/description/banner.jpg differ diff --git a/website_sale_advanced_search/static/description/categories.png b/website_sale_advanced_search/static/description/categories.png new file mode 100644 index 000000000..2a9c7f18d Binary files /dev/null and b/website_sale_advanced_search/static/description/categories.png 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..5f83ac317 --- /dev/null +++ b/website_sale_advanced_search/static/description/index.html @@ -0,0 +1,101 @@ +
+

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?

+ + +
diff --git a/website_sale_advanced_search/static/description/screen2.png b/website_sale_advanced_search/static/description/screen2.png new file mode 100644 index 000000000..a5510eb59 Binary files /dev/null and b/website_sale_advanced_search/static/description/screen2.png differ diff --git a/website_sale_advanced_search/static/description/screen3.png b/website_sale_advanced_search/static/description/screen3.png new file mode 100644 index 000000000..5f5da6aef Binary files /dev/null and b/website_sale_advanced_search/static/description/screen3.png differ diff --git a/website_sale_advanced_search/static/description/search_occurance.png b/website_sale_advanced_search/static/description/search_occurance.png new file mode 100644 index 000000000..4d2b114f6 Binary files /dev/null and b/website_sale_advanced_search/static/description/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..05c5a3747 --- /dev/null +++ b/website_sale_advanced_search/views/assets.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/website_sale_advanced_search/views/template.xml b/website_sale_advanced_search/views/template.xml new file mode 100644 index 000000000..a1b7237aa --- /dev/null +++ b/website_sale_advanced_search/views/template.xml @@ -0,0 +1,32 @@ + + + + + + \ No newline at end of file