cancel
Showing results for 
Search instead for 
Did you mean: 

Save the discount applied in sales_order_item when the price was modified by a catalog price rule.

Save the discount applied in sales_order_item when the price was modified by a catalog price rule.

Full details can found in https://github.com/magento/magento2/issues/19858

  • Initial GitHub Issues #19858 was reopened on Jul 30, 2019 with argumentation:

    I'm reopening this issue for two reasons:

    First this behaviour was working in M1. When a catalog price rule changed the product price in M1 this was reflected in the discount fields of the sales_order_item database table. This way you could always determine if a discount was used when the product was ordered.

    Secondly, either way, a special price or a price different then the original price is a discount, and it shouldn't matter where this discount is applied. It could be applied in the catalog or it could be applied in the cart, you're giving a discount on the price of the product. This should be registered as a discount.

    Please reopen the internal tickets within Magento Jira as well.

  • Based on multiple feedbacks in slack and comments on the issue, it seems still a pain point for the community
  • The issue was re-verified on the latest 2.3-develop branch and Confirmed again

1. Magento 2.3.*.
2. Catalog price rule which is enabled.
3. A visible and enabled product.

Steps to reproduce 

1. Create a product with the sku 'A'.
2. Create a catalog price rule for the product with the sku 'A' with a percentage discount or a fixed discount.
3. Apply and save the catalog price rule.
4. Run the command `bin/magento index:reindex`.
5. Place the product with the sku 'A' in your cart.
6. Complete the checkout process.

Expected result 

1. Product 'A' is shown with the discounted price on the product detail page and in the checkout [frontend].
2. In the backoffice the discounted amount/percentage is shown in the order per order item [backend].
3. In the table `sales_order_item` the `discount_amount` or `discount_percent` value is saved [database].

Actual result 

1. Product 'A' is shown with the discounted price on the product detail page and in the checkout [frontend].
2. In the backoffice the discounted amount/percentage is *NOT* shown in the order at all [backend].
3. In the table `sales_order_item` the `discount_amount` or `discount_percent` value is *NOT* saved [database].

At the moment there is no proper way to ascertain whether an order item actually has a discount or not.
The `applied_rule_ids` does not necessarily mean it is a discount for the product, it could also be free shipping for example.