magento2: I cannot move the block

Preconditions

Magento 2.4-develop Php v. 7.2

Steps to reproduce

  1. Open catalog module -> catalog_category_view.xml
  2. Try to move a toolbar outside the block.
<referenceContainer name="content.top">
    <container name="product_list_toolbar_container" htmlTag="div"/>
</referenceContainer>
<move element="product_list_toolbar" destination="product_list_toolbar_container"/>

(product_list_toolbar_container - my container).

Actual result

  1. Fatal error: Uncaught Error: Call to a member function getSize() on null in \vendor\magento\module-catalog\view\frontend\templates\product\list\toolbar.phtml:26 Stack trace: ...

I think I know why the error occurs. The block cannot be found when he outside.

  1. https://github.com/magento/magento2/blob/develop/app/code/Magento/Catalog/Block/Product/ListProduct.php#L215
  2. https://github.com/magento/magento2/blob/develop/app/code/Magento/Catalog/Block/Product/ListProduct.php#L196

move-block

Expected Result

The block successfully moved

Additional information

This is a problem of the system architecture. How I can solve it?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 9
  • Comments: 32 (11 by maintainers)

Most upvoted comments

@mbernabeu Working on the issue.

by design

bad design

I have a custom layout, why do I need.

Also I cannot remove the block. How can I hide it?

<referenceBlock name="product_list_toolbar" remove="true"/>

Is there any news about these issues? I have the same problem