-
Notifications
You must be signed in to change notification settings - Fork 341
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
Reset page size before load #1862
Conversation
The page size is already reset in _renderFiltersBefore but might be changed between rendering the filters and loading the collection. If that happens no items will be found.
Tests are basically running through.
I am wondering if that really changed because of the patch?
That does not make sense :-D The Method of course has to be called like that because we are overwriting the parent. |
@DanieliMi can you quickly add a
to the _beforeLoad, like it is with the other methods. @ maintainers: I am wondering if we should just ignore the class complexity as well? Or do we need major refactoring because of this small change? That would be a pity |
@DanieliMi and this one:
|
Hello everybody. You can add * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) into class annotations and, please, use annotation Regards |
all checks passed :-D does this have chances to be merged? |
This appears to break the solution for Infortis Ultimo theme mentioned in https://github.com/Smile-SA/elasticsuite/wiki/FAQ It relies on sending the pageSize to the collection, because otherwise it tries to load everything and that just doesn't work of course. Problematic code: EDIT: Even worse; this seems to break pagination on layered navigation (at least on elasticsuite 2.9.2), causing it to try to load the entire product collection of a category on page load. @romainruaud @androshchuk @amenk @DanieliMi Can you check this? |
Hi Guys, I've been struggling all day with what I thought was a custom theme / pagination issue with M2.3.3 and elasticsuite 2.8 but turns out to be the changes made by this commit. Even when I revert to the Luma theme with no custom code loading the _beforeLoad() function is setting pagesize to false causing all products in the category /. search / filter to be loaded. When I revert this commit everything works as normal. I guess this might be causing problems for a lot of users... |
@romainruaud How can we proceed here, this also seems to cause #1903 ... but just reverting will also cause the old problems to appear. |
@amenk I don't know if all the tests would be easy to write :
I'll try to have a look but actually we'll have to deliver a release containing the fix asap. And by the way, I missed @Quazz message that was pointing the problem 19 days ago :/ As always, you did a good catch guy ! |
good question, maybe some example layout XML files have to be created and tested against. |
It could work by having certain my_handle_1.xml files and write integration tests which inject the according handles and check the pagination on the according pages. |
Summary
The page size is already reset in _renderFiltersBefore but might be changed between rendering the filters and loading the collection. If that happens no items will be found.
Related Issues
#249
Description
When moving the navigation (
catalog.leftnav
) it will change the load order of the blocks. In our case we moved it incatalog_category_view_type_layered.xml
:When rendering a category view
\Magento\Catalog\Block\Product\ProductList\Toolbar::setCollection
is called multiple times. WithinsetCollection
$this->_collection->setCurPage($this->getCurrentPage());
is called and will overwrite resetting the page size in _renderFiltersBefore if_renderFiltersBefore
is called outside of\Magento\Framework\Data\Collection\AbstractDb::load
since filters will be only rendered once (see \Magento\Framework\Data\Collection\AbstractDb::_renderFilters).So we need to make sure
_pageSize
is false when loading the collection and setting it in _renderFiltersBefore is good but it might be overwritten if the method is called outside of\Magento\Framework\Data\Collection\AbstractDb::load
.Setting
_pageSize
to false in_beforeLoad()
makes sure the page size is handled by the engine and the collection does not depend on block load order anymore.The commit should be applied to 2.9.x as well since it might have the same issue (not verified by myself tho).