更改订单时更改订单日期

时间:2015-06-30 11:17:13

标签: magento

我希望有人能够解决一个需要我们大量体力劳动的问题,解决方案似乎很简单: - )

要点: 是否可以更改编辑订单(已开票或尚未开票)时未编辑订单的订单日期和时间,但它使用原始订单的订单日期和时间的代码?

示例:

  • 订单1000于2015年5月15日在12:00
  • 放置
  • 订单1000于2015年5月25日14:00编辑,新订单ID为1000-1
  • 我们将信用或取消订单1000,具体取决于发票状态
  • 标准Magento将在订购日期25/05/2015 14:00
  • 下订单1000-1

但我们希望订购1000-1以获得15/05/2015 12:00的订单日期,与原始订单1000相同。

说明: 我们使用Magento Extension(嵌入式ERP),它使用产品预订。如果客户订购产品,则不会从库存中移除该商品,而是预留库存。如果该商品延期交货,则客户将被排入队列。

系统使用先进先出系统。它使用订单日期来检查哪个客户的队列高于其他客户。

因为我们使用延期交货,客户有时会喜欢添加或删除要订购的商品,因为他们无论如何都要等待商品。但是,当更改订单以添加或删除项目时,新订单将获得新的订单日期和时间。我们希望客户拥有与原始订单相同的产品预订。所以现在我们手动更改每个项目的产品预订,使其与原始订单相同。

我希望当新订单与原始订单的订单日期和时间相同时,我们可以自动完成新订单的正确产品预订。

1 个答案:

答案 0 :(得分:0)

将文件 app / code / core / Mage / Adminhtml / Model / Sales / Order / Create.php 复制到 app / code / local / Mage / Adminhtml / Model / Sales /为了/ 即可。保持文件夹结构不变!

找到选项 createOrder()并更改此

if ($this->getSession()->getOrder()->getId()) {
            $oldOrder = $this->getSession()->getOrder();

            $this->getSession()->getOrder()->setRelationChildId($order->getId());
            $this->getSession()->getOrder()->setRelationChildRealId($order->getIncrementId());
            $this->getSession()->getOrder()->cancel()
                ->save();
            $order->save();
        }

用这个:

if ($this->getSession()->getOrder()->getId()) {
            $oldOrder = $this->getSession()->getOrder();

            $this->getSession()->getOrder()->setRelationChildId($order->getId());
            $this->getSession()->getOrder()->setRelationChildRealId($order->getIncrementId());
            $this->getSession()->getOrder()->cancel()
                ->save();
            $order->setCreatedAt($oldOrder->getCreatedAt());
            $order->save();
        }
相关问题