Skip to content

Commit 07b708f

Browse files
ENGCOM-1685: [backport 2.1] Category\Collection::joinUrlRewrite should use the store set on the collection #13756
- Merge Pull Request #13756 from alepane21/magento2:bugfix/issue-13704-backport-2.1 - Merged commits: 1. 2239f3d 2. 6f556ff 3. 915be6e
2 parents 8a0fd71 + 915be6e commit 07b708f

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public function joinUrlRewrite()
311311
['request_path'],
312312
sprintf(
313313
'{{table}}.is_autogenerated = 1 AND {{table}}.store_id = %d AND {{table}}.entity_type = \'%s\'',
314-
$this->_storeManager->getStore()->getId(),
314+
$this->getStoreId(),
315315
CategoryUrlRewriteGenerator::ENTITY_TYPE
316316
),
317317
'left'
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Category\Collection;
8+
9+
class UrlRewriteTest extends \PHPUnit_Framework_TestCase
10+
{
11+
/**
12+
* @var \PHPUnit_Framework_MockObject_MockObject
13+
*/
14+
protected $_model;
15+
16+
protected function setUp()
17+
{
18+
$this->_model = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category\Collection::class)
19+
->disableOriginalConstructor()
20+
->setMethods(['joinTable'])
21+
->getMock();
22+
}
23+
24+
public function testStoreIdUsedByUrlRewrite()
25+
{
26+
$cond = '{{table}}.is_autogenerated = 1 AND {{table}}.store_id = 100 AND {{table}}.entity_type = \'category\'';
27+
$this->_model->expects($this->once())
28+
->method('joinTable')
29+
->with(
30+
$this->anything(),
31+
$this->anything(),
32+
$this->anything(),
33+
$this->equalTo($cond),
34+
$this->anything()
35+
);
36+
$this->_model->setStoreId(100);
37+
$this->_model->joinUrlRewrite();
38+
}
39+
}

0 commit comments

Comments
 (0)