Skip to content
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

Hide SKU field if it's being dynamically generated #217

Closed
andris-sevcenko opened this issue Mar 28, 2018 · 9 comments
Closed

Hide SKU field if it's being dynamically generated #217

andris-sevcenko opened this issue Mar 28, 2018 · 9 comments
Assignees
Labels
💡 enhancement Ideas and suggestions
Milestone

Comments

@andris-sevcenko
Copy link
Contributor

Created by: Lindsey DiLoreto (lindsey@doublesecretagency.com) on 2016/04/27 00:03:34 +0000
Votes at time of UserVoice import: 8


It's awesome that we can dynamically generate an SKU! This is (obviously) reminiscent of dynamically generated titles on Entries.

However, the SKU field still appears, with a red asterisk denoting it as "required". It would be great if it followed the pattern of Entry titles, and the field were simply hidden if it's going to be dynamically generated.

Thanks! :)

@andris-sevcenko
Copy link
Contributor Author

Created by: Anonymous (shawna@imarc.com) on 2017/04/17 18:30:59 +0000


Alternatively, I'd also support making the SKU field non-required when generated values are available so that it can be overwritten for whatever reason, with helper text explaining that entering a value will overwrite the generated SKU value

@andris-sevcenko
Copy link
Contributor Author

Created by: outline4 (s.a@outline4.ch) on 2017/06/21 20:18:37 +0000


  • 100

@andris-sevcenko
Copy link
Contributor Author

Created by: Stephen McIver (spm999@gmail.com) on 2017/12/01 17:36:17 +0000


I thought it was a bug that the SKU field still appears as required when it's supposed to be dynamically generated! Please fix this bug/add this feature (delete as appropriate). (-:

@lukeholder lukeholder added the 💡 enhancement Ideas and suggestions label Mar 28, 2018
@lukeholder lukeholder added this to the 2.2 milestone Oct 10, 2019
@nfourtythree nfourtythree self-assigned this Oct 11, 2019
nfourtythree added a commit that referenced this issue Oct 16, 2019
@nfourtythree
Copy link
Contributor

SKU fields now no longer show for new products or variants if the SKU will be automatically generated.

This code has been pushed and should be included in the 2.2 release.

@spacemanup
Copy link

Thanks a lot. But now my workaround doesn't work anymore. My SKU consists of the product ID and the variant ID. So far I had assigned a temporary SKU first, deleted it in a second step and saved the product again. However, this is no longer possible and I can't create new products anymore.

@nfourtythree
Copy link
Contributor

Hi @spacemanup

In theory, this kind of process will still be possible.

How were you assigning your temporary SKU?

@spacemanup
Copy link

spacemanup commented Nov 6, 2019 via email

@nfourtythree
Copy link
Contributor

You could definitely get this working.

If you use the Elements::EVENT_BEFORE_SAVE_ELEMENT event to check to see if the element is a variant, isNew is true and that the SKU is blank. If these conditions pass you could set the SKU to a random string prefixed with TEMPORARY- for example.

Also listening on that same event you could check if the element is a variant, isNew is false and the SKU starts with TEMPORARY- if it does you could blank the SKU field and then let the auto SKU format do the rest of the work.

Hope that makes sense

@spacemanup
Copy link

That definitively makes sense! Thank you so much for this fast and very helpful answer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 enhancement Ideas and suggestions
Projects
None yet
Development

No branches or pull requests

4 participants