I am facing category page url issue when try to sort products by Price (low to high) or (high to low). I'm using below code to add Price options (high to low).
<option value="<?= /* @escapeNotVerified */ $_key.'&product_list_dir=asc'; ?>"<?php if($block->isOrderCurrent('price') && $block->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>>
<?php echo $block->escapeHtml(__("Price - Low to High")) ?>
</option>
<option value="<?= /* @escapeNotVerified */ $_key.'&product_list_dir=desc'; ?>"<?php if($block->isOrderCurrent('price') && $block->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>>
<?php echo $block->escapeHtml(__("Price - High to Low")) ?>
</option>
<?php else:?>
<option value="<?= /* @escapeNotVerified */ $_key ?>"
<?php if ($block->isOrderCurrent($_key)): ?>
selected="selected"
<?php endif; ?>
>
<?= $block->escapeHtml(__($_order)) ?>
</option>
<?php endif; ?>
How to fix this issue.Need help... Category page URL
https://example.com/boys.html?product_list_order=price%26product_list_dir%3Ddesc