未找到“Mage_Catalog_Block_Product_Mostviewed”类[magento]

时间:2016-01-23 14:13:46

标签: magento

我正在尝试在主页上显示最常查看的产品。得到以下错误。

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

致命错误:第491行的C:\ xampp \ htdocs \ ifasonx \ app \ code \ core \ Mage \ Core \ Model \ Layout.php中找不到“Mage_Catalog_Block_Product_Mostviewed”类

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

1 个答案:

答案 0 :(得分:0)

因为你的班级名称错了。 Magento没有名字Mage_Catalog_Block_Product_Mostviewed。也请不要在本地目录下的Mage命名空间错误。请为此开发一个模块然后准备一个块Namespace_Modulename_Block_Mostviewed然后调用其中的函数。 请按照以下流程操作。

http://arabgento.com/en/magento-display-best-selling-products-most-viewed-products-new-products-absolutely-or-by-categories/

然后从phtml或cms中调用块