Magento 2.4.9 Alert: Async Bulk Product Updates Can Silently Re-Enable Disabled Products
Uncovering a Silent Threat to Magento 2 Product Management
For Magento 2 merchants and developers relying on efficient bulk operations, particularly through the asynchronous REST API, a critical issue has been identified in Magento Open Source 2.4.9. This bug can lead to a seemingly innocuous attribute update silently re-enabling previously disabled products, potentially disrupting inventory management and sales strategies.
The Problem: Unintended Product Activation via Async API
The core of the issue, reported by VitaliyBoyko on GitHub, revolves around the asynchronous bulk product update endpoint. When updating a product attribute—such as its weight—without explicitly including the status field in the API request, disabled products are unexpectedly set to 'Enabled'. This behavior contradicts the expected outcome, where an omitted status should preserve the product's existing availability, consistent with synchronous API updates.
Steps to Reproduce the Issue:
- Start with a simple product in Magento Open Source 2.4.9, explicitly set to Disabled (status code
2). - Submit a weight-only update using the async bulk API, deliberately omitting the
statusfield in the request body.
PUT /rest/all/async/bulk/V1/products/bySku
Content-Type: application/json
[
{
"product": {
"sku": "async-status-repro",
"weight": 2.5
}
}
]
bin/magento queue:consumers:start async.operations.all
weight will be updated, but critically, the status will have changed from Disabled (2) to Enabled (1).The Technical Deep Dive: Why Omission Leads to Activation
The GitHub issue provides a detailed analysis of the regression, tracing it back to a specific commit (34606dc82869a813bb606d7fc9eb01f24f587399) related to an async invoice refund fix. This commit altered how Magento\WebapiAsync\Model\OperationRepository::create() handles serialization:
- Before: The system serialized the raw submitted request data.
- After: It now encodes resolved service parameters via
$this->messageEncoder->encode($topicName, $entityParams).
This change has a cascading effect:
- When product data is encoded, it goes through the product data-interface getters.
- Crucially,
Magento\Catalog\Model\Product::getStatus()returnsStatus::STATUS_ENABLED(1) if its raw status data isnull. Consequently, a missing status in the original request becomesstatus = 1in the serialized message. - Upon decoding, the product explicitly contains a status of
1. Magento\Catalog\Model\ProductRepository::save()is designed to preserve the existing status only when!$product->hasData(Product::STATUS). Since the status is now explicitly injected as1, this preservation logic is bypassed, leading to the product being saved as 'Enabled'.
Mitigation and Impact for Merchants
While a permanent fix is being developed, the immediate workaround for developers and merchants is to:
- Explicitly supply the intended product status in all asynchronous bulk updates. This requires the caller to know and provide the current status, adding an extra layer of complexity.
- Alternatively, revert to using the synchronous product update endpoint for critical status-sensitive updates, sacrificing the performance benefits of bulk asynchronous operations.
This bug highlights a significant risk for e-commerce operations. Unintentionally enabled products can lead to:
- Selling out-of-stock items.
- Displaying products that are still in development or awaiting approval.
- Inaccurate inventory reporting and potential customer dissatisfaction.
The issue underscores the importance of thorough testing, especially when integrating with Magento's powerful but complex API ecosystem. Shopping Mover advises all Magento 2.4.9 users leveraging async bulk product updates to review their integration logic and implement the temporary mitigation until an official patch is released.