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;








3















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.










share|improve this question
























  • 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

















3















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.










share|improve this question
























  • 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













3












3








3


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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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










1 Answer
1






active

oldest

votes


















0














$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.






share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    $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.






    share|improve this answer



























      0














      $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.






      share|improve this answer

























        0












        0








        0







        $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.






        share|improve this answer













        $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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 10 '17 at 17:39









        Abhishek JakhotiyaAbhishek Jakhotiya

        703311




        703311



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

            Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?