Is there a command for moving categories to be sub-categories?
And can a number of them be sun in a script?
Is there a command for moving categories to be sub-categories?
And can a number of them be sun in a script?
Something like this might do it.
parent=Category.find_by_slug('slug')
subs=Category.where(<a way to get your categories>).update_all(parent_category_id: parent.id)
Thanks. It took me a while to figure out what was meant by “a way to get your categories”, but realised it probably was the “where” clause of a SQL statement. Though I had no idea what the table names or column names were, but managed to find them with the SQL statements noted in the post about the Data Model.
So, I ended up with this,
parent=Category.find_by_slug('csgnet') subs=Category.where('slug like “csg1%”').update_all(parent_category_id: parent.id)
which moves all categories starting with the text “csg1” into the category “csgnet”, where “slug” is the column name in the table of categories. The table name is called “category”, I think.