Skip to content

Commit 6f86cd8

Browse files
authored
Merge branch '2.4-develop' into add-exclude-group-to-cron-run-command
2 parents c6c26d3 + 60637c2 commit 6f86cd8

File tree

155 files changed

+3665
-912
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+3665
-912
lines changed

app/code/Magento/AdminNotification/view/adminhtml/web/template/grid/listing.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
<div class="message-system-short">
1010
<button class="message-system-action-dropdown" toggleCollapsible>
1111
<span>
12-
<translate args="'System Messages'"/>:
13-
<text args="totalRecords"/>
12+
<translate args="'System Messages'"></translate>:
13+
<text args="totalRecords"></text>
1414
</span>
1515
</button>
1616
<div class="message-system-short-wrapper" if="rows[0]" repeat="foreach: [rows[0]], item: '$row'" visible="!$collapsible.opened()">
1717
<fastForEach args="data: getVisible(), as: '$col'" >
18-
<render args="$col.getBody()"/>
18+
<render args="$col.getBody()"></render>
1919
</fastForEach>
2020
</div>
2121
</div>
2222
<div class="message-system-collapsible">
2323
<ul class="message-system-list">
2424
<li repeat="foreach: rows, item: '$row'">
2525
<fastForEach args="data: getVisible(), as: '$col'" >
26-
<render args="$col.getBody()"/>
26+
<render args="$col.getBody()"></render>
2727
</fastForEach>
2828
</li>
2929
</ul>

app/code/Magento/AsynchronousOperations/view/adminhtml/web/template/grid/listing.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
<div class="message-system-short">
1010
<button class="message-system-action-dropdown" toggleCollapsible>
1111
<span>
12-
<translate args="'System Messages'"/>:
13-
<text args="totalRecords"/>
12+
<translate args="'System Messages'"></translate>:
13+
<text args="totalRecords"></text>
1414
</span>
1515
</button>
1616
<div class="message-system-short-wrapper" if="rows[0]" repeat="foreach: [rows[0]], item: '$row'" visible="!$collapsible.opened()">
1717
<fastForEach args="data: getVisible(), as: '$col'" >
18-
<render args="$col.getBody()"/>
18+
<render args="$col.getBody()"></render>
1919
</fastForEach>
2020
</div>
2121
</div>
2222
<div class="message-system-collapsible">
2323
<ul class="message-system-list">
2424
<li repeat="foreach: rows, item: '$row'">
2525
<fastForEach args="data: getVisible(), as: '$col'" >
26-
<render args="$col.getBody()"/>
26+
<render args="$col.getBody()"></render>
2727
</fastForEach>
2828
</li>
2929
</ul>

app/code/Magento/Backend/Model/Dashboard/Chart/Date.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public function getByPeriod(string $period): array
6363

6464
if ($period === Period::PERIOD_24_HOURS) {
6565
$dateEnd->modify('-1 hour');
66+
} elseif ($period === Period::PERIOD_TODAY) {
67+
$dateEnd->modify('now');
6668
} else {
6769
$dateEnd->setTime(23, 59, 59);
6870
$dateStart->setTime(0, 0, 0);

app/code/Magento/Backend/Model/Dashboard/Period.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
class Period
1414
{
15+
public const PERIOD_TODAY = 'today';
1516
public const PERIOD_24_HOURS = '24h';
1617
public const PERIOD_7_DAYS = '7d';
1718
public const PERIOD_1_MONTH = '1m';
@@ -30,6 +31,7 @@ class Period
3031
public function getDatePeriods(): array
3132
{
3233
return [
34+
static::PERIOD_TODAY => __('Today'),
3335
static::PERIOD_24_HOURS => __('Last 24 Hours'),
3436
static::PERIOD_7_DAYS => __('Last 7 Days'),
3537
static::PERIOD_1_MONTH => __('Current Month'),
@@ -46,6 +48,7 @@ public function getDatePeriods(): array
4648
public function getPeriodChartUnits(): array
4749
{
4850
return [
51+
static::PERIOD_TODAY => self::PERIOD_UNIT_HOUR,
4952
static::PERIOD_24_HOURS => self::PERIOD_UNIT_HOUR,
5053
static::PERIOD_7_DAYS => self::PERIOD_UNIT_DAY,
5154
static::PERIOD_1_MONTH => self::PERIOD_UNIT_DAY,

app/code/Magento/Backend/Test/Unit/Model/Dashboard/PeriodTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function testGetDatePeriods()
3737
{
3838
$this->assertEquals(
3939
[
40+
Period::PERIOD_TODAY => (string)__('Today'),
4041
Period::PERIOD_24_HOURS => (string)__('Last 24 Hours'),
4142
Period::PERIOD_7_DAYS => (string)__('Last 7 Days'),
4243
Period::PERIOD_1_MONTH => (string)__('Current Month'),

app/code/Magento/Backend/view/adminhtml/web/template/dynamic-rows/grid.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</div>
1212

1313
<div class="admin__field-complex-elements">
14-
<render args="fallbackResetTpl" if="$data.showFallbackReset && $data.isDifferedFromDefault"/>
14+
<render args="fallbackResetTpl" if="$data.showFallbackReset && $data.isDifferedFromDefault"></render>
1515
<button attr="{disabled: disabled}"
1616
class="action-secondary"
1717
type="button"

app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,20 @@ class ConfiguredPrice extends CatalogPrice\FinalPrice implements ConfiguredPrice
4949
*/
5050
private $configuredPriceSelection;
5151

52+
/**
53+
* @var DiscountCalculator
54+
*/
55+
private $discountCalculator;
56+
5257
/**
5358
* @param Product $saleableItem
5459
* @param float $quantity
5560
* @param BundleCalculatorInterface $calculator
5661
* @param PriceCurrencyInterface $priceCurrency
57-
* @param ItemInterface $item
62+
* @param ItemInterface|null $item
5863
* @param JsonSerializer|null $serializer
5964
* @param ConfiguredPriceSelection|null $configuredPriceSelection
65+
* @param DiscountCalculator|null $discountCalculator
6066
*/
6167
public function __construct(
6268
Product $saleableItem,
@@ -65,18 +71,23 @@ public function __construct(
6571
PriceCurrencyInterface $priceCurrency,
6672
ItemInterface $item = null,
6773
JsonSerializer $serializer = null,
68-
ConfiguredPriceSelection $configuredPriceSelection = null
74+
ConfiguredPriceSelection $configuredPriceSelection = null,
75+
DiscountCalculator $discountCalculator = null
6976
) {
7077
$this->item = $item;
7178
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
7279
->get(JsonSerializer::class);
7380
$this->configuredPriceSelection = $configuredPriceSelection
7481
?: \Magento\Framework\App\ObjectManager::getInstance()
7582
->get(ConfiguredPriceSelection::class);
83+
$this->discountCalculator = $discountCalculator
84+
?: \Magento\Framework\App\ObjectManager::getInstance()->get(DiscountCalculator::class);
7685
parent::__construct($saleableItem, $quantity, $calculator, $priceCurrency);
7786
}
7887

7988
/**
89+
* Set item to the model
90+
*
8091
* @param ItemInterface $item
8192
* @return $this
8293
*/
@@ -144,12 +155,12 @@ public function getConfiguredAmount($baseValue = 0.)
144155
*/
145156
public function getValue()
146157
{
147-
if ($this->item) {
158+
if ($this->item && $this->item->getProduct()->getId()) {
148159
$configuredOptionsAmount = $this->getConfiguredAmount()->getBaseAmount();
149-
return parent::getValue() +
150-
$this->priceInfo
151-
->getPrice(BundleDiscountPrice::PRICE_CODE)
152-
->calculateDiscount($configuredOptionsAmount);
160+
return parent::getValue() + $this->discountCalculator->calculateDiscount(
161+
$this->item->getProduct(),
162+
$configuredOptionsAmount
163+
);
153164
}
154165
return parent::getValue();
155166
}
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Bundle\Test\Unit\Pricing\Price;
9+
10+
use Magento\Bundle\Pricing\Price\DiscountCalculator;
11+
use Magento\Catalog\Model\Product;
12+
use Magento\Catalog\Model\Product\Configuration\Item\ItemInterface;
13+
use Magento\Bundle\Pricing\Price\ConfiguredPrice;
14+
use Magento\Bundle\Pricing\Adjustment\Calculator;
15+
use Magento\Catalog\Pricing\Price\ConfiguredPriceSelection;
16+
use Magento\Framework\DataObject;
17+
use Magento\Framework\Pricing\Amount\AmountInterface;
18+
use Magento\Framework\Pricing\Price\PriceInterface;
19+
use Magento\Framework\Pricing\PriceCurrencyInterface;
20+
use Magento\Framework\Pricing\PriceInfo\Base;
21+
use Magento\Framework\Serialize\Serializer\Json;
22+
use PHPUnit\Framework\MockObject\MockObject;
23+
use PHPUnit\Framework\TestCase;
24+
25+
/**
26+
* Test for \Magento\Bundle\Pricing\Price\ConfiguredPrice
27+
*/
28+
class ConfiguredPriceTest extends TestCase
29+
{
30+
/**
31+
* @var float
32+
*/
33+
private $basePriceValue = 100.00;
34+
35+
/**
36+
* @var ItemInterface|MockObject
37+
*/
38+
private $itemMock;
39+
40+
/**
41+
* @var Product|MockObject
42+
*/
43+
private $productMock;
44+
45+
/**
46+
* @var Calculator|MockObject
47+
*/
48+
private $calculatorMock;
49+
50+
/**
51+
* @var Base|MockObject
52+
*/
53+
private $priceInfoMock;
54+
55+
/**
56+
* @var ConfiguredPrice
57+
*/
58+
private $model;
59+
60+
/**
61+
* @var PriceCurrencyInterface|MockObject
62+
*/
63+
private $priceCurrencyMock;
64+
65+
/**
66+
* @var Json|MockObject
67+
*/
68+
private $jsonSerializerMock;
69+
70+
/**
71+
* @var ConfiguredPriceSelection|MockObject
72+
*/
73+
private $configuredPriceSelectionMock;
74+
75+
/**
76+
* @var AmountInterface|MockObject
77+
*/
78+
private $amountInterfaceMock;
79+
80+
/**
81+
* @var DiscountCalculator|MockObject
82+
*/
83+
private $discountCalculatorMock;
84+
85+
/**
86+
* Initialize base dependencies
87+
*/
88+
protected function setUp(): void
89+
{
90+
$basePrice = $this->getMockForAbstractClass(PriceInterface::class);
91+
$basePrice->expects($this->any())->method('getValue')->willReturn($this->basePriceValue);
92+
93+
$this->priceInfoMock = $this->createMock(Base::class);
94+
$this->priceInfoMock->expects($this->any())->method('getPrice')->willReturn($basePrice);
95+
$this->productMock = $this->getMockBuilder(Product::class)
96+
->setMethods(['getPriceInfo', 'getOptionById', 'getResource', 'getId'])
97+
->disableOriginalConstructor()
98+
->getMock();
99+
$this->productMock->expects($this->once())->method('getPriceInfo')->willReturn($this->priceInfoMock);
100+
$this->priceCurrencyMock = $this->getMockForAbstractClass(PriceCurrencyInterface::class);
101+
102+
$this->jsonSerializerMock = $this->getMockBuilder(Json::class)
103+
->getMock();
104+
$this->configuredPriceSelectionMock = $this->getMockBuilder(ConfiguredPriceSelection::class)
105+
->setMethods(['getSelectionPriceList'])
106+
->disableOriginalConstructor()
107+
->getMock();
108+
$this->configuredPriceSelectionMock->expects($this->any())->method('getSelectionPriceList')
109+
->willReturn($this->prepareAndReturnSelectionPriceDataStub());
110+
$this->amountInterfaceMock = $this->getMockBuilder(AmountInterface::class)->getMock();
111+
$this->amountInterfaceMock->expects($this->any())->method('getBaseAmount')
112+
->willReturn(100.00);
113+
$this->calculatorMock = $this->getMockBuilder(Calculator::class)
114+
->disableOriginalConstructor()
115+
->getMock();
116+
$this->calculatorMock->expects($this->any())->method('calculateBundleAmount')
117+
->willReturn($this->amountInterfaceMock);
118+
$this->discountCalculatorMock = $this->getMockBuilder(DiscountCalculator::class)
119+
->disableOriginalConstructor()
120+
->getMock();
121+
$this->discountCalculatorMock->expects($this->any())->method('calculateDiscount')
122+
->willReturn(-5.00);
123+
$this->model = new ConfiguredPrice(
124+
$this->productMock,
125+
1,
126+
$this->calculatorMock,
127+
$this->priceCurrencyMock,
128+
null,
129+
$this->jsonSerializerMock,
130+
$this->configuredPriceSelectionMock,
131+
$this->discountCalculatorMock,
132+
);
133+
}
134+
135+
/**
136+
* Test of value getter when item presented
137+
*/
138+
public function testGetValueMethod(): void
139+
{
140+
$this->productMock->expects($this->any())->method('getId')->willReturn(123);
141+
$this->itemMock = $this->getMockBuilder(ItemInterface::class)
142+
->getMock();
143+
$this->itemMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
144+
$this->model->setItem($this->itemMock);
145+
$valueFromMock = $this->model->getValue();
146+
$this->assertEquals(95.00, $valueFromMock);
147+
}
148+
149+
/**
150+
* Test of value getter if no product item
151+
*/
152+
public function testGetValueMethodNoItem(): void
153+
{
154+
$this->productMock = $this->getMockBuilder(Product::class)
155+
->disableOriginalConstructor()
156+
->getMock();
157+
$this->itemMock = $this->getMockBuilder(ItemInterface::class)
158+
->getMock();
159+
$this->itemMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
160+
$this->productMock->expects($this->any())->method('getId')->willReturn(false);
161+
$this->model->setItem($this->itemMock);
162+
$valueFromMock = $this->model->getValue();
163+
$this->assertEquals(100.00, $valueFromMock);
164+
}
165+
166+
/**
167+
* Stub data for calculation amount of bundle
168+
* @return \Magento\Framework\DataObject[]
169+
*/
170+
private function prepareAndReturnSelectionPriceDataStub(): array
171+
{
172+
$first = new DataObject();
173+
$first->setValue(2);
174+
$first->setQuantity(1);
175+
$second = new DataObject();
176+
$second->setValue(3);
177+
$second->setQuantity(1);
178+
return [
179+
$first,
180+
$second
181+
];
182+
}
183+
}

app/code/Magento/Bundle/view/base/web/template/product/final_price.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77
<if args="hasPriceRange($row())">
88
<div class="price-from">
99
<with args="getPriceByCode('minimal_price')">
10-
<render args="getBody()" />
10+
<render args="getBody()" ></render>
1111
</with>
1212
<with args="getPriceByCode('minimal_regular_price')">
13-
<render args="getBody()" />
13+
<render args="getBody()" ></render>
1414
</with>
1515
</div>
1616
<div class="price-to">
1717
<with args="getPriceByCode('max_price')">
18-
<render args="getBody()" />
18+
<render args="getBody()" ></render>
1919
</with>
2020
<with args="getPriceByCode('max_regular_price')">
21-
<render args="getBody()" />
21+
<render args="getBody()" ></render>
2222
</with>
2323
</div>
2424
</if>
2525

2626
<ifnot args="hasPriceRange($row())">
2727
<with args="getPriceByCode('minimal_price')">
28-
<render args="getBody()" />
28+
<render args="getBody()" ></render>
2929
</with>
3030
<with args="getPriceByCode('minimal_regular_price')">
31-
<render args="getBody()" />
31+
<render args="getBody()" ></render>
3232
</with>
3333
</ifnot>

app/code/Magento/Bundle/view/base/web/template/product/price/minimal_price.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
html="getMinimalPriceUnsanitizedHtml($row())"></span>
2020

2121
<each args="data: getAdjustments(), as: '$adj'">
22-
<render args="$adj.getBody()"/>
22+
<render args="$adj.getBody()"></render>
2323
</each>
2424
</span>
2525
</if>

0 commit comments

Comments
 (0)