-
Notifications
You must be signed in to change notification settings - Fork 8
website_sale sorting of products
Michael Karrer edited this page Sep 30, 2015
·
7 revisions
# See webite_sale models product.py line 148 to 178 def set_sequence_top ...
# @http.route()
# def shop(self, page=0, category=None, search='', **post):
# res = super(website_sale_categories, self).shop(page, category, search, **post)
# res.qcontext['products'].sorted(key=lambda r: r.website_sequence)
# return resadd a sequence field to the products and make them dragable in the backend
Find the current visible neighbour and exchange places
CAT A
B(1), C(2), A(3), D(4), E(5)
CAT B
B(1), C(2), D(4), E(5)
Example:
In CAT B we move Product D one Place Up - so in front of Product C:
RESULT: B(1), D(2), C(3), E(5)
FULL RESULT: B(1), D(2), C(3), A(4), E(5)
- Find visible neighbor of Product D = Produkt C(2)
- Find all products with a higher or equal sequence number to C except D = C(2), A(3), E(5)
- Resort all found products beginning with sequence number of C + 1 = 3 = C(3), A(4), E(5) (so we found the highest start number 3 and then we add +1 for every other product found in point 2)
- Set D to the initial sequence number of C = D(2)