我有两个自定义模型(“myorder”和“myarticle”)。每个“ myarticle
”都有一个rif_ord_app
指向相关myorder
“字段”的外键“ rif_ordine_vsp
”。我需要过滤这两个集合,然后使用两个字段“ rif_ord_app
”和“ rif_ordine_vsp
”加入它们。
例如:
我过滤“myorders”集合:
$collection_orders = Mage::getModel('mycomp_logistic/myorder')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('customer_id', array('in' => array_values($arrayCustomersId)))
->addAttributeToFilter('payment_done_online', array('eq' => ($filter['is_from_where'] == 'from_web')))
->addAttributeToFilter('pdv_ritiro_id', array('eq' => $filter['pdv_ritiro_code']))
->addAttributeToFilter('pdv_ordinante_id', array('eq' => $filter['pdv_ordinante_code']))
->addAttributeToFilter('rif_ordine_vsp', array('eq' => $filter['num_ord']))
->addAttributeToFilter('data_ordine', array('from' => $daydate));
...然后我过滤“myarticle”集合:
$collection_articles = Mage::getModel('mycomp_logistic/myarticle')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('num_bolla', array('eq' => $filter['cod_bolla']))
->addAttributeToFilter('sscc', array('eq' => $filter['sscc']))
->addAttributeToFilter('stato', array('eq' => $filter['st_art']));
..最后...我没能加入这两个系列。
我试过这样的事情:
$tbl_order = Mage::getSingleton('core/resource')->getTableName('mycomp_logistic/myorder');
$collection_articles = $collection_articles->getSelect()->join(array('t2' => $tbl_order), 'main_table.rif_ord_app = t2.rif_ordine_vsp', 't2.rif_ordine_vsp');
..但我确定这是错误的方式。
有什么帮助吗?