2014-04-03 17 views

回答

7

在第74行的塊類app/code/core/Mage/Adminhtml/Block/Review/Rating/Detailed.php中,使用硬編碼的商店代碼「default」調用setStoreFilter()當Magento中沒有代碼爲「default」的商店時出現異常,並且在關閉錯誤頁面時將該用戶轉發到404頁面。

要重現該問題,請在Magento中創建第二個商店和相關商店視圖,將「默認」商店代碼更改爲「mystorecode」,然後轉到管理菜單「目錄>評論和評分>顧客評論>所有評論」並按下「添加新評論」按鈕。

所提出的解決方法是如下:

--- a/app/code/core/Mage/Adminhtml/Block/Review/Rating/Detailed.php 
+++ b/app/code/core/Mage/Adminhtml/Block/Review/Rating/Detailed.php 
@@ -68,10 +68,13 @@ class Mage_Adminhtml_Block_Review_Rating_Detailed extends Mage_Adminhtml_Block_T 
        ->addRatingOptions(); 

      } elseif (!$this->getIsIndependentMode()) { 
+    $default_store = Mage::app()->getWebsite()->getDefaultStore(); 
       $ratingCollection = Mage::getModel('rating/rating') 
        ->getResourceCollection() 
        ->addEntityFilter('product') 
-     ->setStoreFilter(Mage::app()->getStore('default')->getId()) 
+     ->setStoreFilter(($default_store) 
+          ? $default_store->getId() 
+          : Mage_Core_Model_App::ADMIN_STORE_ID) 
        ->setPositionOrder() 
        ->load() 
        ->addOptionToItems(); 

只需更換:

    $ratingCollection = Mage::getModel('rating/rating') 
        ->getResourceCollection() 
        ->addEntityFilter('product') 
        ->setStoreFilter(Mage::app()->getStore('default')->getId()) 
        ->setPositionOrder() 
        ->load() 
        ->addOptionToItems(); 

有:

    $default_store = Mage::app()->getWebsite()->getDefaultStore(); 
       $ratingCollection = Mage::getModel('rating/rating') 
        ->getResourceCollection() 
        ->addEntityFilter('product') 
        ->setStoreFilter(($default_store) 
             ? $default_store->getId() 
             : Mage_Core_Model_App::ADMIN_STORE_ID) 
        ->setPositionOrder() 
        ->load() 
        ->addOptionToItems(); 

希望這解決了這個問題。

+0

你是天才! – Alexandros

+0

那麼,我必須將我的默認商店代碼始終設置爲「默認」? – Alexandros

+0

當我試圖保存一個新的審查沒有出現!也許它需要更多的修復? – Alexandros

0

是Magento的團隊解決此問題在新版本中,它們添加以下代碼

->setStoreFilter(Mage::app()->getDefaultStoreView()->getId()) 

,而不是

->setStoreFilter(Mage::app()->getStore('default')->getId()) 

我認爲最好的辦法升級的版本