1

I need help changing the text in () when selecting the sort option. With translation I change to Low to high and High to low but I have to change Product name to (A-Z). I don't know how to change only one option (Only Product Name)

enter image description here

$directions = ['asc', 'desc'];
$currentDirection = $block->getCurrentDirection();

?>
<div class="toolbar-sorter sorter">
    <label class="sorter-label" for="sorter"><?= $block->escapeHtml(__('Sort By')) ?></label>
    <select id="sorter" data-role="sorter" class="sorter-options">
        <?php foreach ($block->getAvailableOrders() as $_key => $_order) :?>
            <?php foreach ($directions as $_sort): ?>
                <option value="<?= $block->escapeHtmlAttr($_key) ?>.<?= $_sort ?>"
                    <?php if ($block->isOrderCurrent($_key) && $currentDirection === $_sort) :?>
                        selected="selected"
                    <?php endif; ?>
                    >
                    <?= $block->escapeHtml(__($_order)) ?>
                    (<?= $block->escapeHtml($_sort === "asc" ? __("Ascending") : __("Descending")) ?>)
                </option>
            <?php endforeach; ?>
        <?php endforeach; ?>
    </select>
?>

1 Answer 1

0

Ok i find solution! Just add this code :

<?php if ($_key == 'name'):?>


                  

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.