Hello Magento Friends,

In today’s instructional guide, I will explain How to Move the Category Position Programmatically in Magento 2?

A Magento 2 store contains various categories to classify the products based on their type. The category comprises various subcategories and products. You can quickly move subcategories in Magento 2 by drag-and-drop from the Admin Panel. Another way to move the category position is by executing it programmatically.

Let’s see how to move the category position from one parent category to another parent category along with its products programmatically in Magento 2.

Steps to Move Category Position Programmatically in Magento 2:

Category position before running the script

category position - before

 

Step 1: Create a file in your Magento root directory at the below path. 

magento_root_directory\Changecategoryposition.php

Now add the code as follows

Step 2: After the above step, you will need to run the below-given URL.

https://yourdomain.com/Changecategoryposition.php 

Category position after running the script

category position - after

Conclusion:

This way, you can change the category position in Magento 2 programmatically. Alternatively, you can integrate Duplicate Categories Extension for Magento 2 to create a copy of the category.

Share your doubts with me in the comment box. Stay in touch with us for more Magento 2 solutions.

Happy Coding!

Click to rate this post!
[Total: 2 Average: 5]