protected function _rebuildCategoryIndex($storeId, $categoryIds = null)
{
if ($categoryIds == null || count($categoryIds) == 0) {
$size = $this->category_helper->getCategoryCollectionQuery($storeId, $categoryIds)->getSize();
$by_page = $this->config->getNumberOfElementByPage();
$nb_page = ceil($size / $by_page);
for ($i = 1; $i <= $nb_page; $i++) {
$data = array('store_id' => $storeId, 'category_ids' => $categoryIds, 'page_size' => $by_page, 'page' => $i);
$this->addToQueue('algoliasearch/observer', 'rebuildCategoryIndex', $data, $by_page);
}
} else {
$this->addToQueue('algoliasearch/observer', 'rebuildCategoryIndex', array('store_id' => $storeId, 'category_ids' => $categoryIds), count($categoryIds));
}
return $this;
}