magento 常用方法集锦

1,获得store的配置变量

2,设置store的配置变量

3,获取Ip地址

[code]
// 返回Ip地址的字符串格式:127.0.0.1
echo Mage::helper('core/http')->getRemoteAddr();
// 返回Ip地址的数值格式:2130706433
echo Mage::helper('core/http')->getRemoteAddr(true);
[/code]

4,Get all websites and stores in Magento

[code]
foreach (Mage::app()->getWebsites() as $website) {
foreach ($website->getGroups() as $group) {
$stores = $group->getStores();
foreach ($stores as $store) {
//$store is a store object
}
}
}
[/code]

5,快捷格式化商品价格

6,格式化时间

7,快捷获取LOGO

8,用户中心菜单增删改

9,添加删除一个系统Attribute

10,Magento获取客户端IP:

11,Magento: Get checkout cart total details | Subtotal/Grandtotal/Discount/Tax:

12,Magento – 获取订单支付信息:

13,获取网站基本信息:

14,获取订单状态:

15,top.link的添加删除:

16,加载某个 attribute:

17,获取某个 attribute 的所有 option:

18, 获取某个 attribute 的所有多语言 label:

19,获取所有的产品属性的 attribute:

20,获取某个 product 的所有 attribute:
注:如果是在collection中获取自定义的attribute,必须加addAttributeToSelect(), 如下:

21,利用静态block

22,获取某个种类的所有 attribute:

23,获取某个 attribute_set 的所有 attribute:

24,获取 attribute 对象 by attribute code

25,get store id

26, product collection

27,数据库操作

28,获取 quote 中的所有的 item

29,获取这个网站所代表的国家的代号(如:FR)

30,获取后台的配置

31,获取当前的时间

32,generate skin url

33,generate select html

34,删除一个product的所有的images

35,获取指定level目录

36,发送邮件

37, get website config

38,用block创建一个template

39,
获取对象的方法: get_class_methods($object)
返回对象的类名: get_class($object)

40,controller 中 添加block

41,在Configuation中添加validate

42, 获取当前的controller

43, can't see load.gif in firefox6
so just remove or comment the id "#loading-mas" about ,it will solve it

44,get attributeSetId by attributeName

45,get attributeSetName by attributeSetId

46,修改数据库结构

CHANGE is_synced is_synced INT(4) NOT NULL");
[/crayon]

47,获取登录的用户信息

48,格式化时间

49,加减日期

50, 打印php调试信息的代码

51,添加面包翘
在 controller中:

52,filter in collection

53,日期过滤

54,判断日期是否有效

55,test code for quote

56,日期的比较

57,delete confirm js

58, 在controller中返回blocl html

59,获取某个action的url

60, 添加customer attribute

61,获取product某个 option的label

62, 格式化某个日期

63,magento中只单独保存某个attribute的方法

64,常用的load

PHP
Mage::getModel('sales/order')->load(); Mage::getModel('customer/customer')->load(); Mage::getModel('catalog/product')->load();
1
2
3
Mage::getModel('sales/order')->load();
Mage::getModel('customer/customer')->load();
Mage::getModel('catalog/product')->load();

转载于:https://www.cnblogs.com/zhengyanbin2016/p/5733296.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值