Magento Credit Memos模型

时间:2014-07-16 15:06:53

标签: magento

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

亲切的问候

2 个答案:

答案 0 :(得分:5)

我把它快速地放在一起。例如,假设你想抓住评论,你可以做这样的事情。

根据订单获取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

希望这有帮助!

答案 1 :(得分:0)

获得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();