如何加入收藏在Magento? [英] How to join collections in Magento?

查看:144
本文介绍了如何加入收藏在Magento?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图加入一个自定义集合与产品在管理网格窗口小部件中显示产品名称(不只是id)。到目前为止,我找不到正确的语法。

I am trying to join a custom collection with products to show the product name (not just the id) in the admin grid widget. So far i can't find the correct syntax.

我可以通过以下方法检索产品名称:

I am able to retrieve the products with the product name by the following:


Mage :: getModel('catalog / product') - > getCollection() - > addAttributeToSelect('name');

Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('name');

,我可以使用以下方式检索我的自定义集合:

and i can retrieve my custom collection with:


Mage :: getResourceModel('xyz_mymodule / model_collection');

Mage::getResourceModel('xyz_mymodule/model_collection');

如何连接这两个模块是主集合,$ model-> getId()返回的id仍然是我的自定义集合的id?

How do i join the two so that the module collection is the primary collection and the id as returned by $model->getId() is still the id of my custom collection?

推荐答案

这里有一个工作示例:

$collection = Mage::getModel('sales/order')->getCollection();
$collection->getSelect()->join( array('order_item'=> sales_flat_order_item), 'order_item.order_id = main_table.entity_id', array('order_item.sku'));

问候,希望有所帮助。

这篇关于如何加入收藏在Magento?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆