Skip to content

Commit d75cff2

Browse files
Merge pull request #9324 from adobe-commerce-tier-4/Tier4-Kings-PR-10-28-2024
[Support Tier-4-Kings glo23503] 10.28.2024 Regular delivery of bugfixes and improvements
2 parents 15a78a0 + 66c3121 commit d75cff2

File tree

12 files changed

+486
-73
lines changed

12 files changed

+486
-73
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66

77
/**
@@ -392,8 +392,7 @@ protected function _getNodeJson($node, $level = 0)
392392
$item['id'] = $node->getId();
393393
$item['store'] = (int)$this->getStore()->getId();
394394
$item['path'] = $node->getData('path');
395-
396-
$item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
395+
$item['a_attr'] = ['class' => $node->getIsActive() ? 'active-category' : 'not-active-category'];
397396
//$item['allowDrop'] = ($level<3) ? true : false;
398397
$allowMove = $this->_isCategoryMoveable($node);
399398
$item['allowDrop'] = $allowMove;

app/code/Magento/Customer/Model/Address/Validator/Customer.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -44,10 +44,7 @@ public function validate(AbstractAddress $address): array
4444
->getCustomerId();
4545

4646
if ($originalAddressCustomerId !== 0 && $originalAddressCustomerId !== $addressCustomerId) {
47-
$errors[] = __(
48-
'Provided customer ID "%customer_id" isn\'t related to current customer address.',
49-
['customer_id' => $addressCustomerId]
50-
);
47+
$errors[] = __('A customer with the same email address already exists in an associated website.');
5148
}
5249
}
5350

app/code/Magento/Customer/Test/Unit/Model/Address/Validator/CustomerTest.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -82,12 +82,7 @@ public function testValidateNewCustomerWithExistingCustomerAddress(): void
8282
$originalAddressMock->expects($this->once())->method('getCustomerId')->willReturn(2);
8383

8484
$this->assertEquals(
85-
[
86-
__(
87-
'Provided customer ID "%customer_id" isn\'t related to current customer address.',
88-
['customer_id' => null]
89-
)
90-
],
85+
[__('A customer with the same email address already exists in an associated website.')],
9186
$this->model->validate($addressMock)
9287
);
9388
}
@@ -160,12 +155,7 @@ public function testValidateExistingCustomerAddressWithNotRelevantCustomer(): vo
160155
$originalAddressMock->expects($this->once())->method('getCustomerId')->willReturn(1);
161156

162157
$this->assertEquals(
163-
[
164-
__(
165-
'Provided customer ID "%customer_id" isn\'t related to current customer address.',
166-
['customer_id' => 2]
167-
)
168-
],
158+
[__('A customer with the same email address already exists in an associated website.')],
169159
$this->model->validate($addressMock)
170160
);
171161
}

app/code/Magento/Quote/Model/ValidationRules/BillingAddressValidationRule.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -46,12 +46,15 @@ public function validate(Quote $quote): array
4646
$billingAddress = $quote->getBillingAddress();
4747
$billingAddress->setStoreId($quote->getStoreId());
4848
$validationResult = $billingAddress->validate();
49-
if ($validationResult !== true) {
50-
$validationErrors = [__($this->generalMessage)];
51-
}
5249
if (is_array($validationResult)) {
5350
$validationErrors = array_merge($validationErrors, $validationResult);
5451
}
52+
if ($quote->getCustomerId() === null && $quote->getCustomerId() !== $quote->getOrigData('customer_id')) {
53+
return [$this->validationResultFactory->create(['errors' => $validationErrors])];
54+
}
55+
if ($validationResult !== true) {
56+
$validationErrors = array_merge([__($this->generalMessage)], $validationErrors);
57+
}
5558

5659
return [$this->validationResultFactory->create(['errors' => $validationErrors])];
5760
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Quote\Test\Fixture;
9+
10+
use Magento\Framework\DataObject;
11+
use Magento\Framework\Exception\NoSuchEntityException;
12+
use Magento\Quote\Api\CartRepositoryInterface;
13+
use Magento\TestFramework\Fixture\DataFixtureInterface;
14+
15+
class ApplyCoupon implements DataFixtureInterface
16+
{
17+
/**
18+
* @var CartRepositoryInterface
19+
*/
20+
public CartRepositoryInterface $quoteRepository;
21+
22+
/**
23+
* @param CartRepositoryInterface $quoteRepository
24+
*/
25+
public function __construct(
26+
CartRepositoryInterface $quoteRepository
27+
) {
28+
$this->quoteRepository = $quoteRepository;
29+
}
30+
31+
/**
32+
* {@inheritdoc}
33+
*
34+
* @param array $data Parameters
35+
* <pre>
36+
* $data = [
37+
* 'cart_id' => (string) Cart ID. Required.
38+
* 'coupon_codes' => (array) Coupon Codes. Required.
39+
* ]
40+
* </pre>
41+
* @throws NoSuchEntityException
42+
*/
43+
public function apply(array $data = []): ?DataObject
44+
{
45+
if (empty($data['cart_id']) || empty($data['coupon_codes'])) {
46+
throw new \InvalidArgumentException('cart_id or coupon_codes is missing!');
47+
}
48+
$quote = $this->quoteRepository->getActive($data['cart_id']);
49+
$quote->setCouponCode(reset($data['coupon_codes']));
50+
$this->quoteRepository->save($quote->collectTotals());
51+
return $quote;
52+
}
53+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Quote\Test\Unit\Model\ValidationRules;
9+
10+
use Magento\Quote\Model\Quote\Address;
11+
use PHPUnit\Framework\MockObject\MockObject;
12+
use Magento\Framework\Validation\ValidationResultFactory;
13+
use Magento\Quote\Model\Quote;
14+
use Magento\Quote\Model\ValidationRules\BillingAddressValidationRule;
15+
use PHPUnit\Framework\TestCase;
16+
17+
class BillingAddressValidationRuleTest extends TestCase
18+
{
19+
/**
20+
* @var BillingAddressValidationRule
21+
*/
22+
private $model;
23+
24+
/**
25+
* @var ValidationResultFactory|MockObject
26+
*/
27+
private $validationResultFactoryMock;
28+
29+
protected function setUp(): void
30+
{
31+
$this->validationResultFactoryMock = $this->getMockBuilder(ValidationResultFactory::class)
32+
->disableOriginalConstructor()
33+
->onlyMethods(['create'])
34+
->getMock();
35+
$this->model = new BillingAddressValidationRule($this->validationResultFactoryMock);
36+
}
37+
38+
public function testValidate()
39+
{
40+
$storeId = 1;
41+
$error = new \Magento\Framework\Phrase(
42+
'A customer with the same email address already exists in an associated website.'
43+
);
44+
$validationResult = [$error];
45+
$validationResultObj = new \Magento\Framework\Validation\ValidationResult($validationResult);
46+
$this->validationResultFactoryMock->expects($this->once())->method('create')->with(
47+
['errors' => $validationResult]
48+
)->willReturn($validationResultObj);
49+
$addressMock = $this->getMockBuilder(Address::class)->disableOriginalConstructor()->getMock();
50+
$addressMock->expects($this->once())->method('validate')->willReturn($validationResult);
51+
$quoteMock = $this->getMockBuilder(Quote::class)
52+
->disableOriginalConstructor()
53+
->getMock();
54+
$quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($addressMock);
55+
$quoteMock->expects($this->once())->method('getStoreId')->willReturn($storeId);
56+
$quoteMock->expects($this->any())->method('__call')->with('getCustomerId')
57+
->willReturn(null);
58+
$quoteMock->expects($this->once())->method('getOrigData')->willReturn(['customer_id' => 2]);
59+
$result = $this->model->validate($quoteMock);
60+
$this->assertIsArray($result);
61+
$this->assertEquals(
62+
'A customer with the same email address already exists in an associated website.',
63+
$result[0]->getErrors()[0]->getText()
64+
);
65+
}
66+
}

app/code/Magento/SalesRule/Model/ResourceModel/Report/Rule/Createdat.php

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,55 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\SalesRule\Model\ResourceModel\Report\Rule;
88

9+
use Magento\Framework\Model\ResourceModel\Db\Context;
10+
use Magento\Framework\Stdlib\DateTime\DateTime;
11+
use Magento\Framework\Stdlib\DateTime\Timezone\Validator;
12+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
13+
use Magento\Reports\Model\FlagFactory;
14+
use Magento\Tax\Model\Config;
15+
use Psr\Log\LoggerInterface;
16+
917
/**
1018
* Rule report resource model with aggregation by created at
11-
*
12-
* @author Magento Core Team <[email protected]>
1319
*/
1420
class Createdat extends \Magento\Reports\Model\ResourceModel\Report\AbstractReport
1521
{
22+
/**
23+
* @param Context $context
24+
* @param LoggerInterface $logger
25+
* @param TimezoneInterface $localeDate
26+
* @param FlagFactory $reportsFlagFactory
27+
* @param Validator $timezoneValidator
28+
* @param DateTime $dateTime
29+
* @param Config $taxConfig
30+
* @param string|null $connectionName
31+
*/
32+
public function __construct(
33+
private readonly Context $context,
34+
private readonly LoggerInterface $logger,
35+
private readonly TimezoneInterface $localeDate,
36+
private readonly FlagFactory $reportsFlagFactory,
37+
private readonly Validator $timezoneValidator,
38+
DateTime $dateTime,
39+
private Config $taxConfig,
40+
string $connectionName = null
41+
) {
42+
parent::__construct(
43+
$context,
44+
$logger,
45+
$localeDate,
46+
$reportsFlagFactory,
47+
$timezoneValidator,
48+
$dateTime,
49+
$connectionName
50+
);
51+
}
52+
1653
/**
1754
* Resource Report Rule constructor
1855
*
@@ -67,6 +104,13 @@ protected function _aggregateByOrder($aggregationField, $from, $to)
67104
$this->getStoreTZOffsetQuery($sourceTable, $aggregationField, $from, $to, null, $salesAdapter)
68105
);
69106

107+
$subtotalAmountFiled = 'base_subtotal';
108+
$subtotalAmountActualFiled = 'base_subtotal_invoiced';
109+
if ($this->taxConfig->displaySalesSubtotalInclTax()) {
110+
$subtotalAmountFiled = 'base_subtotal_incl_tax';
111+
$subtotalAmountActualFiled = 'base_subtotal_incl_tax';
112+
}
113+
70114
$columns = [
71115
'period' => $periodExpr,
72116
'store_id' => 'store_id',
@@ -75,7 +119,7 @@ protected function _aggregateByOrder($aggregationField, $from, $to)
75119
'rule_name' => 'coupon_rule_name',
76120
'coupon_uses' => 'COUNT(entity_id)',
77121
'subtotal_amount' => $connection->getIfNullSql(
78-
'SUM((base_subtotal - ' . $connection->getIfNullSql(
122+
'SUM((' . $subtotalAmountFiled . ' - ' . $connection->getIfNullSql(
79123
'base_subtotal_canceled',
80124
0
81125
) . ') * base_to_global_rate)',
@@ -102,12 +146,17 @@ protected function _aggregateByOrder($aggregationField, $from, $to)
102146
) . ' + ' . $connection->getIfNullSql(
103147
'base_tax_amount - ' . $connection->getIfNullSql('base_tax_canceled', 0),
104148
0
105-
) . ')
149+
) . ' + ' . $connection->getIfNullSql(
150+
'base_discount_tax_compensation_amount - '
151+
. $connection->getIfNullSql('base_discount_tax_compensation_refunded', 0),
152+
0
153+
) . ' - ' . $connection->getIfNullSql('ABS(base_shipping_discount_tax_compensation_amnt)', 0)
154+
. ')
106155
* base_to_global_rate)',
107156
0
108157
),
109158
'subtotal_amount_actual' => $connection->getIfNullSql(
110-
'SUM((base_subtotal_invoiced - ' . $connection->getIfNullSql(
159+
'SUM((' . $subtotalAmountActualFiled . ' - ' . $connection->getIfNullSql(
111160
'base_subtotal_refunded',
112161
0
113162
) . ') * base_to_global_rate)',
@@ -135,7 +184,13 @@ protected function _aggregateByOrder($aggregationField, $from, $to)
135184
) . ' + ' . $connection->getIfNullSql(
136185
'base_tax_invoiced - ' . $connection->getIfNullSql('base_tax_refunded', 0),
137186
0
138-
) . ') * base_to_global_rate)',
187+
) . ' + ' . $connection->getIfNullSql(
188+
'base_discount_tax_compensation_invoiced - '
189+
. $connection->getIfNullSql('base_discount_tax_compensation_refunded', 0),
190+
0
191+
) . ' - ' . $connection->getIfNullSql('ABS(base_shipping_discount_tax_compensation_amnt)', 0)
192+
. ')
193+
* base_to_global_rate)',
139194
0
140195
),
141196
];

app/code/Magento/SalesRule/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"magento/module-checkout": "*",
2929
"magento/module-authorization": "*",
3030
"magento/module-asynchronous-operations": "*",
31-
"magento/module-multishipping": "*"
31+
"magento/module-multishipping": "*",
32+
"magento/module-tax": "*"
3233
},
3334
"suggest": {
3435
"magento/module-sales-rule-sample-data": "*"

app/design/adminhtml/Magento/backend/Magento_Catalog/web/css/source/_module.less

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// /**
2-
// * Copyright © Magento, Inc. All rights reserved.
3-
// * See COPYING.txt for license details.
2+
// * Copyright 2024 Adobe
3+
// * All Rights Reserved.
44
// */
55

6+
@color-grey: #aaa;
7+
68
//
79
// Catalog product grid
810
// ---------------------------------------------
@@ -71,7 +73,7 @@
7173

7274
.catalog-category-edit,
7375
.catalog-category-add {
74-
// TODO: refactor trees
76+
// TODO refactor trees
7577
.x-tree.tree-wrapper {
7678
overflow-x: auto;
7779
}
@@ -121,3 +123,13 @@
121123
}
122124
}
123125
}
126+
127+
//
128+
// Catalog Category Tree
129+
// ---------------------------------------------
130+
131+
.jstree-children {
132+
.not-active-category {
133+
color: @color-grey;
134+
}
135+
}

0 commit comments

Comments
 (0)