/** * Re-index all the products * * @param Storefront_Model_Catalog $catalogModel */ public function reIndexAllProducts(Storefront_Model_Catalog $catalogModel) { $products = $catalogModel->getAllProducts(); if (null !== $products) { foreach ($products as $product) { $categories = $catalogModel->getCategoryChildrenIds($product->categoryId); foreach ($categories as $key => $catId) { if (null !== ($cat = $catalogModel->getCategoryById($catId))) { $categories[$key] = $cat->name; } } $categories[] = $catalogModel->getCategoryById($product->categoryId)->name; $document = new Storefront_Model_Document_Product($product, join(',', $categories)); $this->indexProduct($document); } $this->getIndexingEngine()->commit(); $this->doMaintenance(); } }