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

I cannot move the block #7253

Closed
springimport opened this issue Oct 31, 2016 · 32 comments
Closed

I cannot move the block #7253

springimport opened this issue Oct 31, 2016 · 32 comments
Labels
bug report Component: Catalog 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 Priority: P3 May be fixed according to the position in the backlog. Progress: done 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 Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. stale issue Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@springimport
Copy link

springimport commented Oct 31, 2016

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?

@orlangur
Copy link
Contributor

orlangur commented Nov 1, 2016

Well, some of the blocks are supposed to be inside other blocks or exist in layout by design. I don't think putting "if block exists" conditions everywhere is a wise idea. Only if product listing without toolbar is a real-world use case such check should be added.

Why do you need to move toolbar block outside? If it's really necessary, you can just render its markup in another place in your HTML and not render a markup in original place.

@springimport
Copy link
Author

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"/>

@orlangur
Copy link
Contributor

orlangur commented Nov 2, 2016

As you can see from implementation blocks are mixed with collection model and thus some data is obtained from toolbar block and defines model state. In this (poor) implementation product list block does not make sense without toolbar block (which is not just visual representation but also a storage for some collection flags).

You cannot remove block from layout without additional fixes but you can remove it from HTML markup by changing its or product list template.

@springimport
Copy link
Author

So, I have to make a crutch.

@orlangur
Copy link
Contributor

orlangur commented Nov 3, 2016

Exactly, until product list block implementation is decoupled from toolbar you cannot just change layout structure without consequences.

Since it's quite old code it does not seem to me that it's a big problem.

@springimport
Copy link
Author

I solved the problem moved my blocks inside the category.products block and now I can move the product_list_toolbar within the category.products where I want.

@veloraven
Copy link
Contributor

@springimport thank you for your report.
Please, identify which version of Magento you are running.

@springimport
Copy link
Author

@veloraven Magento ver. 2.1.2.

@Koc
Copy link

Koc commented Dec 13, 2016

@veloraven having similar problem on Magento 2.1.2:

Steps to reproduce issue:

  1. change block order in layout: make layered navigation render before product list
  2. go to page 2
  3. when layered navigation starts render it produces query with limit 20, offset 0 (AFIK this occurs because ListProduct::_beforeToHtml, Toolbar::setCollection haven't called on this state)
  4. we got an error like "no products found for your query".

@deepak-netwin
Copy link

@springimport How did you solve this problem? I'm facing same issue. I want to move product toolbar outside columns container like this http://prntscr.com/f6335o.
But I'm also getting same error i.e. Fatal error: Uncaught Error: Call to a member function getSize() on null in

@springimport
Copy link
Author

@deepak-netwin Try to use a several wrappers for default containers.

@PieterCappelle
Copy link
Contributor

@springimport Could explain what you mean with adding several wrappers for default containers? We're having the same issue.

@springimport
Copy link
Author

@PieterCappelle Instead of moving toolbar, wrap toolbar with content via new blocks and remove classes and tags from toolbar block (currently not working, because m2.2 shows validation errors on this).

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Dec 4, 2017
@magento-engcom-team
Copy link
Contributor

@engcom-Alfa Thank you for verifying the issue.

Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:

Once all required information is added, please add label "Issue: Confirmed" again.
Thanks!

@magento-engcom-team magento-engcom-team removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Dec 23, 2019
@ghost ghost unassigned engcom-Alfa Dec 23, 2019
@engcom-Alfa
Copy link
Contributor

This issue is reproduced on the fresh 2.4-develop instance

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"/>

Actual Result:
screen

@magento-engcom-team magento-engcom-team added Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Dec 24, 2019
@engcom-Alfa engcom-Alfa added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Dec 24, 2019
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Alfa
Thank you for verifying the issue. Based on the provided information internal tickets MC-30052 were created

Issue Available: @engcom-Alfa, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@sdzhepa sdzhepa added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Sep 23, 2020
@gabrieldagama gabrieldagama added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Oct 6, 2020
@ericmorand
Copy link

@orlangur ,

Well, some of the blocks are supposed to be inside other blocks or exist in layout by design

Really? Can you point us to the documentation that give that information to developers?

@fritzmg
Copy link

fritzmg commented Nov 18, 2020

I don't think this is documented in detail anywhere. You'll have to look at the code yourself.

@stale
Copy link

stale bot commented Feb 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Catalog 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 Priority: P3 May be fixed according to the position in the backlog. Progress: done 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 Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. stale issue Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Development

No branches or pull requests