1

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 {
public
function __construct() {
    parent::__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/

| improve this question | | | | |
2

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.
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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