-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Magento 2.2.0 A solution for Product Repeat Issue after filter on category listing page. #11429
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
Magento 2.2.0 A solution for Product Repeat Issue after filter on category listing page. #11429
Conversation
@@ -192,7 +192,14 @@ public function setCollection($collection) | |||
$this->_collection->setPageSize($limit); | |||
} | |||
if ($this->getCurrentOrder()) { | |||
$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection()); | |||
if (($this->getCurrentOrder()) == 'position') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One set of round brackets seem to be redundant here. Additionally, please use strict comparison
$this->_collection->addAttributeToSort( | ||
$this->getCurrentOrder(), | ||
$this->getCurrentDirection() | ||
)->addAttributeToSort('entity_id', $this->getCurrentDirection()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming that this collection contains products – using entity_id
directly is discouraged, as this may break on certain scenarios in Magento Commerce (formerly EE) with staging feature enabled.
This may be resolved using metadata for the entity from MetadataPool
and getting proper link field for the entity in question. You may search code for such examples (something I've found right away: \Magento\ConfigurableProduct\Model\ResourceModel\Indexer\Stock\Configurable::_getStockStatusSelect
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ishakhsuvarov Then you suggest us a proper solutions for this issue. Please let me know what exactly I need to change in above code.
@mayankzalavadia Please consider covering the updated flow with the test |
@ishakhsuvarov Then you suggest us a proper solution for this issue. Please let me know what exactly I need to change in above code. |
…return no products when 2 filters selected.
…r filter on category listing page. #11429
Pull Request For Magento 2.2.0: A solution for Product Repeat Issue after filter on category listing page.
Description
I have traced the issues and finally, I have found the problem. This issues #11139 is occurring just because of product position. When some products position are same on collection at that time we have faced this issue. For more detail about this issues please check #11139
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist