Magento 2 – Remove Position from Category Sorting Product List

magento2product-listsorting

I have sorted products in categories by:

  • price (default)
  • name
  • position

I need to remove the position from the menu leaving only price and name

I don't want to edit every single category view from the catalog–>manage categories because I have too many categories in the store.

PFA
enter image description here

Best Answer

quick workaround can be add a condition in theme templates file Magento_Catalog/templates/product/list/toolbar/sorter.phtml like

if $key != 'position' then don't add in drop down options :

<select id="sorter" data-role="sorter" class="sorter-options">
    <?php foreach ($block->getAvailableOrders() as $_key => $_order): ?>

        <?php if ($_key != 'position') : // if key sort by position remove it?>
        <option value="<?= /* @escapeNotVerified */ $_key ?>"
            <?php if ($block->isOrderCurrent($_key)): ?>
                selected="selected"
            <?php endif; ?>
            >
            <?= $block->escapeHtml(__($_order)) ?>
        </option>
       <?php endif; ?>

    <?php endforeach; ?>
</select>