Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
erp5
Commits
e6ef8520
Commit
e6ef8520
authored
Nov 14, 2012
by
Rafael Monnerat
Committed by
Xiaowu Zhang
Feb 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize using cache method
parent
4c6d54c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
9 deletions
+21
-9
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/Resource_getWebShopImageURL.xml
...5_commerce_widget_library/Resource_getWebShopImageURL.xml
+20
-8
bt5/erp5_commerce/bt/revision
bt5/erp5_commerce/bt/revision
+1
-1
No files found.
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/Resource_getWebShopImageURL.xml
View file @
e6ef8520
...
@@ -53,7 +53,8 @@
...
@@ -53,7 +53,8 @@
<value>
<string>
"""\n
<value>
<string>
"""\n
Find default image for a given resource. If no image\n
Find default image for a given resource. If no image\n
is defined on the resource itself, look in each individual\n
is defined on the resource itself, look in each individual\n
variation.\n
variation. Take a random variation (to increase site \n
appeal)\n
\n
\n
TODO:\n
TODO:\n
- make the variation support generic (remove hardcoded "variation"\n
- make the variation support generic (remove hardcoded "variation"\n
...
@@ -74,13 +75,24 @@ if default_image is not None:\n
...
@@ -74,13 +75,24 @@ if default_image is not None:\n
return default_image.absolute_url()\n
return default_image.absolute_url()\n
\n
\n
if \'variation\' in context.getVariationBaseCategoryList():\n
if \'variation\' in context.getVariationBaseCategoryList():\n
default_variation = context.getVariationRangeCategoryList(base_category_list=[\'variation\'])\n
\n
if len(default_variation):\n
def getDefaultVariation():\n
default_variation = default_variation[0]\n
import random\n
default_variation = default_variation[len(\'variation/\'):]\n
default_variation = context.getVariationRangeCategoryList(base_category_list=[\'variation\'])\n
default_image = context.getPortalObject().restrictedTraverse(default_variation).getDefaultImageValue()\n
if len(default_variation):\n
if default_image is not None:\n
var_count = len(default_variation)\n
return default_image.absolute_url()\n
default_variation = default_variation[random.randint(0, var_count - 1)]\n
default_variation = default_variation[len(\'variation/\'):]\n
default_image = context.getPortalObject().restrictedTraverse(default_variation).getDefaultImageValue()\n
if default_image is not None:\n
return default_image.absolute_url(), default_variation\n
return None\n
\n
from Products.ERP5Type.Cache import CachingMethod\n
url, default_variation = CachingMethod(getDefaultVariation, id=(\'Resource_getDefaultVariation2\', context.getId()), cache_factory=\'erp5_content_long\')()\n
if default_variation: \n
context.REQUEST.set(\'default_displayed_variation\', default_variation) # Pass the value to other widgets\n
return url\n
\n
\n
return None\n
return None\n
</string>
</value>
</string>
</value>
...
...
bt5/erp5_commerce/bt/revision
View file @
e6ef8520
296
297
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment