How to bulk update order or locations and categories to order by name?

ClassiBase classifieds script Forums Tips and tricks How to bulk update order or locations and categories to order by name?

Tagged: , , ,

This topic contains 0 replies, has 1 voice, and was last updated by  ClassiBase 8 months, 3 weeks ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #3222 Reply

    ClassiBase
    Keymaster

    This is question from one of our customers. We share it so other may use this solution.

    When importing ads from other source all locations and categories are scrambles, not alphabetical order, the only way I see to reorder is manually so it is too hard. How to update order of locations and categories to match order by name.

    Currently as of Classibase version 1.7.8 we do not have built in bulk updating order feature.

    To order all locations in alphabetic order please execute following query in mysql using phpmyadmin or any mysql client. This will work if you have less than 56k locations / categories.

    SET @rank:=0;
    UPDATE cb_location SET pos=@rank:=@rank+1 WHERE 1=1 ORDER BY slug;

    Similar query for categories

    SET @rank:=0;
    UPDATE cb_category SET pos=@rank:=@rank+1 WHERE 1=1 ORDER BY slug;
Viewing 1 post (of 1 total)
Reply To: How to bulk update order or locations and categories to order by name?
Your information: