Skip to content

Commit 3dd14f9

Browse files
authored
Merge branch '2.4-develop' into bug/39692-block-selection-in-widget
2 parents 9dfa3f5 + 27217d0 commit 3dd14f9

File tree

31 files changed

+1116
-144
lines changed

31 files changed

+1116
-144
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,9 @@ public function addMediaGalleryData()
23622362
return $this;
23632363
}
23642364

2365-
if (!$this->getSize()) {
2365+
$size = $this->isLoaded() ? $this->count() : $this->getSize();
2366+
2367+
if (!$size) {
23662368
return $this;
23672369
}
23682370

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php

Lines changed: 2 additions & 3 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 2015 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -311,7 +311,6 @@ public function testAddMediaGalleryData()
311311
$this->metadataPoolMock->expects($this->once())->method('getMetadata')->willReturn($metadataMock);
312312
$metadataMock->expects($this->once())->method('getLinkField')->willReturn($linkField);
313313

314-
$this->connectionMock->expects($this->once())->method('fetchOne')->with($selectMock)->willReturn(42);
315314
$this->connectionMock->expects($this->once())->method('fetchAll')->with($selectMock)->willReturn(
316315
[['row_id' => $rowId]]
317316
);
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Copyright © Magento, Inc. All rights reserved.
3-
* See COPYING.txt for license details.
2+
* Copyright 2019 Adobe
3+
* All Rights Reserved.
44
*/
55

66
var config = {
@@ -10,7 +10,8 @@ var config = {
1010
priceOptionDate: 'Magento_Catalog/js/price-option-date',
1111
priceOptionFile: 'Magento_Catalog/js/price-option-file',
1212
priceOptions: 'Magento_Catalog/js/price-options',
13-
priceUtils: 'Magento_Catalog/js/price-utils'
13+
priceUtils: 'Magento_Catalog/js/price-utils',
14+
catalogAddToCart: 'Magento_Catalog/js/catalog-add-to-cart'
1415
}
1516
}
1617
};

app/code/Magento/Catalog/view/frontend/web/js/validate-product.js renamed to app/code/Magento/Catalog/view/base/web/js/validate-product.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Copyright © Magento, Inc. All rights reserved.
3-
* See COPYING.txt for license details.
2+
* Copyright 2016 Adobe
3+
* All Rights Reserved.
44
*/
55
define([
66
'jquery',

app/code/Magento/Catalog/view/frontend/requirejs-config.js

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

66
var config = {
@@ -10,8 +10,7 @@ var config = {
1010
relatedProducts: 'Magento_Catalog/js/related-products',
1111
upsellProducts: 'Magento_Catalog/js/upsell-products',
1212
productListToolbarForm: 'Magento_Catalog/js/product/list/toolbar',
13-
catalogGallery: 'Magento_Catalog/js/gallery',
14-
catalogAddToCart: 'Magento_Catalog/js/catalog-add-to-cart'
13+
catalogGallery: 'Magento_Catalog/js/gallery'
1514
}
1615
},
1716
config: {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog;
9+
10+
use Magento\Backend\App\AbstractAction;
11+
12+
abstract class MassAction extends AbstractAction
13+
{
14+
/**
15+
* Authorization level of a basic admin session
16+
*
17+
* @see _isAllowed()
18+
*/
19+
public const ADMIN_RESOURCE = 'Magento_CatalogRule::promo_catalog';
20+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog;
9+
10+
use Magento\Backend\App\Action\Context;
11+
use Magento\CatalogRule\Api\CatalogRuleRepositoryInterface;
12+
use Magento\Framework\App\Action\HttpGetActionInterface;
13+
use Magento\Framework\App\Action\HttpPostActionInterface;
14+
use Magento\Framework\Controller\ResultFactory;
15+
16+
class MassActivate extends MassAction implements HttpPostActionInterface, HttpGetActionInterface
17+
{
18+
/**
19+
* @var CatalogRuleRepositoryInterface
20+
*/
21+
private $ruleRepository;
22+
23+
/**
24+
* @param Context $context
25+
* @param CatalogRuleRepositoryInterface $ruleRepository
26+
*/
27+
public function __construct(
28+
Context $context,
29+
CatalogRuleRepositoryInterface $ruleRepository
30+
) {
31+
$this->ruleRepository = $ruleRepository;
32+
parent::__construct($context);
33+
}
34+
35+
/**
36+
* Bulk activate catalog price rule
37+
*
38+
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface
39+
*/
40+
public function execute()
41+
{
42+
$ids = $this->getRequest()->getParam('catalogpricerule');
43+
try {
44+
if ($ids) {
45+
foreach ($ids as $id) {
46+
$model = $this->ruleRepository->get($id);
47+
$model->setIsActive(1);
48+
$this->ruleRepository->save($model);
49+
}
50+
$this->messageManager->addSuccessMessage(__('You activated a total of %1 records.', count($ids)));
51+
} else {
52+
$this->messageManager->addErrorMessage(__('Please select a catalog price rule(s)'));
53+
}
54+
} catch (\Exception $e) {
55+
$this->messageManager->addErrorMessage($e->getMessage());
56+
}
57+
return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('catalog_rule/*/');
58+
}
59+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog;
9+
10+
use Magento\Backend\App\Action\Context;
11+
use Magento\CatalogRule\Api\CatalogRuleRepositoryInterface;
12+
use Magento\Framework\App\Action\HttpGetActionInterface;
13+
use Magento\Framework\App\Action\HttpPostActionInterface;
14+
use Magento\Framework\Controller\ResultFactory;
15+
16+
class MassDeactivate extends MassAction implements HttpPostActionInterface, HttpGetActionInterface
17+
{
18+
/**
19+
* @var CatalogRuleRepositoryInterface
20+
*/
21+
private $ruleRepository;
22+
23+
/**
24+
* @param Context $context
25+
* @param CatalogRuleRepositoryInterface $ruleRepository
26+
*/
27+
public function __construct(
28+
Context $context,
29+
CatalogRuleRepositoryInterface $ruleRepository
30+
) {
31+
$this->ruleRepository = $ruleRepository;
32+
parent::__construct($context);
33+
}
34+
35+
/**
36+
* Bulk activate catalog price rule
37+
*
38+
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface
39+
*/
40+
public function execute()
41+
{
42+
$ids = $this->getRequest()->getParam('catalogpricerule');
43+
try {
44+
if ($ids) {
45+
foreach ($ids as $id) {
46+
$model = $this->ruleRepository->get($id);
47+
$model->setIsActive(0);
48+
$this->ruleRepository->save($model);
49+
}
50+
$this->messageManager->addSuccessMessage(__('You deactivated a total of %1 records.', count($ids)));
51+
} else {
52+
$this->messageManager->addErrorMessage(__('Please select a catalog price rule(s)'));
53+
}
54+
} catch (\Exception $e) {
55+
$this->messageManager->addErrorMessage($e->getMessage());
56+
}
57+
return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('catalog_rule/*/');
58+
}
59+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog;
9+
10+
use Magento\Backend\App\Action\Context;
11+
use Magento\CatalogRule\Api\CatalogRuleRepositoryInterface;
12+
use Magento\Framework\App\Action\HttpGetActionInterface;
13+
use Magento\Framework\App\Action\HttpPostActionInterface;
14+
use Magento\Framework\Controller\ResultFactory;
15+
16+
/**
17+
* Bulk Delete selected catalog price rules
18+
*/
19+
class MassDelete extends MassAction implements HttpPostActionInterface, HttpGetActionInterface
20+
{
21+
/**
22+
* @var CatalogRuleRepositoryInterface
23+
*/
24+
private $ruleRepository;
25+
26+
/**
27+
* @param Context $context
28+
* @param CatalogRuleRepositoryInterface $ruleRepository
29+
*/
30+
public function __construct(
31+
Context $context,
32+
CatalogRuleRepositoryInterface $ruleRepository
33+
) {
34+
$this->ruleRepository = $ruleRepository;
35+
parent::__construct($context);
36+
}
37+
38+
/**
39+
* Delete selected catalog price rules
40+
*
41+
* @return \Magento\Backend\Model\View\Result\Redirect
42+
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
43+
*/
44+
public function execute()
45+
{
46+
$ids = $this->getRequest()->getParam('catalogpricerule');
47+
if ($ids) {
48+
foreach ($ids as $id) {
49+
$this->ruleRepository->deleteById($id);
50+
}
51+
$this->messageManager->addSuccessMessage(__('A total of %1 record(s) were deleted.', count($ids)));
52+
} else {
53+
$this->messageManager->addErrorMessage(__('Please select a catalog price rule(s)'));
54+
}
55+
56+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
57+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
58+
59+
return $resultRedirect->setPath('catalog_rule/*/');
60+
}
61+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogRule\Test\Unit\Controller\Adminhtml\Promo\Catalog;
9+
10+
use Magento\Backend\Model\View\Result\Redirect;
11+
use Magento\Framework\App\RequestInterface;
12+
use Magento\Framework\Controller\ResultFactory;
13+
use Magento\Framework\Message\ManagerInterface;
14+
use PHPUnit\Framework\MockObject\MockObject;
15+
use Magento\Backend\App\Action\Context;
16+
use PHPUnit\Framework\TestCase;
17+
use Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog\MassActivate;
18+
use Magento\CatalogRule\Api\Data\RuleInterface;
19+
use Magento\CatalogRule\Model\Rule;
20+
use Magento\CatalogRule\Api\CatalogRuleRepositoryInterface;
21+
22+
class MassActivateTest extends TestCase
23+
{
24+
/**
25+
* @var CatalogRuleRepositoryInterface|MockObject
26+
*/
27+
private $catalogRuleRepositoryMock;
28+
29+
/**
30+
* @var Context|MockObject
31+
*/
32+
protected $contextMock;
33+
34+
/**
35+
* @var MassActivate
36+
*/
37+
protected $activate;
38+
39+
/**
40+
* @var RequestInterface|MockObject
41+
*/
42+
protected $requestMock;
43+
44+
/**
45+
* @var Rule|MockObject
46+
*/
47+
protected $ruleMock;
48+
49+
/**
50+
* @var ManagerInterface|MockObject
51+
*/
52+
protected $messageManagerMock;
53+
54+
/**
55+
* @var Redirect|MockObject
56+
*/
57+
protected $resultRedirectMock;
58+
59+
/**
60+
* @var ResultFactory|MockObject
61+
*/
62+
protected $resultFactory;
63+
64+
protected function setUp(): void
65+
{
66+
$this->requestMock = $this->getMockBuilder(RequestInterface::class)
67+
->onlyMethods(['getParam'])
68+
->getMockForAbstractClass();
69+
$this->contextMock = $this->createMock(Context::class);
70+
71+
$this->messageManagerMock = $this->getMockBuilder(ManagerInterface::class)
72+
->getMockForAbstractClass();
73+
74+
$this->resultRedirectMock = $this->getMockBuilder(Redirect::class)
75+
->onlyMethods(['setPath'])
76+
->disableOriginalConstructor()
77+
->getMock();
78+
79+
$this->resultFactory = $this->createMock(ResultFactory::class);
80+
$this->resultFactory->method('create')->willReturn($this->resultRedirectMock);
81+
$this->contextMock->method('getResultFactory')->willReturn($this->resultFactory);
82+
$this->contextMock->method('getMessageManager')->willReturn($this->messageManagerMock);
83+
$this->contextMock->method('getRequest')->willReturn($this->requestMock);
84+
$this->catalogRuleRepositoryMock = $this->createMock(
85+
CatalogRuleRepositoryInterface::class
86+
);
87+
$this->activate = new MassActivate($this->contextMock, $this->catalogRuleRepositoryMock);
88+
}
89+
90+
public function testExecute()
91+
{
92+
$data = [1];
93+
$this->requestMock->expects(self::any())
94+
->method('getParam')
95+
->willReturn($data);
96+
$catalogRuleMock = $this->getMockForAbstractClass(RuleInterface::class);
97+
$this->catalogRuleRepositoryMock->expects($this->once())
98+
->method('get')
99+
->with(1)
100+
->willReturn($catalogRuleMock);
101+
$this->messageManagerMock->expects($this->once())
102+
->method('addSuccessMessage')
103+
->with(__('You activated a total of %1 records.', $data));
104+
$this->activate->execute();
105+
}
106+
}

0 commit comments

Comments
 (0)