2016-01-23 61 views
0

我正在嘗試在主頁上顯示最受歡迎的產品。獲得跟隨錯誤。找不到類'Mage_Catalog_Block_Product_Mostviewed'[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); 
    } 
} 

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/

回答

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

調用該塊