Skip to content

Commit 6f643b4

Browse files
committed
AC-2765::Page Builder Error When Add Product List With Admin User Scope Limitation
1 parent 96faea7 commit 6f643b4

File tree

2 files changed

+60
-1
lines changed
  • app/code/Magento/Review/Model/ResourceModel/Review/Summary
  • dev/tests/integration/testsuite/Magento/Review/Model/ResourceModel/Review/Summary

2 files changed

+60
-1
lines changed

app/code/Magento/Review/Model/ResourceModel/Review/Summary/Collection.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ public function addEntityFilter($entityId, $entityType = 1)
4444
*/
4545
public function addStoreFilter($storeId)
4646
{
47-
$this->_select->where('store_id = ?', $storeId);
47+
if (is_numeric($storeId)) {
48+
$this->_select->where('store_id IN ?', $storeId);
49+
} else {
50+
$this->_select->where('store_id IN (?)', $storeId);
51+
}
52+
4853
return $this;
4954
}
55+
5056
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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\Review\Model\ResourceModel\Summary;
9+
10+
/**
11+
* Tests some functionality of the Product Review collection
12+
*/
13+
class CollectionTest extends \PHPUnit\Framework\TestCase
14+
{
15+
protected function setUp(): void
16+
{
17+
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
18+
\Magento\Review\Model\ResourceModel\Review\Summary\Collection::class
19+
);
20+
}
21+
22+
/**
23+
* @param mixed $storeId
24+
* @dataProvider storeIdDataProvider
25+
*/
26+
public function testAddStoreFilter($storeId) {
27+
$expectedWhere = is_numeric($storeId) ? 'store_id = ?' : 'store_id IN (?)';
28+
29+
$select = $this->createPartialMock(\Magento\Framework\DB\Select::class, ['where']);
30+
$select->expects(
31+
$this->any()
32+
)->method(
33+
'where'
34+
)->with(
35+
$this->equalTo($expectedWhere)
36+
)->willReturnSelf(
37+
38+
);
39+
40+
$this->assertEquals($this->_model, $this->_model->addStoreFilter($storeId));
41+
}
42+
43+
/**
44+
* @return array
45+
*/
46+
public function storeIdDataProvider(): array
47+
{
48+
return [
49+
[1],
50+
[1, [1,2]]
51+
];
52+
}
53+
}

0 commit comments

Comments
 (0)