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

Fix for remove 'product_list_toolbar' block from layout in XML #9413 #11473

Merged
merged 12 commits into from
Nov 25, 2017

Conversation

mariuscris
Copy link

@mariuscris mariuscris commented Oct 15, 2017

Fix for remove 'product_list_toolbar' block from layout in XML #9413

Description

This solution solves the issue when you want to not have toolbar block set on product listing. The reason why toolbar persisted even after that was explicit removed from layout configuration, it's because the method Magento\Catalog\Block\Product\ListProduct:getToolbarBlock always returns a toolbar block.

I think the main reason was build to return a toolbar block is because the product collection needs to use pagination. But there are cases when you have listing with less then 20 products and you want to not have toolbar in place. In that case you will be forced to create a custom product listing block class because you cannot remove it from the layout.

The product list use modes for listing and this depends on toolbar block to get that information. Because the toolbar block has a default block, this fix will use this block to get the default mode. You can change the listing mode on layout like this:

<referenceBlock name="category.products.list">
            <action method="setMode">
                <argument name="name" xsi:type="string">list</argument>
            </action>
</referenceBlock>

Fixed Issues (if relevant)

  1. Cannot remove product_list_toolbar in XML #9413: Cannot remove product_list_toolbar in XML

Manual testing scenarios

  1. Create Magento_Catalog/layout/catalog_category_view.xml in a 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>
  1. Activate the custom theme
  2. Open a category page with products

…format on construcor of the product list block class
@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Oct 15, 2017

CLA assistant check
All committers have signed the CLA.

…ility. Use the default toolbar to get current listing mode. Refactor the code.
…L depends on product collection. Because you can remove the toolbar from layout, there is no reason for parent class to add the product collection to default toolbar if the toolbar is never used. That is why the test toolbar coverage needs to include a product collection before checking the toolbar HTML.
…ion present in default layout. Remove the previews correction made because it's not solve the problem where is checking if the toolbar HTML is not empty.
Remove FQCN
@magento-engcom-team magento-engcom-team added 2.2.x 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 labels Nov 7, 2017
@okorshenko okorshenko added this to the November 2017 milestone Nov 7, 2017
@magento-engcom-team magento-engcom-team added the Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release label Nov 20, 2017
@omiroshnichenko omiroshnichenko self-assigned this Nov 21, 2017
@magento-team magento-team merged commit 6162464 into magento:2.2-develop Nov 25, 2017
magento-team pushed a commit that referenced this pull request 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Progress: accept Release Line: 2.2 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

Successfully merging this pull request may close these issues.

7 participants