Skip to content

fix(catalog): guard empty website_id in tier price validation (#40799)#40830

Open
lbajsarowicz wants to merge 1 commit into
magento:2.4-developfrom
lbajsarowicz:fix/40799-groupprice-undefined-key
Open

fix(catalog): guard empty website_id in tier price validation (#40799)#40830
lbajsarowicz wants to merge 1 commit into
magento:2.4-developfrom
lbajsarowicz:fix/40799-groupprice-undefined-key

Conversation

@lbajsarowicz
Copy link
Copy Markdown
Contributor

Description

When a website is unassigned from a product in admin, the tier_price form
may post rows with an empty website_id. AbstractGroupPrice::validate
then evaluates $rates[$priceRow['website_id']]['code'] which raises
Warning: Undefined array key "" and short-circuits the save —
Product is not saved, the validate endpoint returns error: true.

Skip rows whose website_id is missing or empty (already skipped when
=== 0 / global scope), and skip rows whose website_id has no entry in
the rates map.

Fixes #40799

Fixed Issues

Manual testing scenarios

  1. Set up multi-website store with advanced pricing on a product (tier prices per website/customer group).
  2. Save product with tier prices across two websites.
  3. Unassign one website from the product, save.
  4. Reload product edit page and save again — saves successfully (before: validate endpoint returns the Undefined array key "" warning and product is not saved).

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (43 existing tests pass)
  • Changes to the codebase comply with technical guidelines

When a website is unassigned from a product in admin, the tier_price
form may post rows with an empty website_id. AbstractGroupPrice::validate
then evaluates \$rates[\$priceRow['website_id']]['code'] which raises
"Warning: Undefined array key \"\"" and short-circuits the save
("Product is not saved", validate endpoint returns error: true).

Skip rows whose website_id is missing or empty (already skipped when
=== 0 / global scope), and skip rows whose website_id has no entry in
the rates map.

Fixes magento#40799
@m2-assistant
Copy link
Copy Markdown

m2-assistant Bot commented May 25, 2026

Hi @lbajsarowicz. 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.

@lbajsarowicz
Copy link
Copy Markdown
Contributor Author

@magento run all tests

@lbajsarowicz lbajsarowicz changed the title fix(catalog): guard empty website_id in tier price validation fix(catalog): guard empty website_id in tier price validation (#40799) May 25, 2026
@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label May 26, 2026
@github-project-automation github-project-automation Bot moved this to Pending Review in Pull Requests Dashboard May 26, 2026
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

Status: Pending Review

2 participants