How can I change name desciption, position and image attributes for a category using code. I tried this code for changing the name, but without success:

// $_this->cm is \Magento\Catalog\Model\Category
$c=$this->cm->loadByAttribute("pim_category_id", $pimCategoryId);

        $c->setData("name", "testingNaminho");
        $c->setName("via setName setted");
        $c->setData("description", $description);
        $c->setData("position", $position);
        //$c->setData("image", $name);


Try following way:

public function __construct(
    \Magento\Framework\Registry $registry
) {
    $this->registry = $registry;

And Now:

$this->registry->register('isSecureArea', true);

//Add your save operation here

Check the store id of the saved category attribute. Likely the value saved in db but the store id is not General

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.