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

Issue-39329-Invalid SKU Handling for Linked Products in Magento #39333

Open
wants to merge 2 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

Syamsg
Copy link

@Syamsg Syamsg commented Nov 6, 2024

Description (*)

Invalid SKU Handling for Linked Products in Magento.
In Magento, it’s possible to save a product SKU as "0." However, an issue occurs when this product is added as a linked product (such as Related Products, Up-Sells, or Cross-Sells) to another product. When attempting to make changes to the main product, it triggers an error: "The linked product SKU is invalid. Verify the data and try again."

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Invalid SKU Handling for Linked Products in Magento #39329

Manual testing scenarios (*)

  • Scenario : Save a Product with a Related Product Having SKU '0'

  1. Set up Related Product with SKU '0':

    • First, create or identify a product with SKU set to '0'.
    • Ensure this product is saved successfully in the system (assuming SKU '0' is valid for related products).
  2. Navigate to the Product to be Edited:

    • Go to the Admin panel.
    • Access Catalog > Products and select the product you intend to edit.
  3. Add Related Product:

    • In the Related Products, Up-sells, and Cross-sells section, add the product with SKU '0' as a related product.
  4. Make an Edit to the Main Product:

    • Change any attribute of the main product, such as Name or Price.
    • Do not make changes to the SKU field.
  5. Save the Product:

    • Click Save.
  6. Expected Result:

    • The product should save successfully without any errors.
    • The presence of a related product with SKU '0' should not prevent saving.
    • Verify that the related product with SKU '0' remains correctly linked to the main product.

Questions or comments

If a product with SKU 0 already exists, we should be able to add this product as a related product to other products.

Copy link

m2-assistant bot commented Nov 6, 2024

Hi @Syamsg. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@m2-community-project m2-community-project bot added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Nov 6, 2024
@hostep
Copy link
Contributor

hostep commented Nov 6, 2024

Is it really needed to prevent products with SKU "0" to be created? Also won't this cause issues for people who already have a product with SKU "0" that works fine, but when they want to update some value on it, your new code might prevent them doing so?

Your other changes will solve the linking problem, so I don't think we should prevent SKU "0" from being created? Or are there other cases that go wrong with a product that has an SKU of "0"?

@Syamsg
Copy link
Author

Syamsg commented Nov 6, 2024

I understand your point. Allowing SKU 0 is generally acceptable, as it’s unique, so only one product would have it. However, there could be potential issues since 0 may sometimes be interpreted as empty or false in programming contexts. Blocking 0 could also disrupt users who already use it. Unless we encounter specific issues in integrations, there’s no strong reason to prevent it, especially if other changes address linking concerns. Therefore, we don't necessarily need to prevent SKU 0, and I will add the required changes.

@Syamsg
Copy link
Author

Syamsg commented Nov 7, 2024

Reverted the changes I made to restrict saving a product with SKU '0.'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid SKU Handling for Linked Products in Magento
2 participants