cancel
Showing results for 
Search instead for 
Did you mean: 

API - multiple products adding

API - multiple products adding

Hello,

I am working on Magento open source (Community Version). API to integrate Magento with third party application.

I would like to know can i add multiple products to a particular category using API.

 

 

 

 

1 REPLY 1

Re: API - multiple products adding

Hi @tatyanabog2b46 ,


protected $categoryLinkManagement;

private function getCategoryLinkManagement()
{
if (null === $this->categoryLinkManagement) {
$this->categoryLinkManagement = \Magento\Framework\App\ObjectManager::getInstance()
->get('Magento\Catalog\Api\CategoryLinkManagementInterface');
}
return $this->categoryLinkManagement;
}

 

You can use below code

$categoryIds = [1];

$this->getCategoryLinkManagement()->assignProductToCategories(
$product->getSku(),

$categoryIds

);

 

Problem Solved? Accept as Solution!

 

Hope it helps!
Thanks

Ankit Jasani