Closed
Description
Preconditions
- Magento 2.1.6
- PHP 7.0.18
- MySql 5.7.18
- Apache 2.4
Steps to reproduce
- Create Magento_Catalog/layout/catalog_category_view.xml in custom theme
- Add the following code:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<referenceBlock name="product_list_toolbar" remove="true"/>
</referenceContainer>
</body>
</page>
Expected result
- The toolbar should be removed from the product list pages.
Actual result
- The toolbar remains on the page. After talking with Alan Storm about the issue he dug into the
vendor/magento/module-catalog/Block/Product/ListProduct.php
file and, specifically, thegetToolbarBlock()
method which does this:
public function getToolbarBlock()
{
$blockName = $this->getToolbarBlockName();
if ($blockName) {
$block = $this->getLayout()->getBlock($blockName);
if ($block) {
return $block;
}
}
$block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, uniqid(microtime()));
return $block;
}
It checks for the toolbar and, if it finds it, returns it. If it doesn't find it (i.e., it's removed via xml), it renders it to the page.
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.2 release lineThe issue has been fixed in 2.3 release lineGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.3 release