14

管理グリッド ウィジェットに (ID だけでなく) 製品名を表示するために、カスタム コレクションに製品を結合しようとしています。これまでのところ、正しい構文が見つかりません。

次の方法で、製品名の製品を取得できます。

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

そして、次の方法でカスタム コレクションを取得できます。

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

モジュール コレクションがプライマリ コレクションであり、$model->getId() によって返される ID が引き続きカスタム コレクションの ID になるように、2 つを結合するにはどうすればよいですか?

4

2 に答える 2

3

Just a quick correction I had to add quotes on the table name: array('order_item'=> 'sales_flat_order_item'), Also getSelect() is not necessary as the third argument is the attribute list. Final argument specifies the type of join you would like to use.

My version looked like this:


$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->join(array('order'=> 'sales/order'),'order.entity_id=main_table.entity_id', array('po_number'=>'po_number', 'imi_customer_email' =>'imi_customer_email'), null,'left');
$this->setCollection($collection);`
于 2015-07-08T08:28:03.100 に答える