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

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

  • 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. – Suresh Chikani Jul 14 '17 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 – Manoj Deswal Jul 14 '17 at 7:01
  • I want display it on first possession – Suresh Chikani Jul 14 '17 at 7:02
  • in drop down you want it at first position ? and i think that is in alphabetical order – Manoj Deswal Jul 14 '17 at 7:07
  • Yes I want that – Suresh Chikani Jul 14 '17 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;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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