-
-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Product Import] Product attributes #2562
[Product Import] Product attributes #2562
Conversation
721a3df
to
d554b55
Compare
fdb7c70
to
be0a287
Compare
be0a287
to
ce52c01
Compare
@Matt-Yorkley we said that we wouldn't save any import file until there are errors, as it is pretty confusing to enable saving if some products contain errors, we want to make sure the user is conscious about what she imports... and safe that she is not making mistakes or messing up her catalog. So shouldn't we stick to the same bevahior? And about the small "warning icon" on the item line, I would keep it but as the line would be in error section users will have to fix before being able to save. So it explains them why it is not saving and what they have to fix. Here also it's not clear if the value you see which is going to be imported is the one you want to import or the original one? If it's in error line it is clear that the value displaying the error message is the one you want to import and which is wrong. Do you agree? |
I put it back to in dev so that we can discuss before it is reviewed ;-) |
@myriamboure I thought these would be ok as warnings, as they don't actually make any of the products invalid. The message at the top about product fields only shows when there are changed product fields in the file, so most of the time it will not be there (only when relevant). The information feels like something we should have in the docs as opposed to the first upload page. |
@RachL we need some UX feedback on this ;-) As it is important info I would leave it as a warning in the app as well... but happy to just take it out and leave it only in user guide if you all prefer that. But on the pass/block saving question, @Matt-Yorkley I insist that if there is a risk of confusion in hub manager mind, it's not desired UX. And if I upload a file of 100 products, the system tells me the warning, but I have no clue how many and which products are concerned, so I have to go through the whole list and see where are the warnings to see if there is a problem or not, etc. It's not good UX to me. If you allow import and user doesn't know clearly what she imports, we need to review UX. |
@myriamboure if I understand correctly, the message is shown when the user add those column in the file, right ? So it basically tells him that those columns won't be taken into account. I guess that it could be convenient to not block the import for that, so that the user has not to do another step of changing his file. |
No it's not that @RachL. In a same import, a use can have new products for which those columns will be taken into account AND existing one for which they won't. And he won't know which one are taken into account or not. |
@Matt-Yorkley we just discussed with @RachL and we'll talk quickly about it in our catchup today, but when discussing we agreed with Rachel on UX side that it would be better to :
|
dd36e27
to
013563b
Compare
end | ||
|
||
def attributes_blank?(attribute, existing_product, entry) | ||
existing_product.send(attribute).blank? && entry.send(attribute).blank? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, use public_send
over send
. The latter does not respect private
methods.
return true if entry.errors.messages.values.include? [I18n.t('admin.product_import.model.not_updatable')] | ||
end | ||
false | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using any? would be a bit more readable IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use #any? I could rewrite it like this:
entry.errors.messages.values.any? { |value| value == [I18n.t('admin.product_import.model.not_updatable')] }
but I think that's less clear than just array.include? object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant using any? with @entries
. If I understood correctly, we're checking if any of the entries has an error regardless of the number of errored ones, right?
csv << ["Tomato", "And Another Enterprise", "Vegetables", "6", "5.50", "500", "Kg"] | ||
end | ||
File.write('/tmp/test-m.csv', csv_data) | ||
file = File.new('/tmp/test-m.csv') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maiking use of Rails' tmp/ folder seems more appropriate. If something happens and you spot this file in tmp/ you know it's something related to the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Product import uses the rails tmp folder for it's destination of uploaded files, but this is purely for the specs to create a CSV file first on the disk, and then "upload" or use it during the test. I thought the system /tmp folder would be better, as it will get cleared automatically regardless of what machine the specs are running on.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can buy the autoclearing as an added benefit 👍
end | ||
|
||
def non_updatable_fields | ||
EntryValidator.non_updatable_fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self
can replace EntryValidator
here and then I'm not sure the method is worth it.
next if attributes_match?(attribute, existing_product, entry) || attributes_blank?(attribute, existing_product, entry) | ||
mark_as_invalid(entry, attribute: display_name, error: I18n.t('admin.product_import.model.not_updatable')) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be made simpler by comparing hashes instead of iterating over the fields. You can use slice on product.attributes
and then compare the resulting hash against non_updatable_fields
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some comparisons that need to be checked here that depend on truthyness as opposed to truth. Comparing 1 == 1.0
, for instance. If I use #slice
here the comparison will be strict, and won't give the correct result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also need to compare across the two values to see if they are both #blank
, and I need it to be true if one is nil
and the other is an empty string, which gives me the same problem with using #slice
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
cc24b37
to
19a1bb9
Compare
I have staged this in https://staging.openfoodfrance.org/ |
@luisramos0 I get the snail once I hit the import button even with a very simple file like here: |
@luisramos0 FYI I've used the same file on https://staging1.openfood.com.au and there it works perfectly. |
I'm having a look right now. |
I just restarted the server (unicorn) and it's now working, at least the first step. Can you please try again? Thanks! |
thx @luisramos0 working good :) I'm not sure I've tested this right. To sum up:
Testing notes: |
Ok so we just checked again and talked with @RachL and it seems the feature is working as expected for all fields expect Description. |
@Matt-Yorkley there has been no activity on this since 11 days. It would be good to prioritize finishing product import stuff so that we can release, over starting bulk invoice printing stuff ;-) Thanks! |
d9819dd
to
2e72447
Compare
2e72447
to
fc68e28
Compare
Staged on: https://staging.openfoodnetwork.org.uk |
Yes, now it works :) https://docs.google.com/document/d/1y_A2w0-yDz28Z4-RH6LfUZJ05zr3o4eBkXJRrFBUTIA/edit# @Matt-Yorkley did you install whole production database on UK staging ? Using filter on product list is sometimes very long (or with cache problems maybe....) and there is no loading signal after filtering, so you don't know if the platform is looking for products or just did not find them. IMO We should have a loading signal after filtering as well, and a sentence when no products are found. What do you think ? |
@RachL yes, we have lots of data on UK staging. Maybe it's worth opening an issue to review the user feedback during loading on that page. |
I have the same experience in France, before we had "no product" now we have nothing but the UX is not better... I experience same issue in France as super admin, that would be worth testing with regular user to see if it's also soooo long to charge. |
Ok so let's merge and we'll open a new issue for loading time and UX, let's merggggge ! |
What? Why?
Closes #2458
Adds error messages when updating product-based fields on variants of existing products.
What should we test?
When attempting to update the category, description, unit_type, variant_unit_name, tax_category, or shipping_category fields on an existing product, the user is shown an error message that the field cannot be updated.
Release notes
Added erorrs when user is attempting to update non-updatable fields during product import.
Changelog Category: Changed