When attempting to rearrange web store categories and subcategories, changes are not made

  1. Open local development environment
  2. Navigate toModules\suitecommerce\Categories\SuiteScript\Categories.Model.js
  3. Search for the sortBy function (Line 631) and comment on the existing code and paste the following:
, sortBy: function(categories, property) {
    if (categories) {
        var self = this;
        property = property || 'sequencenumber';
        _.each(categories, function(category) {
            self.sortBy(category.categories, property);
        });
        categories.sort(function(a, b) {
            //This works with Strings, Numbers, and Numbers as Strings. ie: ['a', 'b', 'c'] OR [1, 3, 20] OR ['1', '3', '20']
            var numberA = Number(a[property]),
                numberB = Number(b[property]);
            if (!isNaN(numberA) && !isNaN(numberB)) {
                return numberA - numberB;
            } else {
                return (a[property] + '').localeCompare(b[property] + '', {}, {
                    numeric: true
                });
            }
        });
    }
}

4. Gulp Deploy the changes

5. After this you can now proceed to arrange it via the parent commerce category via Commerce > Content Management > Commerce Categories

Leave a comment

Your email address will not be published. Required fields are marked *