Description
Preconditions
- Magento 2.1.1 Community Edition
- one Website two StoreViews:
ID: 1 -> [de] -> [Deutsch]
ID: 2 -> [en] -> [Englisch]
Steps to reproduce
Create a category in backend or programmatically
Name: Test123
after that in all storeViews the category have the name Test123
if you now want to try to change the name of the category for StoreView: 2 programmatically it is not working.
Everytime the "Update" is going to StoreView: 1
<?php
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["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);
?>
when i run this the Name for the category is changed for StoreView 1 to "TESTA-1_ENG" but not for StoreView 2. i cant find a way to save the changes to a specific StoreView. Everytime the changes goes to StoreView 1. Also StoreView 0 is not working.