Magento:getVisibleStatusHistory()输出未正确排序
我在下面有一个代码(简化),用于在客户帐户->订单->查看(订单详细信息)中向当前订单添加注释 代码运行良好。唯一的问题是,在处理表单发送的注释并调用Magento:getVisibleStatusHistory()输出未正确排序,magento,sorting,comments,Magento,Sorting,Comments,我在下面有一个代码(简化),用于在客户帐户->订单->查看(订单详细信息)中向当前订单添加注释 代码运行良好。唯一的问题是,在处理表单发送的注释并调用getVisibleStatusHistory()后,除了客户最近添加的注释外,所有注释都按日期/时间(降序)正确排序。该注释被添加为结果中的最后一条注释-这与getVisibleStatusHistory()结果的降序排序不一致。重新加载页面后,页面已正确排序 所有代码都在customized view.phtml中 我有一个表格发送评论: &l
getVisibleStatusHistory()
后,除了客户最近添加的注释外,所有注释都按日期/时间(降序)正确排序。该注释被添加为结果中的最后一条注释-这与getVisibleStatusHistory()
结果的降序排序不一致。重新加载页面后,页面已正确排序
所有代码都在customized view.phtml中
我有一个表格发送评论:
<form action="" method="post">
<textarea name="ordercomment" maxlength="1000"></textarea>
<input type="submit" value="Send" />
</form>
在该脚本之后,打印所有可见的注释:
<?php $_history = $this->getOrder()->getVisibleStatusHistory() ?>
<?php if (count($_history)): ?>
<div class="order-additional order-comments">
<h2 class="sub-title"><?php echo $this->__('About Your Order') ?></h2>
<dl class="order-about">
<?php foreach ($_history as $_historyItem): ?>
<dt><?php echo $this->formatDate($_historyItem->getCreatedAtStoreDate(), 'medium', true) ?></dt>
<dd><?php echo $this->escapeHtml($_historyItem->getComment()) ?></dd>
<?php endforeach; ?>
</dl>
</div>
<?php endif; ?>
有人知道原因是什么吗?上次添加的注释在其他注释中没有正确排序?这种奇怪排序的原因是,当您向订单的状态历史记录集合添加新的历史记录项时,订单加载现有集合(已排序),并将新项添加到其末尾 要正确输出集合,您可以重新加载order对象,然后以正确的顺序获取历史集合:
<?php
$orderNew = Mage::getModel('sales/order')->load($this->getOrder()->getId());
$_history = $orderNew->getVisibleStatusHistory() ?>
这种奇怪排序的原因是,当您将新的历史记录项添加到订单的状态历史记录集合时,订单将加载现有集合(已排序),并将新项添加到其末尾 要正确输出集合,您可以重新加载order对象,然后以正确的顺序获取历史集合:
<?php
$orderNew = Mage::getModel('sales/order')->load($this->getOrder()->getId());
$_history = $orderNew->getVisibleStatusHistory() ?>
非常感谢!很好!谢谢!很好!