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 #3

Merged
merged 4 commits into from
Mar 20, 2018

Conversation

dimonovp
Copy link
Owner

Original Pull Request

magento#13691
This Pull Request related to issue: magento#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
magento#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.
@dimonovp dimonovp merged commit 551fa25 into 2.3-develop Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant