Skip to content

Conversation

@ObliviousHarmony
Copy link
Contributor

@ObliviousHarmony ObliviousHarmony commented Jul 29, 2020

All Submissions:

Changes proposed in this Pull Request:

When a variation has no SKU filled out it will default to the parent's in most cases. A caveat here however is that searching does not take this behavior into consideration. This PR adds a join to the product search for the parent's lookup table for variations and checks the SKU of the parent when the child does not have one entered.

I also considered making this change in get_data_for_lookup_table() but it seemed like invalidating the entire table would be problematic and the product_id is already indexed on the lookup table.

Closes #25543.

How to test the changes in this Pull Request:

  1. Create a variable product with two variations.
  2. Set a SKU on the parent of parent-sku and child-sku on ONE of the children.
  3. Create an order and add a product.
  4. Search for parent-sku. Without the PR no variations will be visible, with the PR, the variation that has no SKU will show up.
  5. Search for child-sku and note both with and without the PR the variation with the SKU will show up.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Fix - Searches for variations now will fallback to parent SKU if one is not entered.

Since the parent's SKU is used when the variation does not have one, we should fall back when searching for consistency.
@Konamiman Konamiman added this to the 4.5.0 milestone Aug 6, 2020
Copy link
Contributor

@rrennick rrennick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ObliviousHarmony This looks great except the nitpick in the DB prepare.

Copy link
Contributor

@jonathansadowski jonathansadowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. 👍

I added a note to the comment re: numbered arguments. I agree that it's best to leave the non-numbered arguments for now.

@ObliviousHarmony
Copy link
Contributor Author

Noting that the failing check is the nightly build failures fixed in master

@ObliviousHarmony ObliviousHarmony merged commit 7340c9a into master Aug 12, 2020
@ObliviousHarmony ObliviousHarmony deleted the fix/25543 branch August 12, 2020 19:58
@woocommercebot woocommercebot added release: add changelog Mark all PRs that have not had their changelog entries added. [auto] release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Aug 12, 2020
@juliaamosova juliaamosova added status: testing instructions added and removed release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Aug 18, 2020
rodrigoprimo added a commit that referenced this pull request Dec 2, 2020
This commit replaces double quotes with single quotes inside a MySQL query to avoid a syntax error when the SQL mode ANSI_QUOTES is enabled in MySQL. When this mode is enabled, MySQL treats double quotes as identifiers (like the backtick character) instead of as string delimiters. Before this change, sites running with this mode enabled wouldn't be able to add products to orders created manually in the admin as the modified query would fail (other places that also use product search including variations would fail as well). The commit that introduced this issue shipped in WC 4.5.0 (see #27171).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: add changelog Mark all PRs that have not had their changelog entries added. [auto]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find variations using the parent SKU when creating orders manually

7 participants