-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
base: 2.4-develop
Are you sure you want to change the base?
magento/magento2#40104 #40105
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your comment! There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
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. |
||
{ | ||
$minPrice = $this->getMinRegularAmount()->getValue(); | ||
$final_price = $product->getFinalPrice(); | ||
$productId = $product->getId(); | ||
if ($final_price < $minPrice) { | ||
$finalPrice = $product->getFinalPrice(); | ||
$productId = (int)$product->getId(); | ||
if ($finalPrice < $minPrice) { | ||
return false; | ||
} | ||
$attributes = $product->getTypeInstance()->getConfigurableAttributes($product); | ||
$items = $attributes->getItems(); | ||
$options = reset($items); | ||
|
||
$maxPrice = $this->configurableMaxPriceCalculator->getMaxPriceForConfigurableProduct($productId); | ||
if ($maxPrice == 0) { | ||
if ($maxPrice === 0.0) { | ||
$maxPrice = $this->getMaxRegularAmount()->getValue(); | ||
} | ||
return (count($options->getOptions()) > 1) && $minPrice == $maxPrice; | ||
|
||
return $minPrice === $maxPrice; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
use Magento\Catalog\Api\CategoryLinkManagementInterface; | ||
use Magento\Catalog\Helper\DefaultCategory; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver; | ||
|
||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/category.php'); | ||
Resolver::getInstance()->requireDataFixture('Magento/ConfigurableProduct/_files/configurable_product_with_one_simple.php'); | ||
|
||
$objectManager = Bootstrap::getObjectManager(); | ||
/** @var CategoryLinkManagementInterface $categoryLinkManagement */ | ||
$categoryLinkManagement = $objectManager->create(CategoryLinkManagementInterface::class); | ||
/** @var DefaultCategory $categoryHelper */ | ||
$categoryHelper = $objectManager->get(DefaultCategory::class); | ||
|
||
foreach (['simple_1', 'configurable'] as $sku) { | ||
$categoryLinkManagement->assignProductToCategories($sku, [$categoryHelper->getId(), 333]); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver; | ||
|
||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/category_rollback.php'); | ||
Resolver::getInstance()->requireDataFixture('Magento/ConfigurableProduct/_files/configurable_product_with_one_simple_with_category.php'); |
There was a problem hiding this comment.
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'];