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.

Hi,

I am also having the same issue. Could you please elaborate how to do this changes. I have setup my server with the frappe cloud service.

Hi,

The presented workaround assumes that you can make changes in the code. AFAIK, this is not possible in frappe cloud.

Possible solution: Try to create a custom field in the Item doctype, via Customize Form. The name of this field should be slideshow, type=Link, options: ‘Website Slideshow’. After you create this field, you should set the slideshow for each Item that you want to be showed in the website.

I didn’t try this approach. So, let me know if this works.

Adjusted with adding images at the bottom in the item page. :grinning:

Nice :+1:

I have used this and worked for me. The problem I am still experiencing is that my thumbnails keep crashing. Initially, they work, but after some seconds they disappear. Any idea what this could be?

Hey can you open a bug ticket on GitHub? Will look into this and fix it in the core

Hello @marination

Here is the github ticket: Error when having a slideshow for item with variants in eCommerce · Issue #29713 · frappe/erpnext · GitHub

Hope this help.

Thanks you

Hi @romanqvist

I haven’t experienced this problem.
Could you elaborate on that? Where it happens? In what circumstances?

I could narrow the problem down. Apparently, it is a Browser problem. With Apple Safari I couldnt get it to work. With Chrome and Firefox, it worked without any problems.