Prestashop: Uploading a texture to an attribute with a color code saved returns 404

Created on 21 Sep 2018  路  15Comments  路  Source: PrestaShop/PrestaShop

Describe the bug
Uploading an image ("texture") to an attribute that have a color code saved will save the image value but remove the image which will return a 404 in the front office. Essentially it has saved the value for the attribute, but since the color code is set it removes the image. If we repeat the process, empty the color code, choose our image and then save, it now works.

To Reproduce

[Part 1] Steps to reproduce the behavior:

  1. Set up an attribute for color
  2. Add a color i.e. #ffffff
  3. Set up some combinations using that attribute
  4. Activate the attribute in the ps_facetedsearch module
  5. Everything is working as expected

[Part 2] Steps to reproduce the behavior:

  1. Edit that attribute and upload an image (keep the color code)
  2. When you save you will not get any errors
  3. Go back to and look at the ps_facetedsearch module
  4. It will still be using the color code #ffffff but it will also be looking for the image since I _it's value_ seems to be stored in the database.
  5. Check the browser console, it will be returning a 404 since it cant find the image. In my case it's looking for .../img/co/8.jpg.

[Part 3] Steps to reproduce the behavior:

  1. Edit that same attribute
  2. Notice that there is no image uploaded
  3. Now empty the color value, select and image, and save.
  4. Now everything works.

Additionnal information
PrestaShop version: 1.7.4.2

1.7.4.2 1.7.5.0 Attributes Bug Fixed Minor

Most helpful comment

@marionf @khouloudbelguith @dennispw

12523

All 15 comments

Hi @dennispw,

Thanks for your report.
In the Part2 first step, I edit the attribute and upload an image (keep the color code) => OK => but this image is not saved.
I attached a video record.
https://drive.google.com/file/d/1mjDw42NDE0WTyr7grgVvWnJJUgxGu7oT/view
Thanks to check & feedback.

Best regards, Khouloud

@khouloudbelguith Precisely. But some value is still saved because in the front office (I used the faceted search as an example) it's trying to get the image but since it doesn't exist you will get a 404. I'm just _guessing here_ but it seems as if the function uploads and renames the image, saves the name - but since the color field isn't empty it deletes the image but not the entry in the database. Unfortunately debunking that specific part is above my head.

Hi @dennispw,

Could you please try to regenerate the file .htaccess

  1. Rename the old file to .htaccess_old
  2. Disable friendly URL
  3. Enable friendly URL

Thanks to check and feedback

Best regards, Khouloud

@khouloudbelguith It makes no difference in my case.

Hi @dennispw,

Could you try to make a small video of this issue please? It would help us to reproduce it.

Best regards, Khouloud

@khouloudbelguith See attached.

#10596.zip

Hi @dennispw,

I attached a screen record.
https://drive.google.com/file/d/1918Hsh4npU7OdThhP3kGGFege4vsmY1S/view
Thanks to check & feedback.

Best regards, Khouloud

@khouloudbelguith It's strange you don't get the 404. However, the real issue is that the texture is removed when entering a color code and/or not even uploaded when there is a color code entered.

It should either:

  1. Upload a texture with an additional setting to choose which to use
  2. Keep the uploaded texture and display a notice that clearly states that the color value has a higher priority than the texture

Hi @dennispw,

So, this is an improvement issue.
When we try to upload a texture and the Color value is not empty. a green alert is displayed "Successful update." but the texture is not uploaded.
@marionf @colinegin what do you think of his suggestion?

Best regards, Khouloud

Hi,

As described by @kpodemski, in this ticket https://github.com/PrestaShop/PrestaShop/issues/12504.
In the PS1.6.1.23, I checked that texture have higher priority
https://drive.google.com/file/d/15-EQW5rmCKkjzIlJbFJJBdEzd8lOTim3/view
But with PS1.7, the color has a higher priority.
@marionf what do you think?
Thanks!

With PrestaShop 1.7.4.2 & 1.7.5.0 , if you have an attribute with a color and you try to change it for a texture, it keeps the color and the uploaded texture isn't applied.

https://drive.google.com/file/d/1I4mURGwGtLKPScUxvpo8q-3juKusv1qK/view?usp=sharing

When you upload a texture, if there is a color, it should be remove

No, color should not be removed, imagine that you want to upload .png file with a background of choice from the color field, this is how it was working in 1.6 and below, in my opinion behavior of this feature should not be changed.

Texture should have higher priortiy on front-office, that's it, but do not delete color value.

@kpodemski

imagine that you want to upload .png file with a background of choice from the color field

I just tried with an 1.6, if I upload a png file the background don't take the color of the field.

https://drive.google.com/open?id=1qXGo0JA-vZ7dJug8H-v1f-FBKEKwlFe5

The color is displayed or the texture but not both

@marionf yes, that's correct, but values in back-office are available, so:

  • allow us to fill out both texture and color
  • use texture if both fields are used
  • do not remove color value from back-office if you upload a texture

@marionf @khouloudbelguith @dennispw

12523

Was this page helpful?
0 / 5 - 0 ratings