MDVA-43232: Sorting products in visual merchandiser by Special Price to Top (or Bottom) causes an error

The MDVA-43232 patch fixes the issue where sorting products in visual merchandiser by Special Price to Top (or Bottom) causes an error while saving category. This patch is available when the Quality Patches Tool (QPT) 1.1.12 is installed. The patch ID is MDVA-43232. Please note that the issue is scheduled to be fixed in Adobe Commerce 2.4.5.

Affected products and versions

The patch is created for Adobe Commerce version:

  • Adobe Commerce (all deployment methods) 2.4.2-p1

Compatible with Adobe Commerce versions:

  • Adobe Commerce (all deployment methods) 2.3.4 - 2.4.3
NOTE
The patch might become applicable to other versions with new Quality Patches Tool releases. To check if the patch is compatible with your Adobe Commerce version, update the magento/quality-patches package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.

Issue

Sorting products in visual merchandiser by Special Price to Top (or Bottom) causes an error while saving category.

Steps to reproduce:

  1. Make sure there are two websites.
  2. Navigate to Stores > Configuration > Catalog > Price and set Catalog Price Scope = Website.
  3. Again, navigate to Stores > Configuration > Catalog > Visual Merchandiser > Visible Attributes for Category Rules > and add Special Price.
  4. Create a simple product and assign the products to both websites.
  5. Add a special price to the default scope of the product.
  6. Switch to the other store’s scope and override both the Price and Special Price of that product.
  7. Do a catalog_product_price reindex.
  8. Go to Catalog > Categories and create a new category.
  9. Add a category rule to filter products that have a special price.
  10. Save the category.
  11. Under the Products in Category section, set Sort Order = Special Price to Top (or Bottom).
  12. Save the category again.

Expected results:

The category is saved without errors.

Actual results:

An exception is thrown:

[2022-02-07T05:58:46.297621+00:00] report.CRITICAL: Exception: Item (Magento\Catalog\Model\Product\Interceptor) with the same ID "1" already exists. in /lib/internal/Magento/Framework/Data/Collection.php:407

Apply the patch

To apply individual patches, use the following links depending on your deployment method:

To learn more about Quality Patches Tool, refer to:

For info about other patches available in QPT, refer to Patches available in QPT in our developer documentation.

recommendation-more-help
8bd06ef0-b3d5-4137-b74e-d7b00485808a