使用 Magento 将平面表连接到 EAV 表?
我正在尝试创建一个 Adminhtml 网格,它将我制作的名为“facility”的表连接到“customer_entity”及其所有属性。
我注意到,由于我的表是平坦的,并且模型继承了 Mage_Core_Model_Mysql4_Collection_Abstract,因此我无法使用我在后端看到的所有示例的 class_methods。
我已经成功地将我的表连接到 customer_entity 表,执行以下操作:
$collection = Mage::getModel('facility/facility')->getCollection()
->join('customer/entity', 'customer_id = entity_id');
但是,我真正需要的只是获取客户名称。有什么帮助吗?
I am trying to manke an Adminhtml Grid which joins a table that I made called "facility" to "customer_entity" and all of its attribtues.
I'm noticing that since my table is flat, and the model inherits fomr Mage_Core_Model_Mysql4_Collection_Abstract, I'm not able to use all the class_methods that I've seen as examples on the backend.
I've successfully been able to join my table to the customer_entity table doing the following:
$collection = Mage::getModel('facility/facility')->getCollection()
->join('customer/entity', 'customer_id = entity_id');
However, what I really need is just to get the customer name. Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
客户姓名不存储在一个字段中,而是由名字、中间名和姓氏组成;并且根据设置,还有前缀和后缀。客户类别有为您组合这些的方法。
joinTable 方法是 EAV 集合的一部分,这就是为什么您不会在基于 MySQL4 的核心集合中看到它。第一个参数不是文字表名称,而是 config.xml 中描述的实体表。
Customer names are not stored in one field, they are a combination of first, middle and last name; and depending on settings, a prefix and suffix too. The customer classes have methods for combining these for you.
The
joinTable
method is part of EAV collections which is why you won't see it in the core MySQL4 based collections. The first parameter is not a literal table name but an entity table as described in your config.xml.一般来说,我同意 之前的答案,只是对语法
null 部分进行了一些更正,这是一个 WHERE 子句,“正确”是类型加入
或者也许更好的决定是:
Generally I agree with the previous answer just some corrections to the syntax
null part is a WHERE clause and the 'right' is the type of the join
Or maybe a better decision is: