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

[Forwardport] Fix for Issue-13556 - Sorting in Product Listing via Quantity not work #14179

Merged

Conversation

dimonovp
Copy link
Contributor

Original Pull Request

#13691

Fixed Issues

  1. Sorting in Product Listing via Quantity not work #13556

Problem

If you edit product attribute 'quantity_and_stock_status' and set "Used for Sorting in Product Listing" to "Yes" sort option will be displayed on category products page but sorting will not work.

Reason

  1. Attribute 'quantity_and_stock_status' has source model, and for sorting magento calls addValueSortToCollection method of source model.
  2. However source model of this attribute ("Magento\CatalogInventory\Model\Source\Stock") does not have its own method "addValueSortToCollection" only inherits parent one which just do nothing (return $this).

Fix

We added to source model method which contain logic to join to collection (which is always product collection) cataloginventory_stock_item table and add order by qty field.

Manual testing scenarios

Testing scenarios can be found in issue
#13556

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

Pavel and others added 4 commits March 19, 2018 14:07
…Model/Source/Stock.php" - overridden parent method "addValueSortToCollection" for adding sorting by stock items qty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants