Knowledgebase

How to use phpMyAdmin to move products from one category to another in Magento

The admin panel offers a couple of ways to move products from one category to another. For example, you can move a single product by editing that product. When you go to Catalog menu>Manage Products and you open the edit screen of a product there's a Categories button on the left which you can use to select which category (categories) should the product be associated with. Another way is to edit the category itself. When you go to Catalog menu>Manage Categories and you open the edit screen of a category you can use the Category Products tab to remove products from the category or to associate products with the category.

By modifying the database in which your Magento is installed you can quickly move products from one category to another. For example, this is a quick solution if you want to move all products from one category to another. You can do this with phpMyAdmin. You can access phpMyAdmin from the Databases section of the Pixie control panel. There's a link in the black area on the right. In phpMyAdmin click on the name of the database in which your Magento is installed (all the databases are listed in the left frame). This will show its tables in the right frame. Click on the SQL tab that's above the tables of the database. In the text area that appears type an SQL query that looks like this:

UPDATE `magento_catalog_category_product` SET `category_id` = 8 WHERE `category_id` = 7

and click on the Go button in the bottom right corner to execute it. In the query that you execute you need to replace magento with the actual prefix of your database tables. You also have to replace the category IDs with those of the particular categories. In our example query above all products from category 7 will be moved to the category with ID 8. If you're not sure what the IDs of the your categories are, one way to check that is in the admin panel of your Magento. When you go to Catalog>Manage Categories and you click on a category on the left to edit it, this will show not only the category settings but also it's name and ID (at the top, above the category settings).

After you execute the query reindex the Magento data. You can do that from the admin panel from System>Index Management.

Was this answer helpful?

 Print this Article

Also Read