2017-10-18 134 views
0

我購買了一個搜索模塊,顯示一個彈出窗口並希望添加我在其中搜索的產品的價格,我發現應該進行更改的文件,但是應該添加什麼顯示產品價格搜索時顯示產品價格

這是用於顯示產品特性

protected function _prepareProducts() 
{ 
    $isEnabledImage = (bool) Mage::getStoreConfig(self::ENABLE_IMAGE_CONFIG); 
    $imageHeight = (int) Mage::getStoreConfig(self::IMAGE_HEIGHT_CONFIG); 
    $imageWidth  = (int) Mage::getStoreConfig(self::IMAGE_WIDTH_CONFIG); 

    $isEnabledDescription = (bool) Mage::getStoreConfig(self::ENABLE_DESCRIPTION_CONFIG); 
    $lengthDescription = (int) Mage::getStoreConfig(self::DESCRIPTION_LENGTH_CONFIG); 

    $collection = $this->_getAlternativeProductCollection(); 

    // $this->_prepareQueryPopularity($collection->getSize()); 

    $toolbar = $this->getToolbarBlock(); 

    $toolbar->setCollection($collection); 

    $size = (int) Mage::getStoreConfig(self::RESULT_SIZE_CONFIG); 
    $collection->setPageSize($size); 
    // $collection->getSelect()->limit($size); 
    $sortOrder = Mage::getStoreConfig(self::SORT_ORDER_PRODUCT); 

    if (0 < count($collection)) { 
     $this->_suggestions[$sortOrder][] = array('html' => 
      '<p class="headercategorysearch">' . $this->__("") . '</p>' 
     ); 
    } 
    if ($isEnabledImage) { 
     $helper = Mage::helper('catalog/image'); 
    } 

    foreach ($collection as $_row) { 

     $_product = Mage::getModel('catalog/product') 
      ->setStoreId($this->getStoreId()) 
      ->load($_row->getId()); 

     $_image = $_srcset = $_description = ''; 

     if ($isEnabledImage) { 
      $_image = (string) $helper->init($_product, 'thumbnail')->resize($imageWidth, $imageHeight); 
      $_srcset = (string) $helper->init($_product, 'thumbnail')->resize($imageWidth * 2, $imageHeight * 2); 
      $_srcset .= ' 2x'; 
     } 
     if ($isEnabledDescription) { 
      $_description = strip_tags($this->_trim(
       $_product->getShortDescription(), 
       $lengthDescription 
      )); 
     } 

     // $store = Mage::app()->getStore(); 
     // $path = Mage::getResourceModel('core/url_rewrite') 
     //  ->getRequestPathByIdPath('product/' . $_product->getId(), $store); 
     // // $url = $store->getBaseUrl($store::URL_TYPE_WEB) . $path; 
     // $url = rtrim(Mage::getUrl($path, array('_store' => $store->getStoreId())), '/'); 
     $url = $_product->getProductUrl(); 
     $this->_suggestions[$sortOrder][] = array(
      'name'  => $_product->getName(), 
      'url'   => $url, 
      'image'  => $_image, 
      'srcset'  => $_srcset, 
      'description' => $_description, 

     ); 
    } 

} 
+0

這是一個完整的文件嗎? – shashi

+0

不,還有更多。但它是非常廣泛的495線。 @shashi –

回答

2

只需在建議陣列加入這一行 '價格'=> $ _product->用getPrice()負責功能

 $this->_suggestions[$sortOrder][] = array(
     'name'  => $_product->getName(), 
     'price'  => $_product->getPrice(), 
     'url'   => $url, 
     'image'  => $_image, 
     'srcset'  => $_srcset, 
     'description' => $_description, 

    ); 
2

您可以使用

$_product->getFinalPrice() 

這裏面_suggestions屬性,但我想也有一個模板或所有這一切輸出有點JS負責的。