分类 Code 下的文章

gzip压缩需要 deflate_module和headers_module的支持;系统默认就是开启的;
还需要开启 LoadModule deflate_module modules/mod_deflate.so
否则报错
AH00526: Syntax error on line 521 of /alidata/server/httpd/conf/httpd.conf:
Unknown filter provider DEFLATE
http.conf 里添加下面的配置


     AddOutputFilterByType DEFLATE text/plain
     AddOutputFilterByType DEFLATE text/css
     AddOutputFilterByType DEFLATE application/xml
     AddOutputFilterByType DEFLATE application/rss+xml
     AddOutputFilterByType DEFLATE application/atom_xml
     AddOutputFilterByType DEFLATE application/x-javascript
     AddOutputFilterByType DEFLATE application/x-httpd-php
     AddOutputFilterByType DEFLATE text/html

重启apache
http://tool.chinaz.com/Gzips测试一下
看网上还有一种办法适用于不能随便重启apache的生产环境


 
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
 
    # Insert filter on all content
    ###SetOutputFilter DEFLATE
    # Insert filter on selected content types only
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
    DeflateCompressionLevel 9
    SetOutputFilter DEFLATE
 
    # Netscape 4.x has some problems...
    #BrowserMatch ^Mozilla/4 gzip-only-text/html
 
    # Netscape 4.06-4.08 have some more problems
    #BrowserMatch ^Mozilla/4\.0[678] no-gzip
 
    # MSIE masquerades as Netscape, but it is fine
    #BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 
    # Don't compress images
    #SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
 
    # Make sure proxies don't deliver the wrong content
    #Header append Vary User-Agent env=!dont-vary
 

magento订单状态流程:

1. 新订单

state : new
status : pending

2. 配送后
state : processing
status : processing

3. 收款后
state : processing
status : processing

4. 订单完成
state : complete
status : complete

5. 订单取消
state : canceled
status : canceled

6. 订单关闭
state : closed
status : closed

7. 订单挂起
state : holded
status : holded

先整理一下,后面在更新

网上这篇文章很多了,当是转载一下,留个备份。
通过这个实例可以学到很多有关Magento的知识。

<?php 
require_once 'app/Mage.php'; 
Mage::app('default'); //初始化程序,设置当前店铺 
$store = Mage::app()->getStore('default');

//通过电子邮件获取用户,当然也可以不获取,创建guest订单
$customer = Mage::getModel('customer/customer');
$customer->setStore($store);
$customer->loadByEmail('[email protected]');

//初始化Quote,Magento的订单是通过Quote来转化过去的
$quote = Mage::getModel('sales/quote');
$quote->setStore($store);
$quote->assignCustomer($customer); //如果有用户则执行这个

$product1 = Mage::getModel('catalog/product')->load(166); /* HTC Touch Diamond */
$buyInfo1 = array('qty' => 1);

$product2 = Mage::getModel('catalog/product')->load(18); /* Sony Ericsson W810i */
$buyInfo2 = array('qty' => 3);

//添加商品到Quote
$quote->addProduct($product1, new Varien_Object($buyInfo1));
$quote->addProduct($product2, new Varien_Object($buyInfo2));

//设置账单和收货品地址
$billingAddress = $quote->getBillingAddress()->addData($customer->getPrimaryBillingAddress());
$shippingAddress = $quote->getShippingAddress()->addData($customer->getPrimaryShippingAddress());

//设置配送和支付方式
$shippingAddress->setCollectShippingRates(true)->collectShippingRates()->setShippingMethod('flatrate_flatrate')->setPaymentMethod('checkmo');
$quote->getPayment()->importData(array('method' => 'checkmo'));

//Quote计算运费
$quote->collectTotals()->save();

//将Quote转化为订单
$service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();
$order = $service->getOrder();

/***至此订单已经成功生成,下面是注册付款信息***/
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
$invoice->register();
$transaction = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());

20121201_161916_734.png

SublimeText也用了一段时间了,用的最爽的大概就是自动提示、各种快捷键了,不愧最风骚的编辑器的称号,哈哈~

Ctrl+L 选择整行(按住-继续选择下行)
Ctrl+KK 从光标处删除至行尾
Ctrl+Shift+K 删除整行
Ctrl+Shift+D 复制光标所在整行,插入在该行之前
Ctrl+J 合并行(已选择需要合并的多行时)
Ctrl+KU 改为大写
Ctrl+KL 改为小写
Ctrl+D 选词 (按住-继续选择下个相同的字符串)
Ctrl+M 光标移动至括号内开始或结束的位置
Ctrl+Shift+M 选择括号内的内容(按住-继续选择父括号)
Ctrl+/ 注释整行(如已选择内容,同“Ctrl+Shift+/”效果)
Ctrl+Shift+/ 注释已选择内容
Ctrl+Z 撤销
Ctrl+Y 恢复撤销
Ctrl+M 光标跳至对应的括号
Alt+. 闭合当前标签
Ctrl+Shift+A 选择光标位置父标签对儿
Ctrl+Shift+[ 折叠代码
Ctrl+Shift+] 展开代码
Ctrl+KT 折叠属性
Ctrl+K0 展开所有
Ctrl+U 软撤销
Ctrl+T 词互换
Tab 缩进 自动完成
Shift+Tab 去除缩进
Ctrl+Shift+↑ 与上行互换
Ctrl+Shift+↓ 与下行互换
Ctrl+K Backspace 从光标处删除至行首
Ctrl+Enter 光标后插入行
Ctrl+Shift+Enter 光标前插入行
Ctrl+F2 设置书签
F2 下一个书签
Shift+F2 上一个书签

Mysql开启远程连接

1、进入mysql,创建一个新用户root,密码为root:

格式:grant 权限 on 数据库名.表名 to 用户@登录主机 identified by "用户密码";

grant select,update,insert,delete on *.* to [email protected] identified by "root";

原先数据表结构

mysql> use mysql;
Database changed
mysql> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------+------+-------------------------------------------+

执行上述语句后结果

mysql> use mysql;
Database changed
mysql> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host | user | password |
+--------------+------+-------------------------------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 192.168.1.12 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+--------------+------+-------------------------------------------+
2 rows in set (0.00 sec)

可以看到在user表中已有刚才创建的root用户。host字段表示登录的主机,其值可以用IP,也可用主机名,

(1)有时想用本地IP登录,那么可以将以上的Host值改为自己的Ip即可。

2、实现远程连接(授权法)

将host字段的值改为%就表示在任何客户端机器上能以root用户登录到mysql服务器,建议在开发时设为%。

update user set host = ’%’ where user = ’root’;

将权限改为ALL PRIVILEGES

mysql> use mysql;
Database changed
mysql> grant all privileges on *.* to root@'%' identified by "root";
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host | user | password |
+--------------+------+-------------------------------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 192.168.1.12 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| % | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+--------------+------+-------------------------------------------+
3 rows in set (0.00 sec)

这样机器就可以以用户名root密码root远程访问该机器上的MySql.

3、实现远程连接(改表法)

use mysql;

update user set host = '%' where user = 'root';

这样在远端就可以通过root用户访问Mysql.