Programmatically update name of category in specific storeMagento 2: Products with internal IDs > ~16500 not showing in categoryMagento2 - create new/update category programmatically for specific storeView not workingMagento 2 - Create product programmatically with different store view valuesGet config value for specific store from admin areaForm is not displayed on panel admin Magento 2Having trouble exporting products from Magento 2.x. Fatal error: Uncaught Error: Call to a member function getName()Magento 2.3.0 Get product attribute name in phtml in CMS BlockCategory Date component showing wrong valueSave an EAV attribute in Magento2 without touching the model, repositoryMagento 2.3.0 - The store that was requested wasn't found
What happened to Ghost?
Does higher resolution in an image imply more bits per pixel?
I’ve officially counted to infinity!
How to reply this mail from potential PhD professor?
Pigeonhole Principle Problem
Password expiration with Password manager
Field Length Validation for Desktop Application which has maximum 1000 characters
Applying a function to a nested list
Did we get closer to another plane than we were supposed to, or was the pilot just protecting our delicate sensibilities?
Can I use 1000v rectifier diodes instead of 600v rectifier diodes?
A Warm Riley Riddle
What does air vanishing on contact sound like?
How did Captain America use this power?
Historically, were women trained for obligatory wars? Or did they serve some other military function?
Airbnb - host wants to reduce rooms, can we get refund?
Is it the same airport YUL and YMQ in Canada?
Why do money exchangers give different rates to different bills
What is the word which sounds like "shtrass"?
Is lying to get "gardening leave" fraud?
How do I tell my manager that his code review comment is wrong?
Disabling Resource Governor in SQL Server
My ID is expired, can I fly to the Bahamas with my passport
What are the spoon bit of a spoon and fork bit of a fork called?
You look catfish vs You look like a catfish?
Programmatically update name of category in specific store
Magento 2: Products with internal IDs > ~16500 not showing in categoryMagento2 - create new/update category programmatically for specific storeView not workingMagento 2 - Create product programmatically with different store view valuesGet config value for specific store from admin areaForm is not displayed on panel admin Magento 2Having trouble exporting products from Magento 2.x. Fatal error: Uncaught Error: Call to a member function getName()Magento 2.3.0 Get product attribute name in phtml in CMS BlockCategory Date component showing wrong valueSave an EAV attribute in Magento2 without touching the model, repositoryMagento 2.3.0 - The store that was requested wasn't found
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a magento 2 multi store setup (e.g. stores with the id 1 - 3) and I want to update the name of the category with the entity_id 3.
I've tried
$cat = $this->_categoryRepository->get(3, 3);
$cat->setName('Test in Store 3');
$this->_categoryRepository->save($cat);
with $this->_categoryRepository
being an implementation of MagentoCatalogApiCategoryRepositoryInterface
obtained via constructor based dependency injection.
But this just updates the value of the current store. I ran this code inside a cli command and it updated the name attribute of store 1 and not store 3.
The save method in MagentoCatalogModelCategoryRepository obtains the store via
$storeId = (int)$this->storeManager->getStore()->getId();
which always yields the current store.
What is the correct way to update a store specific attribute of a category? I know I could directly hack the database or use the resource model, but that would totally defeat the purpose of the repository pattern.
magento2 magento-2.1
add a comment |
I have a magento 2 multi store setup (e.g. stores with the id 1 - 3) and I want to update the name of the category with the entity_id 3.
I've tried
$cat = $this->_categoryRepository->get(3, 3);
$cat->setName('Test in Store 3');
$this->_categoryRepository->save($cat);
with $this->_categoryRepository
being an implementation of MagentoCatalogApiCategoryRepositoryInterface
obtained via constructor based dependency injection.
But this just updates the value of the current store. I ran this code inside a cli command and it updated the name attribute of store 1 and not store 3.
The save method in MagentoCatalogModelCategoryRepository obtains the store via
$storeId = (int)$this->storeManager->getStore()->getId();
which always yields the current store.
What is the correct way to update a store specific attribute of a category? I know I could directly hack the database or use the resource model, but that would totally defeat the purpose of the repository pattern.
magento2 magento-2.1
Review this link to change attribute of category w3solver.com/…. Let me know if that does not help
– arushi
May 10 '17 at 12:49
add a comment |
I have a magento 2 multi store setup (e.g. stores with the id 1 - 3) and I want to update the name of the category with the entity_id 3.
I've tried
$cat = $this->_categoryRepository->get(3, 3);
$cat->setName('Test in Store 3');
$this->_categoryRepository->save($cat);
with $this->_categoryRepository
being an implementation of MagentoCatalogApiCategoryRepositoryInterface
obtained via constructor based dependency injection.
But this just updates the value of the current store. I ran this code inside a cli command and it updated the name attribute of store 1 and not store 3.
The save method in MagentoCatalogModelCategoryRepository obtains the store via
$storeId = (int)$this->storeManager->getStore()->getId();
which always yields the current store.
What is the correct way to update a store specific attribute of a category? I know I could directly hack the database or use the resource model, but that would totally defeat the purpose of the repository pattern.
magento2 magento-2.1
I have a magento 2 multi store setup (e.g. stores with the id 1 - 3) and I want to update the name of the category with the entity_id 3.
I've tried
$cat = $this->_categoryRepository->get(3, 3);
$cat->setName('Test in Store 3');
$this->_categoryRepository->save($cat);
with $this->_categoryRepository
being an implementation of MagentoCatalogApiCategoryRepositoryInterface
obtained via constructor based dependency injection.
But this just updates the value of the current store. I ran this code inside a cli command and it updated the name attribute of store 1 and not store 3.
The save method in MagentoCatalogModelCategoryRepository obtains the store via
$storeId = (int)$this->storeManager->getStore()->getId();
which always yields the current store.
What is the correct way to update a store specific attribute of a category? I know I could directly hack the database or use the resource model, but that would totally defeat the purpose of the repository pattern.
magento2 magento-2.1
magento2 magento-2.1
edited Sep 23 '18 at 18:25
Zefiryn
4,63321728
4,63321728
asked May 10 '17 at 11:23
ochnygoschochnygosch
1068
1068
Review this link to change attribute of category w3solver.com/…. Let me know if that does not help
– arushi
May 10 '17 at 12:49
add a comment |
Review this link to change attribute of category w3solver.com/…. Let me know if that does not help
– arushi
May 10 '17 at 12:49
Review this link to change attribute of category w3solver.com/…. Let me know if that does not help
– arushi
May 10 '17 at 12:49
Review this link to change attribute of category w3solver.com/…. Let me know if that does not help
– arushi
May 10 '17 at 12:49
add a comment |
1 Answer
1
active
oldest
votes
$storeId = (int)$this->storeManager->getStore()->getId();
Category name does have scope of store so repository's save method will work fine when you call this code from admin after switching scope using store scope switcher in admin category form.
But instead of using save method of the repository you could
Directly call save on category.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f173814%2fprogrammatically-update-name-of-category-in-specific-store%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$storeId = (int)$this->storeManager->getStore()->getId();
Category name does have scope of store so repository's save method will work fine when you call this code from admin after switching scope using store scope switcher in admin category form.
But instead of using save method of the repository you could
Directly call save on category.
add a comment |
$storeId = (int)$this->storeManager->getStore()->getId();
Category name does have scope of store so repository's save method will work fine when you call this code from admin after switching scope using store scope switcher in admin category form.
But instead of using save method of the repository you could
Directly call save on category.
add a comment |
$storeId = (int)$this->storeManager->getStore()->getId();
Category name does have scope of store so repository's save method will work fine when you call this code from admin after switching scope using store scope switcher in admin category form.
But instead of using save method of the repository you could
Directly call save on category.
$storeId = (int)$this->storeManager->getStore()->getId();
Category name does have scope of store so repository's save method will work fine when you call this code from admin after switching scope using store scope switcher in admin category form.
But instead of using save method of the repository you could
Directly call save on category.
answered May 10 '17 at 17:39
Abhishek JakhotiyaAbhishek Jakhotiya
703311
703311
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f173814%2fprogrammatically-update-name-of-category-in-specific-store%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Review this link to change attribute of category w3solver.com/…. Let me know if that does not help
– arushi
May 10 '17 at 12:49