【问题标题】:Magento Credit Memos ModelMagento 信用备忘录模型
【发布时间】:2014-09-07 04:30:26
【问题描述】:

任何人都可以帮助模型/集合搜索 magento 中的所有贷项通知单而不是订单吗? 我可以使用 Mage::getModel('sales/order') 来获取订单,但看不到贷项通知单

亲切的问候

【问题讨论】:

    标签: magento


    【解决方案1】:

    我很快把它放在一起。例如,假设你想抢 cmets,你可以这样做。

    根据订单获取 CreditMemo 评论

    $incrementId = 100000002;
    $collection = Mage::getResourceModel('sales/order_creditmemo_collection')
                ->addAttributeToFilter('increment_id', $incrementId);
    
    foreach($collection as $item) {
        $creditMessage = Mage::getResourceModel('sales/order_creditmemo_comment_collection')
                       ->addAttributeToFilter('entity_id', $item->getEntityId());
    
        foreach($creditMessage as $message) {
                echo $message->getComment();
        }
    }
    

    您可以使用increment_id 甚至order_id 过滤集合:)

    获取所有评论

    $collection = Mage::getResourceModel('sales/order_creditmemo_comment_collection');
    

    下面是 creditmemo 的表格列表

    sales_flat_creditmemo
    sales_flat_creditmemo_comment
    sales_flat_creditmemo_grid
    sales_flat_creditmemo_item
    

    希望这会有所帮助!

    【讨论】:

    • 我认为通过Mage::getModel('sales/order_creditmemo_comment')->getCollection() 访问集合会更好——您不需要直接访问资源模型
    【解决方案2】:

    获取 Credit Memo 评论集合的正确方法

        $collection = Mage::getResourceModel('sales/order_creditmemo_collection')
                ->addFieldToFilter('order_id', $order->getId()); /* here we have no load memo by order id not increment id.Increment id is the creditmemo increment id not order increment id. */
    
    foreach($collection as $item) {
    
        $creditMessage = Mage::getResourceModel('sales/order_creditmemo_comment_collection')
                       ->addAttributeToFilter('parent_id', $item->getId()); /* here we need to use parent_id not entity_id.*/
    
                       }
                       var_dump($creditMessage->getData());
                       exit();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-01
      • 2011-11-23
      • 1970-01-01
      • 2012-07-09
      • 1970-01-01
      • 2013-12-20
      • 2023-01-17
      相关资源
      最近更新 更多