0

I was doing a research on how to create this 3 elements, I already have 1 website, but I will have a form that will fill the information of store and store view.

I found this question https://community.magento.com/t5/Magento-2-x-Programming/Magento-2-How-to-create-website-Store-Store-view-Root-Category/td-p/87236 but I have no idea where to put that code.

For example this code for creating an store:

private function createOrUpdateGroup($groupId, $websiteId, $storeName, $storeCode)
    {
        $group = $this->groupFactory->create();
        if($groupId)
            $group->load($groupId);

        $group->setWebsiteId($websiteId);
        $group->setName($storeName);
        $group->setCode($storeCode);
        $group->save();

        return $group;
    }

Am I supposed to add this private method in the controller where I'm going to submit the form?

Greetings!

0

You can use data patches for these changes.

https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/data-patches.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.