[英]Join two tables and put results in grid magento 1.9.x
我正在開發一個帶有平板的自定義模塊,其中包含產品的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'
));
如何加入Magento的藏品? 沒測試過! :d
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.