Skip to content

Commit 01ab2cd

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop latest changes
Accepted Community Pull Requests: - #25478: Clearer PHPDocs comment for AbstractBlock and Escaper (by @edward-simpson) - #24815: Fix #21684 - Currency sign for "Layered Navigation Price Step" is not according to default settings (by @Bartlomiejsz) - #24471: Resolve Export Coupon Code Grid redirect to DashBoard when create New Cart Price Rule issue24468 (by @edenduong) - #25640: set correct pram like in BlockRepository implementation (by @torhoehn) - #25452: Elastic Search 5 Indexing Performance Issue with product mapper (by @behnamshayani) - #22917: #22856: Catalog price rules are not working with custom options as expected. (by @p-bystritsky) Fixed GitHub Issues: - #21684: Currency sign for "Layered Navigation Price Step" is not according to default settings (reported by @dmak) has been fixed in #24815 by @Bartlomiejsz in 2.4-develop branch Related commits: 1. 2c70512 2. 2a5c87c 3. d351549 4. 9c4c965 - #24468: Export Coupon Code Grid redirect to DashBoard when create New Cart Price Rule (reported by @edenduong) has been fixed in #24471 by @edenduong in 2.4-develop branch Related commits: 1. 5d175a3 2. 853a1e5 - #20966: Elastic Search 5 Indexing Performance Issue (reported by @DarthFly) has been fixed in #25452 by @behnamshayani in 2.4-develop branch Related commits: 1. df50692 2. 1a0cae2 3. d1c848f 4. 0bf7a4c 5. 2b5b986 - #22856: Catalog pricerules are not working with custom options as expected in Magento 2.3.0 product details page (reported by @dcwnaveen) has been fixed in #22917 by @p-bystritsky in 2.4-develop branch Related commits: 1. a8f3b9e 2. 4fb5da8 3. 56142ae 4. 7489207 5. 20ae9e3 6. 8b159d0 7. 4ac980b 8. fbea751
2 parents 87b0a4b + a9222ed commit 01ab2cd

File tree

30 files changed

+1143
-322
lines changed

30 files changed

+1143
-322
lines changed

app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
7-
/**
8-
* Product options abstract type block
9-
*
10-
* @author Magento Core Team <core@magentocommerce.com>
11-
*/
6+
declare(strict_types=1);
127

138
namespace Magento\Catalog\Block\Product\View\Options;
149

10+
use Magento\Catalog\Pricing\Price\BasePrice;
11+
use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
1512
use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface;
13+
use Magento\Framework\App\ObjectManager;
1614

1715
/**
1816
* Product options section abstract block.
@@ -47,20 +45,29 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template
4745
*/
4846
protected $_catalogHelper;
4947

48+
/**
49+
* @var CalculateCustomOptionCatalogRule
50+
*/
51+
private $calculateCustomOptionCatalogRule;
52+
5053
/**
5154
* @param \Magento\Framework\View\Element\Template\Context $context
5255
* @param \Magento\Framework\Pricing\Helper\Data $pricingHelper
5356
* @param \Magento\Catalog\Helper\Data $catalogData
5457
* @param array $data
58+
* @param CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule
5559
*/
5660
public function __construct(
5761
\Magento\Framework\View\Element\Template\Context $context,
5862
\Magento\Framework\Pricing\Helper\Data $pricingHelper,
5963
\Magento\Catalog\Helper\Data $catalogData,
60-
array $data = []
64+
array $data = [],
65+
CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null
6166
) {
6267
$this->pricingHelper = $pricingHelper;
6368
$this->_catalogHelper = $catalogData;
69+
$this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule
70+
?? ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class);
6471
parent::__construct($context, $data);
6572
}
6673

@@ -161,6 +168,15 @@ protected function _formatPrice($value, $flag = true)
161168
$priceStr = $sign;
162169

163170
$customOptionPrice = $this->getProduct()->getPriceInfo()->getPrice('custom_option_price');
171+
172+
if (!$value['is_percent']) {
173+
$value['pricing_value'] = $this->calculateCustomOptionCatalogRule->execute(
174+
$this->getProduct(),
175+
(float)$value['pricing_value'],
176+
(bool)$value['is_percent']
177+
);
178+
}
179+
164180
$context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true];
165181
$optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context);
166182
$priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount(

0 commit comments

Comments
 (0)