Skip to content
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
Closed

Cannot remove product_list_toolbar in XML #9413

joshfortyfour opened this issue Apr 26, 2017 · 10 comments
Assignees
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@joshfortyfour
Copy link

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
Copy link
Member

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
Copy link

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
Copy link
Member

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
Copy link
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 👍

@magento-engcom-team magento-engcom-team added G1 Passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team
Copy link
Contributor

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

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Sep 28, 2017
@mariuscris
Copy link

I'm working on it #SQUASHTOBERFEST

magento-team pushed a commit that referenced this issue Nov 25, 2017
…t in XML #9413 #11473

 - Merge Pull Request #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
…t in XML #9413 #11473

 - Merge Pull Request #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
[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
@okorshenko
Copy link
Contributor

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

@okorshenko okorshenko added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Nov 27, 2017
@VincentMarmiesse
Copy link
Contributor

Hi @okorshenko,

Is it supposed to be fixed in 2.2.2?

I'm having the issue on a 2.2.2.

@okorshenko
Copy link
Contributor

I think it will be a part of 2.2.4

@okorshenko okorshenko added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Mar 2, 2018
@okorshenko
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

7 participants