Skip to content

magento/magento2#40104 #40105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

swnsma
Copy link
Contributor

@swnsma swnsma commented Jul 28, 2025

Description (*)

Refactoring.
Add tests to check single-option-price issue.

Fixed Issues (if relevant)

  1. Fixes 'As low as' price label is shown for configurable products with single option #40104

Manual testing scenarios (*)

  1. Create configurable product
  2. Add one simple product as an option (e.g. color blue) and set price 100$
  3. Open PDP/PLP to check the product
  4. "100$" price should be shown
  5. Add second option for configurable product (e.g. color red) and set price 120$
  6. Open PDP/PLP to check the product
  7. "As low as 100$" price should be shown

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Refactoring.
Add tests to check single-option-price issue.
Copy link

m2-assistant bot commented Jul 28, 2025

Hi @swnsma. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@swnsma
Copy link
Contributor Author

swnsma commented Jul 29, 2025

@magento run all tests

@ct-prd-projects-boards-automation ct-prd-projects-boards-automation bot added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Jul 29, 2025
@github-project-automation github-project-automation bot moved this to Pending Review in Pull Requests Dashboard Jul 29, 2025
@@ -196,26 +196,25 @@ public function _resetState(): void
}

/**
* Check whether Configurable Product have more than one children products
* Check whether Configurable options do not have price difference
*
* @param SaleableInterface $product
* @return bool
*/
public function isChildProductsOfEqualPrices(SaleableInterface $product): bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should an early return be added to the beginning of this method to exit if the product is not configurable?

    if ($product->getTypeId() !== 'configurable') {
        return false;
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment!
I've just realized that we don't need any arguments, as an object of this class will already have a product assigned.

Copy link

@victortodoran victortodoran Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should not need a new instance of a class to call a one method with a different product.

  • isChildProductsOfEqualPrices is no longer backwards compatible checks $this->product instead of parameter.
  • proposed alternative reduces flexibility, I should not need a new instance to just check a different product. the change basically makes the code single use.

I propose to revert back to checking the parameter.

EDIT: I just saw that the price is checked against the instance on the class. Please disregard above.

Refactoring.
Simplify original logic.
Fix static tests.
@@ -63,7 +63,7 @@ public function getMaxPriceForConfigurableProduct($productId)
$result = $connection->fetchRow($select);

if ($result && isset($result['max_price'])) {
return $result['max_price'];
return (float)$result['max_price'];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return (float) $result['max_price'];

if ($maxPrice == 0) {

$maxPrice = $this->configurableMaxPriceCalculator
->getMaxPriceForConfigurableProduct((int)$this->product->getId());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

->getMaxPriceForConfigurableProduct((int) $this->product->getId());

Fix code styles.
@swnsma
Copy link
Contributor Author

swnsma commented Jul 30, 2025

@magento run all tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review
Projects
Status: Pending Review
Development

Successfully merging this pull request may close these issues.

'As low as' price label is shown for configurable products with single option
3 participants