i am trying to display most viewed products on homepage. getting following error.

class Mage_Catalog_Block_Product_Mostviewed extends Mage_Catalog_Block_Product_Abstract {
function __construct() {
    $storeId = Mage::app() - > getStore() - > getId();
    $products = Mage::getResourceModel('reports/product_collection') - > addOrderedQty() - > addAttributeToSelect('*') - > addAttributeToSelect(array('name', 'price', 'small_image')) - > setStoreId($storeId) - > addStoreFilter($storeId) - > addViewsCount();
    Mage::getSingleton('catalog/product_status') - > addVisibleFilterToCollection($products);
    Mage::getSingleton('catalog/product_visibility') - > addVisibleInCatalogFilterToCollection($products);
    $products - > setPageSize(5) - > setCurPage(1);
    $this - > setProductCollection($products);


Fatal error: Class 'Mage_Catalog_Block_Product_Mostviewed' not found in  C:\xampp\htdocs\ifasonx\app\code\core\Mage\Core\Model\Layout.php on line 491

refference:- http://www.magikcommerce.com/blog/how-to-show-most-viewed-best-selling-products-in-magento-store/

1 Answer 1


The error means that the autoloader is failing to load a file containing the class. The most likely cause is probably one of:

  1. There isn't actually a file app/code/local/Mage/Catalog/Block/Product/Mostviewed.php because of a typo in the filename.
  2. The file is there but has incorrect file permissions, meaning the webserver cannot read it.
  3. You have compilation mode enabled. This would require re-compilation after creating the new block class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.