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

Fix for Issue-13556 - Sorting in Product Listing via Quantity not work #13691

Merged
merged 4 commits into from
Mar 7, 2018

Conversation

nuzil
Copy link
Contributor

@nuzil nuzil commented Feb 16, 2018

This Pull Request related to issue: #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)

…Model/Source/Stock.php" - overridden parent method "addValueSortToCollection" for adding sorting by stock items qty.
@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Feb 16, 2018

CLA assistant check
All committers have signed the CLA.

@sidolov sidolov self-assigned this Mar 7, 2018
@sidolov
Copy link
Contributor

sidolov commented Mar 7, 2018

Changes covered with unit test

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.

4 participants