Magento add most popular products
来源:互联网 发布:软件开发技术服务合同 编辑:程序博客网 时间:2024/05/26 19:17
在magento\app\code\local\Mage\Catalog\Block\Product 创建一个文件名为 MostPopular.php 的文件
<?phpclass Mage_Catalog_Block_Product_MostPopular extends Mage_Catalog_Block_Product_Abstract{public function __construct(){parent::__construct(); $storeId = Mage::app()->getStore()->getId(); $products = Mage::getResourceModel('reports/product_collection')//->addAttributeToSelect('*')->addAttributeToSelect(array('name', 'price', 'small_image', 'short_description', 'description'))->setStoreId($storeId)->addStoreFilter($storeId)->addViewsCount(); Mage::getSingleton(‘catalog/product_status’)->addVisibleFilterToCollection($products);Mage::getSingleton(‘catalog/product_visibility’)->addVisibleInCatalogFilterToCollection($products); //$products->setPageSize(6)->setCurPage(1); $this->setProductCollection($products);}}
在magento\app\design\frontend\bagstore\default\template\catalog\product 创建一个文件名为MostPopular.phtml的文件
在同一个文件夹内查找new.phtml 并复制代码到 MostPopular.phtml 内。
在任何phtml位置用
<?php echo $this->getLayout()->createBlock(‘catalog/product_MostPopular’)->setTemplate(‘catalog/product/MostPopular.phtml’)->toHtml();?>
输出
或在xhtml中用
<block type=”catalog/product_MostPopular” template=”catalog/product/MostPopular.phtml” />
输出到想要的位置。
- Magento add most popular products
- [Magento] Add downloadable products
- Bestseller products in Magento
- most popular site
- Popular Gucci products exclusively for charming girl
- magento -- 推荐插件 -- Featured Products
- How to Import Products into Magento
- How to import products into Magento?
- Magento 修改首页 New Products 列数
- 10 Most Popular Misconceptions about Exploratory Testing
- Electronics Among Most Popular Gifts This Year
- Most popular sites for Chinese programmer
- The Most Popular Java API Classes 地址
- The most popular color of balloon
- The Most Popular Java API Classes
- Add Highslide to Magento
- magento add admin account
- magento导入导出Custom Options, Tier Prices and Grouped Products
- 构造函数和析构函数
- 什么是RS-485接口?它比RS-232-C接口相比有何特点?
- asterisk sip codec协商
- 我国户外登山运动事故频发 10年内有220人遇难-户外登山-事故-遇难
- SQL中IN和EXISTS用法的区别
- Magento add most popular products
- linux shell until语句详解
- 多线程下,生产者消费者锁的优化问题
- 获取本月的第一天和最后一天
- /proc/$PID/status
- XP中“登录失败:未授予用户在此计算机上的请求登录类型”的解决办法
- 栈与堆的区别
- 推荐12个非常不错而且免费的后台管理HTML模板
- 系统编程之进程通信 共享内存