Stock level is not correctly showing on the edit variation form

Created on 19 March 2025, 7 months ago

Our product variation stock level is not correctly showing on the product variation edit form. It displays 0 all the time, while the stock is correctly shown if we show the stock level field in a view.

Correct

Wrong

In `StockLevelWidgetBase.php` the current level is retrieved with `$level = $field->get('available_stock')->getValue();`. I think we can better use the `StockServiceManager` here to get the actual stock level of the variation?

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium dtrdewaele

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @dtrdewaele
  • Merge request !31#3514024: Use StockServiceManager → (Open) created by dtrdewaele
  • Status changed to Closed: works as designed 2 months ago
  • 🇬🇧United Kingdom guy_schneerson

    This should not be needed as the stock filed is a computed field, and the getValue() should ensure the correct value is returned as the computeValue function uses the StockServiceManager to get the value.
    I tested this on the 3.x branch, and it is working as expected.

    If you still think it's an issue, I would need to know why it is not using the computeValue() on your setup. so fill free to reopen if you have more info.

Production build 0.71.5 2024