- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016
03:59 AM
10-14-2016
03:59 AM
create new/update category programmatically for specific storeView not working
Hi,
when i try to create/update a category programmatically for example to change the category name in my english storeView (2) to another name it does not work. The changes will go everytime to storeView 1 and not to the storeview that i defined:
<?php 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 that the name of the category is "TESTA-1_ENG" in storeView 1 but not in storeView 2. In storeView 2 it is the again the original name from the create process.
i think this must be a bug? Every save process will only affect to storeView 1 and not to the storeView that i defined.
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2016
02:36 AM
12-06-2016
02:36 AM
Re: create new/update category programmatically for specific storeView not working
Why you again using objectmanager for saving. ? you can simly use $category->save();