且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

magento连接表集合

更新时间:2023-11-30 10:14:04

getSelect()join()返回的类型是选择对象,而不是addStoreFilter()addIsActiveFilter()所属的集合.选择部分需要出现在链的后面:

The returned type from getSelect() and join() is a select object, not the collection that addStoreFilter() and addIsActiveFilter() belong to. The select part needs to occur later in the chain:

$collection = Mage :: getModel('flagbit_faq/faq')->getCollection() 
              ->addStoreFilter(Mage :: app()->getStore())
              ->addIsActiveFilter();
// Cannot append getSelect right here because $collection will not be a collection
$collection->getSelect()
           ->join(array('t2' => $tbl_faq_item),'main_table.faq_id = t2.faq_id','t2.category_id');