0

I need below condition to my website.

Magento2 Catalog search result and product listing grid only sort by product name to be set.

I have also back-end configuration done but issue is like product listing page is show product name and when search any product then catalog search result page show relevant search .

so give me solution

enter image description here

0

2 Answers 2

0

If you want to sort by other attribute, you need to...

  • Go to: Stores > Attribute > Product
  • Choose the product you want to integrate to be able to change the sort order
  • Navigate to "Storefront Properties" (on the left)
  • Set "Used for Sorting in Product List" to "Yes"

Magento2 edit attribute properties to make is available in the sort order option

0
  1. Make your attribute 'Used for Sorting in Product Listing' to Yes
  2. Just add this block in referenceContainer at catalogsearch_result_index.xml
<referenceBlock name="search_result_list">
            <action method="setDefaultDirection">
                <argument name="dir" xsi:type="string">asc or desc</argument>
            </action>
            <action method="setSortBy">
                <argument name="attribute" xsi:type="string">attribute_code</argument>
            </action>
</referenceBlock>

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.