我正在开发一个自定义模块,其中包含一个包含产品 sku 的平面表格。我想在网格中显示 sku 和从目录/产品中获取的名称以及我自己的表中获取的其他信息; 在 Grid.php 中我有:
protected function _prepareCollection()
{
$collection = Mage::getModel('hf/hfdistr')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
如何从目录/产品中获取产品名称并将其与我的表格附加信息合并?任何帮助表示赞赏。 (Magento 1.9.3.2)
最佳答案
你可以这样加入他们
$products = Mage::getSingleton('core/resource')->getTableName('catalog/product');
$collection = Mage::getModel('custom/model')->getCollection();
$collection->getSelect()->join(
array(
'cp'=> $products
),
'cp.sku = main_table.sku',
array(
'cp.sku','cp.other_attribute_other',
'cp.other_attribute_to_select'
));
How to join collections in Magento? 未经测试! :D
关于php - 加入两个表并将结果放入网格 magento 1.9.x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43520499/