Question

Magento Enterprise Edition, version 1.13.1.0

Unable to add a new product review via admin screens. When "Add new Review" button is clicked in Admin, menu Catalog : Reviews and Ratings : Customer Reviews : All Reviews, and exception is generated in Magento and the 404 page is then shown.

This is a clean Magento installation, with no customisations.

Any idea on how to fix this?

Was it helpful?

Solution

The block class app/code/core/Mage/Adminhtml/Block/Review/Rating/Detailed.php, at line 74 calls the setStoreFilter(), using a hard-coded store code "default", which generates an exception when there are no stores in Magento with code "default", and when error pages are switched off, forwards the admin user to 404 page.

To reproduce the problem, create a second store and related store view in Magento, change the "default" store code to "mystorecode", then go to Admin menu "Catalog > Reviews and Ratings > Customer Reviews > All Reviews" and press the "Add New Review" button.

The proposed fix is the following:

--- 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();

simply replace:

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

with:

                 $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();

Hope this solves the problem.

OTHER TIPS

that Magento team fix this issue in the newer version , they add this code

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

instead of

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

i think the best idea to upgrade the version

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top