I am working in a process to will weekly updating a list of products and assign them to a sales category. The list could have 2000 products or more each time. Right now I am using the method assignProductToCategories from \Magento\Catalog\Api\CategoryLinkManagementInterface
foreach($updatedSalesProducts as $_sku => $_categoryIds){
$productModel = $this->_productRepository->get($_sku, true, \Magento\Store\Model\Store::DEFAULT_STORE_ID, true);
$currentCategories = $productModel->getCategoryIds();
$_categoryIds = array_merge($currentCategories, $_categoryIds);
$_categoryIds = array_unique($_categoryIds);
$this->_categoryLinkManagementInterface->assignProductToCategories($_sku, $_categoryIds);
}
However, each product is taking around 4 seconds to update. So, in total, all the processes are taking 2 hours or more. Is there a faster way to assign the 2000 products to the same category without taking too much time?