Skip to content

Commit 90b9c43

Browse files
authored
Merge pull request magento#4734 from magento-tsg-csl3/MC-19197
[TSG-CSL3] For 2.3 (MC-19197)
2 parents d93d288 + 5aaaaab commit 90b9c43

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

app/code/Magento/LayeredNavigation/Block/Navigation.php

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,25 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
7-
/**
8-
* Catalog layered navigation view block
9-
*
10-
* @author Magento Core Team <[email protected]>
11-
*/
126
namespace Magento\LayeredNavigation\Block;
137

148
use Magento\Framework\View\Element\Template;
9+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
10+
use Magento\Catalog\Block\Product\ProductList\Toolbar;
1511

1612
/**
13+
* Catalog layered navigation view block
14+
*
1715
* @api
1816
* @since 100.0.2
1917
*/
2018
class Navigation extends \Magento\Framework\View\Element\Template
2119
{
20+
/**
21+
* Product listing toolbar block name
22+
*/
23+
private const PRODUCT_LISTING_TOOLBAR_BLOCK = 'product_list_toolbar';
24+
2225
/**
2326
* Catalog layer
2427
*
@@ -67,9 +70,20 @@ protected function _prepareLayout()
6770
$filter->apply($this->getRequest());
6871
}
6972
$this->getLayer()->apply();
73+
7074
return parent::_prepareLayout();
7175
}
7276

77+
/**
78+
* @inheritdoc
79+
*/
80+
protected function _beforeToHtml()
81+
{
82+
$this->configureToolbarBlock();
83+
84+
return parent::_beforeToHtml();
85+
}
86+
7387
/**
7488
* Get layer object
7589
*
@@ -119,4 +133,20 @@ public function getClearUrl()
119133
{
120134
return $this->getChildBlock('state')->getClearUrl();
121135
}
136+
137+
/**
138+
* Configures the Toolbar block
139+
*
140+
* @return void
141+
*/
142+
private function configureToolbarBlock(): void
143+
{
144+
/** @var Toolbar $toolbarBlock */
145+
$toolbarBlock = $this->getLayout()->getBlock(self::PRODUCT_LISTING_TOOLBAR_BLOCK);
146+
if ($toolbarBlock) {
147+
/** @var Collection $collection */
148+
$collection = $this->getLayer()->getProductCollection();
149+
$toolbarBlock->setCollection($collection);
150+
}
151+
}
122152
}

0 commit comments

Comments
 (0)