6

Native Magento give 3 options position, name, price for sort by option. I added one custom product attribute for sorting option. I want to display it on first position but it is displaying on last position.

How can I change position of custom added attribute and it will display on first sort by option.

Thanks

2 Answers 2

4

Yes , Native Three Option position, name, price comes and by default Sort by position is selected

enter image description here

Added Size 4th criteria to sort

enter image description here

Suppose you want to make Short by Size by default

Go to below path and uncheck the USE SYSTEM VALUE then select your value

Admin > Stores > Configuration > Catalog > Catalog > Store Front > Product Listing Sort by > size

enter image description here

enter image description here

If you added custom value that should be here in drop down list and then you can select that for default shorting via admin

I hope this will help you out, Tested on default LUMA Theme

Thanks

6
  • Yes it's used for default sort by option but not display on first position. I want to display it on first position currently it is showing on fourth position. Commented Jul 14, 2017 at 6:53
  • added Size and its coming on 4th no in drop down, then I selected it in default sorting and it comes sorted by default and show size a default value Commented Jul 14, 2017 at 7:01
  • I want display it on first possession Commented Jul 14, 2017 at 7:02
  • in drop down you want it at first position ? and i think that is in alphabetical order Commented Jul 14, 2017 at 7:07
  • Yes I want that Commented Jul 14, 2017 at 7:08
0

You can do this with plugins.

For that:

Here you can check how to make a plugin.

1. Make a di.xml file.

<type name="Magento\Catalog\Model\Config">
<plugin name="Company_Catalog::getAttributeUsedForSortByArray" type="Company\Catalog\Plugin\AttributeUsedForSortByArray" sortOrder="1"/>
</type>
</config>
  1. Make your plugin file.

*

namespace Firstygroup\Catalog\Plugin;

class AttributeUsedForSortByArray
{
    public function afterGetAttributeUsedForSortByArray(
        $options,
        $result
    )
    {
        if ($result) {
            if(isset($result['position'])){
                unset($result['position']);
            }
        }
        return $result;
    }
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.