Skip to content

Commit c75fd89

Browse files
authored
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Accepted Community Pull Requests: - #34001: Fixed customertoken not generating after configured failure in a row (by @sagar2009kumar) - #34000: Extend locales validation - include (3 chars) language codes as valid. (by @Bashev) - #33124: [ReadMe] updated readMe file for QuoteBundleOptions-ReleaseNotification modules (by @vlmed) - #33922: Add regions for Belarus (by @DmitryFurs) - #33903: [Reproducible Builds] Diff in generated/metadata between the builds (by @ihor-sviziev) - #33682: 33589 fix array values in catalogsearch parameters (by @SilinMykola) - #33874: Added "Today" to dashboard report (by @NetStorm84) - #33449: Inheriting from a class that doesn't exist#33334 (by @monteshot) - #32814: Fix a PHP error being thrown on a Magento error being thrown (by @MJTheOne) - #33067: Add aria-label to page jump (by @bradleybrecher) Fixed GitHub Issues: - #34067: [Issue] Fixed customertoken not generating after configured failure in a row (reported by @m2-assistant[bot]) has been fixed in #34001 by @sagar2009kumar in 2.4-develop branch Related commits: 1. c1290c5 2. c76bbe6 3. 9c079dc 4. e89bd3d 5. d0fa57e - #33996: Filipino (philippines) language translation not working! (reported by @pawan) has been fixed in #34000 by @Bashev in 2.4-develop branch Related commits: 1. 22b5f38 2. 8801961 - #4451: Fix for admin shipment, creditmemo, invoice pdf emulation (reported by @ksz2013) has been fixed in #33124 by @vlmed in 2.4-develop branch Related commits: 1. ff21e6d 2. 52c72cd - #33924: [Issue] Add regions for Belarus (reported by @m2-assistant[bot]) has been fixed in #33922 by @DmitryFurs in 2.4-develop branch Related commits: 1. f0c7eea 2. 9d41780 3. 9233d61 - #23324: [Reproducible Builds] Diff in generated/metadata between the builds (reported by @ihor-sviziev) has been fixed in #33903 by @ihor-sviziev in 2.4-develop branch Related commits: 1. 6cf5ee9 - #33928: [Issue] [Reproducible Builds] Diff in generated/metadata between the builds (reported by @m2-assistant[bot]) has been fixed in #33903 by @ihor-sviziev in 2.4-develop branch Related commits: 1. 6cf5ee9 - #33589: strlen() expects parameter 1 to be string, array given | magento/module-catalog-search (reported by @Morgy93) has been fixed in #33682 by @SilinMykola in 2.4-develop branch Related commits: 1. 58adfbf 2. 0c72905 3. d25aba7 4. e5df80f 5. dd0124b 6. 44ed899 - #34008: [Issue] Added "Today" to dashboard report (reported by @m2-assistant[bot]) has been fixed in #33874 by @NetStorm84 in 2.4-develop branch Related commits: 1. cba2411 2. f68d0d9 - #33334: Inheriting from a class that doesn't exist (reported by @Qikerz) has been fixed in #33449 by @monteshot in 2.4-develop branch Related commits: 1. f649582 2. a1575f7 3. 3a92f3e 4. c717b34 5. 995cb2a 6. b0c2133 7. 1aa93e0 8. 33914c1 9. 0f32c4d 10. 72facef 11. e1b094b 12. 9625436 13. f34f5c8 14. 2ec38bc 15. 0669115 - #32819: [Issue] Fix a PHP error being thrown on a Magento error being thrown (reported by @m2-assistant[bot]) has been fixed in #32814 by @MJTheOne in 2.4-develop branch Related commits: 1. 42ae72e 2. f6aacc1 3. 44836eb 4. ba01f61 - #33075: [Issue] Add aria-label to page jump (reported by @m2-assistant[bot]) has been fixed in #33067 by @bradleybrecher in 2.4-develop branch Related commits: 1. 4400de6 2. 0430a80 3. 345758e 4. d05b564 5. 3cf162b 6. 0b01c57 7. b84bd72
2 parents 86dc050 + a93ef5c commit c75fd89

File tree

29 files changed

+757
-83
lines changed

29 files changed

+757
-83
lines changed

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/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/CatalogSearch/Model/Advanced.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ public function addFilters($values)
210210
$this->addSearchCriteria($attribute, $preparedSearchValue);
211211

212212
if ($attribute->getAttributeCode() == 'price') {
213+
foreach ($value as $key => $element) {
214+
if (is_array($element)) {
215+
$value[$key] = 0;
216+
}
217+
}
218+
213219
$rate = 1;
214220
$store = $this->_storeManager->getStore();
215221
$currency = $store->getCurrentCurrencyCode();
@@ -351,23 +357,30 @@ protected function addSearchCriteria($attribute, $value)
351357
/**
352358
* Add data about search criteria to object state
353359
*
354-
* @todo: Move this code to block
355-
*
356360
* @param EntityAttribute $attribute
357361
* @param mixed $value
362+
*
358363
* @return string|bool
359364
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
360365
* @SuppressWarnings(PHPMD.NPathComplexity)
366+
* @throws LocalizedException
367+
* @todo: Move this code to block
361368
*/
362369
protected function getPreparedSearchCriteria($attribute, $value)
363370
{
364371
$from = null;
365372
$to = null;
366373
if (is_array($value)) {
374+
foreach ($value as $key => $element) {
375+
if (is_array($element)) {
376+
$value[$key] = '';
377+
}
378+
}
367379
if (isset($value['from']) && isset($value['to'])) {
368380
if (!empty($value['from']) || !empty($value['to'])) {
369381
$from = '';
370382
$to = '';
383+
371384
if (isset($value['currency'])) {
372385
/** @var $currencyModel Currency */
373386
$currencyModel = $this->_currencyFactory->create()->load($value['currency']);

app/code/Magento/CatalogSearch/view/frontend/templates/result.phtml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
// @codingStandardsIgnoreFile
67

7-
/** This changes need to valid applying filters and configuration before search process is started. */
8+
use Magento\CatalogSearch\Block\Result;
9+
10+
/** These changes need to valid applying filters and configuration before search process is started. */
11+
12+
/** @var $block Result*/
813
$productList = $block->getProductListHtml();
914
?>
1015
<?php if ($block->getResultCount()) : ?>

0 commit comments

Comments
 (0)