I want to move a category from parent category to another parent category.

category Drag and drop from admin is too slow. So how can I do this using code?


I think this will help for you,

First create one test file in root directory with below content and run www.example.com/test.php

$mobile_id = 246;
$mobile_cover_id = 116;
$category = Mage::getModel('catalog/category')->load($mobile_cover_id);
$category->move($mobile_id, null);
| improve this answer | |
  • I am asking about magento 2. BTW Thanks, I have done. – Vinod Kumar Apr 28 '18 at 11:06
$categoryId = 183;
$parentId = 540;
$rootCat = $objectManager->get('Magento\Catalog\Model\Category');
$cat_info = $rootCat->load($categoryId);
$cat_info->move($parentId, null);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.