コード例 #1
0
 public function searchResult($hit)
 {
     $catalog = new Storefront_Model_Catalog();
     $product = $catalog->getProductById($hit->productId);
     if (null !== $product) {
         $category = $catalog->getCategoryById($product->categoryId);
         $this->view->product = $product;
         $this->view->category = $category;
         return $this->view->render('index/_result.phtml');
     }
 }
コード例 #2
0
 /**
  * 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();
     }
 }