2Hats . 1 minute
January 8, 2014

How can products be assigned to multiple stores programmatically in Magento 2?

Let’s say you have a Magento multi-website/store installation and you want to assign the products of a particular category to the new store. I wrote a few lines of code to accomplish this.

You can use this piece of code wherever you want in Magento 2. For example, you can use it as a standalone script to update a bunch of products in the /pub folder. Or, you can use it as a product save observer. It’s your call!

This may not be the most optimized solution, but it did the trick for me.

blog
Greetings! I'm Aneesh Sreedharan, CEO of 2Hats Logic Solutions. At 2Hats Logic Solutions, we are dedicated to providing technical expertise and resolving your concerns in the world of technology. Our blog page serves as a resource where we share insights and experiences, offering valuable perspectives on your queries.
Aneesh ceo
Aneesh Sreedharan
Founder & CEO, 2Hats Logic Solutions
Subscribe to our Newsletter
Aneesh ceo

    Stay In The Loop!

    Subscribe to our newsletter and learn about the latest digital trends.