magento 每日新品展示
来源:互联网 发布:淘宝属于b2c还是c2c 编辑:程序博客网 时间:2024/04/28 14:51
1、创建Newarrivals.php文件:
<?php/** * This is the part of 'BmProducts' module for Magento, * which allows easy access to product collection * with flexible filters */class Bestmagento_BmProducts_Block_Product_Newarrivals extends Mage_Catalog_Block_Product_List{function get_prod_count(){//unset any saved limitsMage::getSingleton('catalog/session')->unsLimitPage();return (isset($_REQUEST['limit'])) ? intval($_REQUEST['limit']) : 48;}function get_cur_page(){return (isset($_REQUEST['p'])) ? intval($_REQUEST['p']) : 1;}/*** Retrieve loaded category collection ** @return Mage_Eav_Model_Entity_Collection_Abstract**/protected function _getProductCollection(){$date = $_GET['date'];$collection = Mage::getResourceModel('catalog/product_collection');$collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());$collection = $this->_addProductAttributesAndPrices($collection)->addAttributeToSelect('created_at')->setOrder('created_at', 'desc')->setPageSize($this->get_prod_count())->setCurPage($this->get_cur_page());if(!empty($date)){$this->_data['title'] = $date;$collection->getSelect()->where('DATE(created_at) = ?',$date);}$this->setProductCollection($collection);return $collection;}}
2、后台CMS列表添加Page页,设置Design内容为:
<reference name="content"> <block type="bmproducts/product_newarrivals" name="product_new" template="catalog/product/list.phtml"> <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml"> <block type="page/html_pager" name="product_list_toolbar_pager" /> <action method="setDefaultGridPerPage"><limit>48</limit></action> <action method="addPagerLimit"><mode>grid</mode><limit>48</limit></action> </block> <action method="setToolbarBlockName"><name>product_list_toolbar</name></action> </block></reference>
不带分页可以只设置Content项为:
{{block type="bmproducts/product_newarrivals" name="newarrivals" title="New Arrivals" template="catalog/product/list.phtml"}}
3、在要显示目录的地方加如下代码:
<div class="support_left"><div class="subitem"><div class="title">New Arrivals</div><?php$collection = Mage::getModel('catalog/product')->getResourceCollection()->setOrder('created_at', 'desc');$collection->getSelect()->group('CAST(created_at as date)');//$collection->getSelect()->group('CAST(created_at as date)')->limit(5);//echo $collection->getSelect();exit;$date = array();foreach($collection as $val){?><div class="left_link"><a href="/new_arrivals?date=<?php echo date("Y-m-d",strtotime($val['created_at'])); ?>" rel="nofollow"><?php echo date("Y-m-d",strtotime($val['created_at'])); ?></a></div><?php}?></div></div>
- magento 每日新品展示
- ecshop 每日新品展示
- magento带有分页功能的新品插件
- Magento调用New Arrivals 新品上架产品实例
- [MES]每日新品自动维护批号规则与条码规则
- 【AI每日播报】科大讯飞新品发布 MXNet携手亚马逊AWS
- magento前台展示product的各种信息
- 每日产品辣评:谷歌连发五款新品,却还是被苹果抢了头条
- Magento
- magento
- 每日
- iPod出新品啦
- 产品策划新品上市
- 2010年末新品
- 数据库性能、集群,新品
- 盛夏新品,增值销售
- “拿破仑新品蛋糕,
- 云产品新品发布
- Java异常抛出时的规定
- C++实例 单文件创建
- App 申请时In App Purchase注意事项
- 在c# WinForm程序中关闭程序的同时停止BackgroundWork
- MFC应用程序设计(第二版)学习笔记
- magento 每日新品展示
- 移动网页设计规范(适应手机屏幕大小)
- linux下mysql配置文件my.cnf详解
- ARM中LDR B BX BL BLX指令的研究
- c# winform程序在WebBrowser控件中执行javascript脚本
- Linux--- 多线程
- C语言实现写入日志文件
- android4.0上, baidu map 不能自动刷新问题
- STM32F2系列之USART学习