2

When I try to update a category category name programmatically only for StoreView 2, it does not work.

The changes will go to StoreView 1 every time and not to the StoreView that I defined:


    use \Magento\Framework\App\Bootstrap;

    include('app/bootstrap.php');

    $bootstrap = Bootstrap::create(BP, $_SERVER);
    $objectManager = $bootstrap->getObjectManager(); 
    $category = $objectManager->get('\Magento\Catalog\Model\Category')->load(78);

    $d["updated_at"] = "2016-10-14 10:22:34";
    $d["entity_id"] = "78";
    $d["psl_wawi_cat_id"] = "42";
    $d["position"] = "10";
    $d["is_active"] = "1";
    $d["store_id"] = "2";
    $d["store"] = "2";
    $d["storeid"] = "2";
    $d["is_anchor"] = "1";
    $d["name"] = "TESTA-1_ENG";
    $d["custom_design_from"] = "";
    $d["custom_design_to"] = "";
    $d["include_in_menu"] = "1";
    $d["default_sort_by"] = "";
    $d["path"] = "1/2/74/78";
    $d["level"] = "3";
    $d["url_key"] = "testa-1-eng";
    $d["attribute_set_id"] = "3";
    $category->setData($d);
    $category->setStoreId(2);

    $categoryFactory=$objectManager->get('\Magento\Catalog\Api\CategoryRepositoryInterface')->save($category);

After running this script the name of the category is "TESTA-1_ENG" in StoreView 1 but not in StoreView 2. StoreView 2 still has the original name from the create process.

I think this may be a bug? Every save process will only affect StoreView 1 and not to the StoreView that I defined.

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.