2

I am currently in the process of reordering an entire category tree via an upgrade script. I am aware that you can update the parent ID via the following:

$category->setParentId($value);
$category->save();

Is this the right method to carry out this update?

In doing this will the path and children_count values in the catalog_category_entity table auto update or will I have to set these before saving the category?

1

I don't think this will suffice or is a correct way to do it. If you look at Mage_Adminhtml_Catalog_CategoryController::moveAction() you will see what happens when you update category position by drag and drop from admin.

Most interesting parts are Mage_Catalog_Model_Category::move() and Mage_Catalog_Model_Resource_Category::changeParent()

Hope this helps.

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.