Magento-在magento之外的Cronjob更新装运状态 [英] Magento - Cronjob outside magento to update shipment status

查看:46
本文介绍了Magento-在magento之外的Cronjob更新装运状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用magento框架之外的脚本,将对脚本进行编程以获取所有发货和跟踪号.

获得这些货运和跟踪编号后,我将与货运提供商联系,并根据其是否已派遣/扫描或交付来更新货运和订单的状态.

下面是完成一半的代码,我被困住了,

请帮助

感谢和问候, 索拉比(Suurabh)

解决方案

为订单创建装运和发票后,其状态将设置为完成".不确定要在此处进行哪些更改,但是如果在magento安装中设置了一些自定义状态,则可以使用订单类的 setStatus()方法.

$myShipment->getOrder()->setStatus("YourCustomStatus");

我不认为货件具有状态,但是您可以通过调用 addComment($ comment,$ notifyCustomer)给货件添加注释,其中第一个变量是字符串,第二个变量是bool.

$myShipment->addComment("01/01/2010 06:55, Out for delivery", true);

您还可以使用类似的方法在订单中添加评论:

$myShipment->getOrder()->addComment("01/01/2010 06:55, Out for delivery", true);

I am working on a script which is out of magento framework and will be programmed to get all shipments and tracking number.

After getting these shipments and tracking number i will check with shipping provider and update the status of shipment and order based on if its dispatched / scanned or delivered.

following is half done code and I am stuck,

<?php
    require_once 'app/Mage.php';
    Mage::app('default');

$myShipment=Mage::getModel('sales/order_shipment'); 
$shipment=Mage::getResourceModel('sales/order_shipment_collection')
    ->addAttributeToSelect('*');

$allIds=$shipment->getAllIds();
foreach($allIds as $thisId) {
    $myShipment->load($thisId)->getAllTrackings();
    echo "<pre>";
    print_r($myShipment);
    echo "</pre>";

}

Please help,

Thanks and Regards, Saurabh

解决方案

Once shipment and invoice are created for an order it is set to a status of "Complete". Not sure what you want to change there, but if you have some custom statuses set up in your magento installation you can use the setStatus() method of the order class.

$myShipment->getOrder()->setStatus("YourCustomStatus");

I don't think shipments have statuses, but you can add a comment to a shipment by calling addComment($comment, $notifyCustomer), where first variable is a string and second is bool.

$myShipment->addComment("01/01/2010 06:55, Out for delivery", true);

You can also add a comment to the order using a similar method:

$myShipment->getOrder()->addComment("01/01/2010 06:55, Out for delivery", true);

这篇关于Magento-在magento之外的Cronjob更新装运状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆