How To Add Magento 2 Products To Category Programmatically

I have created Magento 2 product programmatically, but how can I add or assign new products to exist Magento 2 categories

You will need to get Magento 2 product SKU and category ID first and call assignProductToCategories method from categoryLinkManagement class to assigning the products to exist Magento 2 categories

Here is the example

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments