Skip to content

Incorrect min price calculation for products with custom options. #7740

Closed
@PiimegaOy

Description

@PiimegaOy

Preconditions

  1. Magento 2.1
  2. PHP 7.0.8 & MySQL 5.6.31-0ubuntu0.14.04.2

Steps to reproduce

  1. Make product with custom options set as required, where you have both free and non free options available

Expected result

  1. The minimal price in catalog_product_options_type_price should be the base price without the custom option price added. (Since even though the custom option is required there is free option available for customer to choose)

Actual result

  1. The minimal price in catalog_product_options_type_price has the custom option price included.

I got this explanation of the issue from one of our developers:

When saving product with options, Magento saves prices of these options in the table ‘catalog_product_options_type_price’. Code for this operation can be found in \Magento\Catalog\Model\ResourceModel\Product\Option\Value method _saveValuePrices. On the line 98, it check condition “$object->getPrice() $priceType“ and saves price only if it is true. Because for a free options price is zero, it causes that prices for free options are not saved in the table.

When reindexing product prices, prices of custom options are applied in the Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice method _applyCustomOption. At the line 457 it join the table ‘catalog_product_options_type_price’ in order to get minimal values of prices. Because originally this table does not contain zero prices, they are not applied to the minimal price calculation and, thus, not-minimal value of price is used instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions