Magento Grid collection联表查询添加字段
来源:互联网 发布:手机网络老是连接超时 编辑:程序博客网 时间:2024/06/05 02:30
下面这个是我在做对后端显示用户客户端登陆源显示时遇到的,是后端Grid列表中的:
我的系统文件中自己建立的文件中Fun->Token->Model->Observer.php 可以通过文件中的generteToken方法得到相关的手机接口请求头信息,包括:Customer,device_id,Language,Platform等信息。
$old_token = $observer->getEvent()->getToken();$old_customer_id = Mage::helper('token')->getCustomerId($old_token);
$old_token
得到的是用户的ID的加密信息,而$old_customer_id
可以将加密的用户ID解密
$mobileInfo = Mage::getModel('fun_customer/mobileinfo')->load($device_id, 'device_id');$customer_device = Mage::getModel('fun_customer/mobileinfo')->load($customer->getId(), 'customer_id');
$mobileInfo
是通过数据库中字段device_id
,对应的$device_id
的值来查询对应行的数据。 $customer_device
是通过数据库中字段customer_id
,对应的$customer->getId()
的值来查询对应行的数据。
联表查询相关样例及解析:
$collection = Mage::getResourceModel('customer/customer_collection');$collection -> getSelect()-> joinLeft(array("info"=>'customer_mobile_info'), 'e.entity_id = info.customer_id',array( "info.platform"));
所打印出来的数据库语句是:SELECT e.*, info.platform FROM customer_entity AS e LEFT JOIN customer_mobile_info AS info ON e.entity_id = info.customer_id WHERE (e.entity_type_id = ‘1’) 意思是联表查询将customer_mobile_info 中的platform字段添加到customer_entity数据表中,并将platform的数据也联表到customer_mobile_info 中
而在Grid中添加这个字段的渲染器,代码如下:
$this->addColumn('platform', array( 'header'=> Mage::helper('customer')->__('Platform'), 'width' => '80px', 'type' => 'text', 'index' => 'platform', 'filter_index'=>'info.platform', ));
阅读全文
0 0
- Magento Grid collection联表查询添加字段
- magento grid collection 多表查询字段冲突的解决
- magento添加客户自定义字段
- magento 添加会员注册字段
- magento collection
- Magento - Contact Form 添加自定义字段
- Magento后台表单字段添加备注
- magento product 添加新的字段
- sql server 添加、查询 字段、表注释
- SQL添加删除、查询表、字段说明
- select All ------grid控件----magento后台查询所有信息
- magento 后台订单grid表获取shipping_description
- jqgrid主从表查询+添加grid按钮+查询框的“X”取消+查询框去掉
- sqlserver添加查询 表、字段注释(转)
- Magento collection filters
- Ext grid 超级强大的动态添加字段、列扩展
- Extjs grid中某一行字段中添加Checkbox
- Grid 表是字段宽度单位?
- 7、@SessionAttributes——模型数据
- python3 读文件的问题
- 计算买书应付的费用
- YUM
- [推荐] Minds + Machines 2017 回顾: 数字化产业转型以Minds + Machines为中心
- Magento Grid collection联表查询添加字段
- 文章标题
- Composer 设置国内镜像加速命令
- 使用JDBC对MySQL数据库进行增、删、改、查等操作
- react developer tools插件下载、安装
- noip2017滚粗记
- Python搭建tensorflow三层神经网络
- FastDFS 搭建图片服务器
- SQL必知必会学习笔记_1、2课