自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(38)
  • 收藏
  • 关注

Magento随机生成sales rule的coupon code

在Magento中可以使用SalesRule模块下的Mage_SalesRule_Model_Coupon_Codegenerator类随机生成coupon code。 首选获得code genetator实例,可以调用Mage_SalesRule_Model_Rule的静态方法: [code="php"] $codeGenerator = Mage_SalesRule_Model_Ru...

2013-01-02 22:09:15 266

Magento 后台配置中实现日期选择 (Date picker)

首先,创建一个新的Form Field 类: [code="php"]

2012-12-28 15:07:02 237

获得指定customer 购买的产品数据

获得指定customer 购买的产品信息,如果是configurable的,则取configurable的名字。 [code="php"] $orderedProductsForCustomerData = array(); $orderTable =Mage::getSingleton('core/resource')-...

2011-12-10 20:54:42 184

将缺货产品放在产品列表后面

Rewrite Mage_Catalog_Model_Layer: 加入以下代码: [code="php"]

2011-12-10 20:50:38 150

Mac Lion上安装配置Nginx PHP PHP-FPM

<!--?xml version="1.0" encoding="UTF-8" standalone="no"?--> Install Nginx And PHP-FPM On Mac Lion 安装Nginx 方法1:使用brew. brew install nginx 按提示操作,安装完成后nginx的配置文件在/usr/local/etc/nginx/ngin...

2011-12-10 16:01:08 163

How to customize Magento as CMS system (1.5.0 CE)

Before install: 1. Go to app/etc/modules, edit Mage_All.xml, only set the following modules active. Mage_Core Mage_Eav Mage_Page Mage_Install Mage_Admin Mage_Adminhtml Mage_Cron Mage_Directo...

2011-03-06 22:42:00 145

How to redirect to another url in block or template

In Block class: [code="php"] public function _toHtml(){ Mage::getSingleton('customer/session')->setBeforeAuthUrl($this->getRequest()->getRequestUri()); if (!Mage::getSingleton('customer/se...

2011-02-25 13:47:50 100

Use call back function to proccess Magento large collection

[code="php"] $orders = Mage::getModel('sales/order')->getCollection(); Mage::getSingleton('core/resource_iterator')->walk($orders->getSelect(), array(array($this,'proccessOrder'))); public function...

2011-01-19 12:58:16 105

How to remove unnecessary columns in Magento collection

[code="php"] $orders = Mage::getModel('sales/order')->getCollection(); $orders->getSelect()->reset('columns'); $orders->getSelect()->columns(array('total_amount'=>'sum(grand_total)')); ...

2011-01-19 12:56:44 127

How to calculate currency according to reward points rate in Magento

[code="php"] $rate = Mage::getModel('enterprise_reward/reward_rate'); $rate->fetch(1, Mage::app()->getStore()->getId(),Enterprise_Reward_Model_Reward_Rate::RATE_EXCHANGE_DIRECTION_TO_CURRENCY);...

2011-01-13 18:03:22 163

Magento二次开发的利器:Rewrite

Magento是一个十分优秀的电子商务系统,但是有时候我们需要增加一些新的功能或者修改原有的功能,一般情况下通过自己开发的扩展模块(module)可以满足要求。如果需要修改系统的一些默认行为(如结账,注册等),不提倡直接修改Magento本身模块里的代码(修改后无法升级,因为升级后所做的修改会被升级后的文件覆盖),这时候Magento提供的rewrite机制可以满足我们的要求。 Magent...

2010-12-08 17:15:48 198

增加Magento后台管理功能三:在后台设置(System/Configuration)中加入自定义设置

在模块的etc目录下新建system.xml配置文件,内容如下: [code="xml"] Settings 1 text 500 ...

2010-11-30 16:17:26 243

增加Magento后台管理功能二:开发后台Controller

在模块的controllers目录下创建Adminhtml目录,新建一个Controller类。 [code="php"] class Glamour_CustomerMessage_Adminhtml_MessageController extends Mage_Adminhtml_Controller_Action { //设置当前激活的菜单 protecte...

2010-11-30 16:02:52 215

增加Magento后台管理功能一:在后台管理界面加入菜单

在模块的etc目录下增加adminhtml.xml配置文件,用于加入自定义的菜单项。文件内容如下: [code="xml"] Customer Mess...

2010-11-30 15:47:02 373

Magento在CMS Page中增加用户信息变量

Magento的cms页面和static block页面中可以用一些指示符来得到相应的信息,如{{skin url=".."}} {{media url="..."}}等。 在Mage_Cms_Block_Page类的_toHtml方法中可以找到下面的代码: [code="php"] $helper = Mage::helper('cms'); $processor...

2010-11-26 10:14:51 170

Magento根据不同的浏览器自动切换package或 theme

在后台设置中: System > Configuration > Design 切换Package: 在Package设定里面: 添加 exception: Matched expression: iPhone|iPod Value: (新建的package名字,如mobile, /magento/app/design/frontend/mobile) 如果要自动切...

2010-11-26 10:05:54 153

Magento让后台数据列表中的action列链接在新窗口打开

[code="php"] 'actions' => array( array( 'caption' => Mage::helper('productfaq')->__('Edit'), 'url' => array( ...

2010-11-08 16:56:20 139

Maegen获得后台当前用户的信息

[code="php"] $admin = Mage::getSingleton('admin/session')->getUser(); if($admin){ return $admin->getId(); } [/code] 注意,只在后台相应的类中有效,前台经测试无法获得。...

2010-11-08 16:53:42 161

Magento中用子类替换Block

Step 1:创建一个新的Module Step 2: 编辑模块的config.xml配置文件: [code type="xml"] 0.1.0 Glamour_Glscatalog_Block_Adminhtml_Product_Edit_Tab_Related ...

2010-10-15 10:47:13 199

Magento中添加带有选项的属性

下面的代码为Customer实体添加了性别属性,有两个可选值 Male和Female [code="php"] $installer->startSetup(); $installer->addAttribute('customer', 'gender', array( 'label' => 'Gender', 'visible' =>...

2010-10-14 14:49:06 155

Magento为后台用户保存操作日志(企业版)

[code="PHP"] protected function _logAdminAction($username, $userId, $details) { $eventCode = 'catalog_products'; //可用的event code 参见后台Admin Actions Log中Aciton G...

2010-09-19 17:00:51 346

Magento中通过访问Url把产品加入购物车

Magento中可以通过访问Url把产品加入购物车。 1 添加简单产品(Simple Product) (1) 通过产品id checkout/cart/add?product=[id]&qty=[qty] (2) 通过产品sku $cProd = Mage::getModel('catalog/product'); $id = $cProd->getIdByS...

2010-09-17 17:50:38 194

Magento通过简单产品获得所属的可配置产品

[code="php"] $product = Mage::getModel(‘catalog/product’) ->setStoreId(Mage::app()->getStore()->getId()) ->load($productId); if($product->type_id==“simple”) { $parentId=$product->loadParen...

2010-09-15 17:46:57 163

Magento中为Block启用Cache

在Block类的_construct(不是构造方法)方法中加入以下代码: [code="php"] public function _construct() { $this->addData( array( 'cache_lifetime' => 3600, 'cache_tags' => array(Mage_Catalog_Mod...

2010-09-14 17:12:19 137

Magento中获得Product所有属性的Values和Labels

[code="php"]$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'attribute_id'); foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){ attrubuteArray[$opti...

2010-09-10 18:11:16 140

Magento中获得可配置产品(Configurable)的所有简单产品

[code="java"] if(product->isConfigurable()){ } $allProducts=$product->getTypeInstance(true)->getUsedProducts(null, $product); echo count($allProducts); foreach($allProducts as $simpleProduct){ ...

2010-08-20 17:11:48 284

Magento中获得设置时区的当前时间

Magento中默认时区为GMT, 不能直接使用time(), date()等方法,否则会出现时间差。 用下面的方法取当前时间(和后台设置的时区一致): [code="PHP"]date("Y-m-d", Mage::getModel('core/date')->timestamp(time()));[/code] 获得UTC时间 [code="PHP"] $date = Mag...

2010-08-06 17:07:48 300

Magento中Model和ResourceModel(非EAV)中两个_init方法参数意义

Magento中非EAV Model继承自Mage_Core_Model_Abstract,需要实现_construct方法 [code="PHP"] protected function _construct(){ $this->_init('Model tag 名/ResourceModel tag名'); }[/code] 先通过mod...

2010-08-06 14:27:43 226

原创 Magento重载Controller的方法

重载购物车页 Mage_Checkout_CartController::indexAction(). 第一步:建立相应的文件 app/code/local/MyNameSpace/MyModule/etc/config.xml app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php a...

2010-07-30 14:52:24 157

Magento获得指定客户的所有订单

[code="PHP"] $customerId=客户Id; $limit=10; $orders=Mage::getResourceModel('sales/order_collection'); $orders->addAttributeToFilter('customer_id', $customerId)->getSelect()->order('e.entity_id desc...

2010-07-27 16:25:08 236

Magento模块开发第二部分

4. 创建Block 4.1 Block类 在config.xml中的global段中有下面的block声明: [code="xml"] [/code] 我们加入以下块声明: [code="xml"] Glamour_HelloWorld_Block [/code] 其中,helloworld标签用于调用createBlock方法时传入的参数...

2010-07-27 11:03:54 95

Magento模块开发 第一部分

1.模块配置文件 基本的模块配置文件有2个,一个是etc下面的config.xml, 还有一个在app/etc/modules下面,以YourPackageName_ YourModuleName.xml命名。 Magento里面的模块都属于不同的包(Package), 每个包又分属于不同的代码池中(Code Pool)。Magento 中的 代码池有core, community和local...

2010-07-20 16:51:24 97

原创 使用javamail发送邮件例子

需要的包:mail1.4.3.jar, activation.jar 1 验证类 [code="java"] package util.mail; import javax.mail.Authenticator; import javax.mail.PasswordAuthentication; public class MailAuthenticator extends Au...

2010-01-13 18:01:00 100

原创 ibatis入门

1 ibatis配置文件 [code="xml"] [/code] 2 实体类 [code="java"] package domain; public class Login { private Integer loginId; private String lo...

2010-01-11 18:28:04 81

原创 一个简单MVC模式的实现

简单MVC模式的实现主要由3部分组成,用于初始化的ConfigListener,控制器 Controller和配置文件 mvc_config.xml 1 监听器ConfigListener 主要用于在初始化ServletContext时读入配置文件,并把路径和转发信息储存在attribute中。代码如下: [code="java"] public class ConfigListe...

2009-12-29 17:46:40 139

Java中解决Mysql中文问题的方法总结

通过以下几个步骤(必需): 1 修改my.ini,在[mysqld]和[client]中加入 [code]default-character-set=utf8[/code] 2 创建数据库和表时设置default charset: [code="sql"] CREATE DATABASE IF NOT EXISTS my_db default charset utf8 COLLATE...

2009-12-23 17:15:16 121

Hinernate入门例子

1. 建立项目文件系统结构­ HelloWorld -src­ +lib­ +bin(或者build)­ 所需要的包 -lib antlr-2.7.6.jar dom4j-1.6.1.jar hibernate3.jar javassist-3.9.0.GA.jar ...

2009-12-06 20:28:44 131

原创 Hibernate中Session的使用

对于web app使用 per request per session的方式 配置thread 通过SessionFactory的getCurrentSession()方法,该方法会自动获得与当前线程绑定的Session实例。 注意在Servlet的请求方法中不要使用openSession()方法,因为Sevlet采用多线程处理用户请求,A线程通过openSession()获得一个Sessi...

2009-12-06 20:24:06 97

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除