ERPNext.com Frappe Cloud Documentation Partners Frappe School Public Chat

Error when having a slideshow for item with variants in eCommerce

Hi there.
When accessing a Item’s details in website, the system throws the following error:

Traceback (most recent call last):
  File "apps/frappe/frappe/website/render.py", line 49, in render
    data = render_page_by_language(path)
  File "apps/frappe/frappe/website/render.py", line 178, in render_page_by_language
    return render_page(path)
  File "apps/frappe/frappe/website/render.py", line 194, in render_page
    return build(path)
  File "apps/frappe/frappe/website/render.py", line 201, in build
    return build_page(path)
  File "apps/frappe/frappe/website/render.py", line 216, in build_page
    context = get_context(path)
  File "apps/frappe/frappe/website/context.py", line 28, in get_context
    context = build_context(context)
  File "apps/frappe/frappe/website/context.py", line 97, in build_context
    ret = context.doc.get_context(context)
  File "apps/erpnext/erpnext/e_commerce/doctype/website_item/website_item.py", line 213, in get_context
    self.set_variant_context(context)
  File "apps/erpnext/erpnext/e_commerce/doctype/website_item/website_item.py", line 274, in set_variant_context
    if self.slideshow and context.variant and context.variant.slideshow:
AttributeError: 'Item' object has no attribute 'slideshow'

To reproduce the error, follow:

  1. Make sure the “Hide variants” checkbox in E Commerce Setting is checked
  2. Create a template Item (“has variants” checked)
  3. Create some variants
  4. Create a Website Slideshow
  5. Create Website Items for template and variants items created previously (Item > Actions > Publish in Website)
  6. Enter the template’s Website Item and set the slideshow
  7. Access the template website item in website

Probably this is a bug.

Any guess how to solve this?

Thanks

A workaround is to edit the frappe-bench/apps/erpnext/erpnext/e_commerce/doctype/website_item/website_item.py, line 274:

context.variant.slideshow = self.slideshow
if self.slideshow and context.variant and context.variant.slideshow:
	context.update(get_slideshow(context.variant))

That is, just set the slideshow in context.variant.slideshow, because the get_slideshow function tries to get the slideshow field but the context.variant is a Item doctype and it does not have a slideshow field, so just use the Website Item’s slideshow.

This solve my problem for the moment. But surely it wouldn’t work for all cases.

Hope this help.