Commit 98e72868 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_advanced_ecommerce: fix price issue and display always variation lower price

parent 6066f6f0
......@@ -16,18 +16,26 @@ else:
default_image = context.getDefaultImageValue()
if default_image is not None:
# if current product has image, consider that it has no variation
return default_image.absolute_url()
#xxxx if current product has image, consider that it has no variation
if len([x for x in context.contentValues(portal_type='Product Individual Variation') if x.getVisibilityState() == "visible" ]) == 0:
return default_image.absolute_url()
def getAvailableVariation(individual_variation_list):
price = None
default = context.REQUEST.get('variation', None)
for individual_variation in individual_variation_list:
return individual_variation
context.REQUEST.set("variation", individual_variation.getRelativeUrl())
tmp = context.Resource_getShopPrice()
if price == None or price > tmp:
price = tmp
min_individual_variation = individual_variation
context.REQUEST.set("variation", default)
return min_individual_variation
#if context.Resource_getInventoryStatus(variation=individual_variation.getRelativeUrl()) in ("STOCK", "AVAILABLE"):
# return individual_variation
return None
individual_variation_list = [x for x in context.contentValues(portal_type='Product Individual Variation') if x.getVisibilityState() == "visible" ]
random.shuffle(individual_variation_list)
individual_variation = getAvailableVariation(individual_variation_list)
if individual_variation:
if image_id:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment