5

我有两个自定义模型(“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');

..但我确定这是错误的方式。

有什么帮助吗?

4

1 回答 1

0

如果您仍想使用 DDL,则必须进行 Join 并在此之后应用过滤器......您不能加入 2 个过滤的集合来生成 1 个集合

于 2014-03-06T20:06:58.533 回答