Magento 2.4.x Admin UI Bug: Undefined Array Key Error with Advanced Pricing and Multi-Store Setup

Unpacking a Critical Magento 2.4.x Admin UI Bug Affecting Advanced Pricing in Multi-Store Setups

As e-commerce migration experts at Shopping Mover, we constantly monitor the pulse of the Magento community, especially critical bug reports that impact merchant operations. A recent GitHub issue (#40799) has surfaced, detailing a significant bug in Magento 2.4.x that prevents products from being saved under specific multi-store and advanced pricing configurations. This issue, labeled with 'S1' severity, highlights a complex interaction between Magento's Admin UI components and its backend validation logic, leading to an 'Undefined array key' warning.

The Problem: 'Undefined Array Key' When Saving Products

The reported bug occurs in Magento 2.4.7-p9 (and is reproducible across 2.4.x versions) within a multi-store environment utilizing advanced pricing features like tier prices across multiple websites and customer groups. The core issue manifests when an administrator attempts to save a product after unassigning one of its associated websites, particularly after previously configuring tier prices for multiple websites.

Steps to Trigger the Bug:

  1. Set up multiple websites in Magento.
  2. Create a product and assign it to several websites.
  3. Configure 3 tier prices for each website and customer group.
  4. Save the product.
  5. Reopen the product, unassign one website from the 'Product in Websites' section, and save again.
  6. Reload the product edit page.
  7. Attempt to save the product one more time.

Instead of a successful save, the system triggers a validation request to catalog/product/validate/, returning an error response:

{ "error": true, "attribute": "tier_price", "messages": [ "Warning: Undefined array key "" in \/var\/www\/html\/vendor\/magento\/module-catalog\/Model\/Product\/Attribute\/Backend\/GroupPrice\/AbstractGroupPrice.php on line 248" ] }

This results in the product not being saved and an error message displayed in the Admin UI.

Diving into the Technical Root Cause

The issue author provided an excellent analysis, pinpointing the origin of this problem. The error is not due to incorrect backend data but rather an issue with the UI component responsible for handling advanced pricing. Specifically, an undefined website_id value is being passed to the Magento_Catalog/js/components/website-currency-symbol component. This occurs within vendor/magento/module-catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php at line 507.

The lack of an explicit handling for an undefined website_id in vendor/magento/module-catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php leads to the 'Undefined array key' warning during currency validation, ultimately preventing the product from being saved. The issue appears to originate from the Dynamic Rows UI component, which seems to fail in correctly repopulating or passing the website_id data after certain administrative actions.

Immediate Workaround for Merchants and Developers

Given the S1 severity, meaning critical functionality is affected and a workaround is necessary, the community report offers a temporary solution:

  • To successfully save the product, simply open the 'Advanced Pricing' modal within the product edit page and then close it. This action seems to correctly repopulate the necessary website_id data, allowing the product to be saved without the error.

While this workaround provides immediate relief, it's a manual step that can disrupt workflow, especially for stores with frequent product updates or large catalogs. It underscores the importance of a permanent fix from the Magento core team.

Community Impact and Call to Action

This detailed bug report is a testament to the strength of the Magento community in identifying and analyzing complex issues. For merchants operating multi-store Magento 2.4.x environments with advanced pricing, this bug can be a significant hurdle. For developers, the identified root cause provides crucial insights for potential patches or custom workarounds while awaiting an official fix.

At Shopping Mover, we emphasize the importance of stable and bug-free e-commerce platforms. Issues like this highlight the ongoing need for vigilance in platform maintenance and the value of a robust community in identifying and resolving challenges. We encourage users experiencing this issue to monitor the GitHub thread for official updates and permanent solutions.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools