New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot remove product_list_toolbar in XML #9413

Closed
joshfortyfour opened this Issue Apr 26, 2017 · 10 comments

Comments

@joshfortyfour

joshfortyfour commented Apr 26, 2017

Preconditions

  1. Magento 2.1.6
  2. PHP 7.0.18
  3. MySql 5.7.18
  4. Apache 2.4

Steps to reproduce

  1. Create Magento_Catalog/layout/catalog_category_view.xml in custom theme
  2. 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

  1. The toolbar should be removed from the product list pages.

Actual result

  1. 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, the getToolbarBlock() 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.

@tuyennn

This comment has been minimized.

Show comment
Hide comment
@tuyennn

tuyennn commented Apr 27, 2017

See this topic
http://magento-quickies.alanstorm.com/post/160022140410/why-you-cant-remove-the-productlisttoolbar

This is why you cannot remove product_list_toolbar

@astorm

This comment has been minimized.

Show comment
Hide comment
@astorm

astorm Apr 27, 2017

@tuyennn Based on @joshfortyfour's bug report (including mentioning the getToolbarBlock) it sounds like he's already aware of the underlying reasons the toolbar block can't be removed,and considers those underlying reasons a bug.

astorm commented Apr 27, 2017

@tuyennn Based on @joshfortyfour's bug report (including mentioning the getToolbarBlock) it sounds like he's already aware of the underlying reasons the toolbar block can't be removed,and considers those underlying reasons a bug.

@tuyennn

This comment has been minimized.

Show comment
Hide comment
@tuyennn

tuyennn Apr 28, 2017

@astorm Yeah, also your topic is quite well. I think your explanation should help to debug and resolve this one.

tuyennn commented Apr 28, 2017

@astorm Yeah, also your topic is quite well. I think your explanation should help to debug and resolve this one.

@VincentMarmiesse

This comment has been minimized.

Show comment
Hide comment
@VincentMarmiesse

VincentMarmiesse May 25, 2017

Contributor

Hello @tuyennn ,
I'm facing the same issue and as @astorm mentioned, I understand why the product_list_toolbar can't be removed with just a remove="true".

But it's a bug IMO and I think it should be fixed in the future 👍

Contributor

VincentMarmiesse commented May 25, 2017

Hello @tuyennn ,
I'm facing the same issue and as @astorm mentioned, I understand why the product_list_toolbar can't be removed with just a remove="true".

But it's a bug IMO and I think it should be fixed in the future 👍

@magento-engcom-team

This comment has been minimized.

Show comment
Hide comment
@magento-engcom-team

magento-engcom-team Sep 28, 2017

Contributor

@joshfortyfour, thank you for your report.
We've created internal ticket(s) MAGETWO-80293 to track progress on the issue.

Contributor

magento-engcom-team commented Sep 28, 2017

@joshfortyfour, thank you for your report.
We've created internal ticket(s) MAGETWO-80293 to track progress on the issue.

@mariuscris

This comment has been minimized.

Show comment
Hide comment
@mariuscris

mariuscris Oct 15, 2017

Collaborator

I'm working on it #SQUASHTOBERFEST

Collaborator

mariuscris commented Oct 15, 2017

I'm working on it #SQUASHTOBERFEST

@maksek maksek moved this from TODO to Development in Progress in #SQUASHTOBERFEST 2017 Oct 15, 2017

@okorshenko okorshenko moved this from Development in Progress to Pull Request In Progress in #SQUASHTOBERFEST 2017 Nov 1, 2017

@magento-engcom-team magento-engcom-team moved this from TODO to Merging In Progress in branch [2.2-develop] Nov 24, 2017

magento-team pushed a commit that referenced this issue Nov 25, 2017

MAGETWO-83399: Fix for remove 'product_list_toolbar' block from layou…
…t in XML #9413 #11473

 - Merge Pull Request magento/magento2#11473 from mariuscris/magento2:issue-9413
 - Merged commits:
   1. 42072dd
   2. 9dbe444
   3. 49fdfae
   4. b6ed2d9
   5. 9cd20c0
   6. 2adefdf
   7. cbda7b8
   8. 992b3a1
   9. 4e937a3
   10. c303e4d
   11. cd7dc56

magento-team pushed a commit that referenced this issue Nov 25, 2017

MAGETWO-83399: Fix for remove 'product_list_toolbar' block from layou…
…t in XML #9413 #11473

 - Merge Pull Request magento/magento2#11473 from mariuscris/magento2:issue-9413
 - Merged commits:
   1. 42072dd
   2. 9dbe444
   3. 49fdfae
   4. b6ed2d9
   5. 9cd20c0
   6. 2adefdf
   7. cbda7b8
   8. 992b3a1
   9. 4e937a3
   10. c303e4d
   11. cd7dc56
   12. 6162464

magento-team pushed a commit that referenced this issue Nov 25, 2017

Merge pull request #1764 from magento-engcom/2.2-develop-prs
[EngCom] Public Pull Requests - 2.2-develop
 - MAGETWO-83552: save invoice ID on credit memo when using API method salesRefundInvoiceV1 #11670
 - MAGETWO-82577: [Backport 2.2] Translate order getCreatedAtFormatted() to store locale #11422
 - MAGETWO-84474: 10128: New Orders not being saved to order grid #12241
 - MAGETWO-83783: Shipping method fixtures not compatible with getShippingMethod(true) in OrderCreateTest #12227
 - MAGETWO-83290: Add swatch option: Prevent loosing data and default value if data is not populated via adminhtml #12036
 - MAGETWO-83741: 11740: Sending emails from Admin in Multi-Store Environment defaults to Primary Store #11992
 - MAGETWO-83399: Fix for remove 'product_list_toolbar' block from layout in XML #9413 #11473

@magento-engcom-team magento-engcom-team moved this from Merging In Progress to Done in branch [2.2-develop] Nov 25, 2017

@okorshenko

This comment has been minimized.

Show comment
Hide comment
@okorshenko

okorshenko Nov 27, 2017

Contributor

The issue has been fixed and delivered to 2.2-develop branch. Will be available with upcoming patch release

Contributor

okorshenko commented Nov 27, 2017

The issue has been fixed and delivered to 2.2-develop branch. Will be available with upcoming patch release

@okorshenko okorshenko closed this Nov 27, 2017

#SQUASHTOBERFEST 2017 automation moved this from Pull Request In Progress to Done Nov 27, 2017

@magento-engcom-team magento-engcom-team moved this from TODO to Done in branch [2.3-develop] Nov 27, 2017

@VincentMarmiesse

This comment has been minimized.

Show comment
Hide comment
@VincentMarmiesse

VincentMarmiesse Jan 27, 2018

Contributor

Hi @okorshenko,

Is it supposed to be fixed in 2.2.2?

I'm having the issue on a 2.2.2.

Contributor

VincentMarmiesse commented Jan 27, 2018

Hi @okorshenko,

Is it supposed to be fixed in 2.2.2?

I'm having the issue on a 2.2.2.

@okorshenko

This comment has been minimized.

Show comment
Hide comment
@okorshenko

okorshenko Jan 29, 2018

Contributor

I think it will be a part of 2.2.4

Contributor

okorshenko commented Jan 29, 2018

I think it will be a part of 2.2.4

@okorshenko

This comment has been minimized.

Show comment
Hide comment
@okorshenko

okorshenko Mar 2, 2018

Contributor

Hi @joshfortyfour. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1380 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

Contributor

okorshenko commented Mar 2, 2018

Hi @joshfortyfour. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1380 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment