Question: How to my stock items listed in alphabetical order

How to my stock items listed in alphabetical order

I have a variety of products, more than 2,000 products. i want them to list in alphabetical order once i click on products. Please tell me which file i need to edit and what to edit to mak

BR

Bryan Richardson

Asked
I have a variety of products, more than 2,000 products. i want them to list in alphabetical order once i click on products.
Please tell me which file i need to edit and what to edit to make this possible.
Counting on your urgent response.
  • MS

    Mian Saleem

    Answered
    Hello,

    The products on listing page is sorted by code and name. If you need only by name then you can modify `aaSorting` for dataTable in `themes/default/admin/views/products/index.php`

    Thank you
  • BR

    Bryan Richardson

    Answered
    i have located the the fine and played with it a couple of times, but i do not seemed to get it right.... here is the code

    <?php
    } ?>
    </style>
    <script>
    var oTable;
    $(document).ready(function () {
    oTable = $('#PRData').dataTable({
    "aaSorting": [[2, "asc"], [3, "asc"]],
    "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "<?= lang('all') ?>"]],
    "iDisplayLength": <?= $Settings->rows_per_page ?>,
    'bProcessing': true, 'bServerSide': true,
    'sAjaxSource': '<?= admin_url('products/getProducts' . ($warehouse_id ? '/' . $warehouse_id : '') . ($supplier ? '?supplier=' . $supplier->id : '')) ?>',
    'fnServerData': function (sSource, aoData, fnCallback) {
    aoData.push({
    "name": "<?= $this->security->get_csrf_token_name() ?>",
    "value": "<?= $this->security->get_csrf_hash() ?>"
    });
    $.ajax({'dataType': 'json', 'type': 'POST', 'url': sSource, 'data': aoData, 'success': fnCallback});
    },
    'fnRowCallback': function (nRow, aData, iDisplayIndex) {
    var oSettings = oTable.fnSettings();
    nRow.id = aData[0];


    please what should i change to make it work?
  • MS

    Mian Saleem

    Answered
    Hello,

    You can see the `"aaSorting": [[2, "asc"], [3, "asc"]],` you can change it to `"aaSorting": [[3, "asc"]],` to sort by the name (3rd column starting from 0)

    Thank you
  • BR

    Bryan Richardson

    Answered
    thanks. it worked out good for me
  • Login to Reply