Im trying to update existing Categories. They have a Custom Design (Theme) because of the general theme we are using and I forgot to add that to the creation code.

So I setup a simple script to retrieve and edit and save the existing Categories.

I thought the "right" way is saving the Category object through the RepoInterface, but when I do that the Category doesn't get updated. Only when I call the (I thought deprecated) method "save" on the Object itself it actually saves.

Some sample code:

$collection = $this->categoryCollection->create();

foreach ($collection as $key => $cat) {
    if ($cat->getId() == 1 || $cat->getId() == 2) // Skip Cats: Root and Default

    try {
        $cat->setData('custom_design', 4);
        $cat->setData('page_layout', 'cat_page');
 /*WHY*/$cat->save(); // Only when I add this it actually saves...
    } catch (Exception $e) {
        echo 'something went wrong...';

Your Answer

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

Browse other questions tagged or ask your own question.