脚本宝典收集整理的这篇文章主要介绍了php – 出口订单从Magento出货,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
预先感谢您的帮助,
安迪
如果你真的想要一个CSV文件,我可以告诉你如何创建它.你没有提到这个脚本将在哪里运行,所以我会假设它是一个外部脚本(这将使它更容易与cron作业一起使用).
您要执行以下操作:
//External script - Load magento framework require_once("C:\PRogram Files\apache Software Foundation\Apache2.2\htdocs\magento\app\Mage.PHP"); Mage::app('default'); $myOrder=Mage::getModel('sales/order'); $orders=Mage::getModel('sales/MysqL4_order_collection'); //Optional filters you might want to use - more available operations in method _getCondITionsql in VARien_Data_Collection_Db. $orders->adDFieldToFilter('total_paid',Array('gt'=>0)); //Amount paid larger than 0 $orders->addFieldToFilter('status',Array('eq'=>"processing")); //Status is "processing" $allIds=$orders->getAllIds(); foreach($allIds as $thisId) { $myOrder->reset()->load($thisId); //echo "<pre>"; //print_r($myOrder); //echo "</pre>"; //Some random fields echo "'" . $myOrder->getBillingAddress()->getLastname() . "',"; echo "'" . $myOrder->getTotal_paid() . "',"; echo "'" . $myOrder->getShippingAddress()->getTelephone() . "',"; echo "'" . $myOrder->getPayment()->getCc_tyPE() . "',"; echo "'" . $myOrder->getStatus() . "',"; echo "\r\n"; }
为了简洁起见(和理智),我没有列出所有可用的订单信息.您可以通过倾销相关对象并查看其字段来了解可用的字段.
例如,如果你要做print_r($myOrder-> getBillingAddress());你会看到像“address_type”和“lastname”这样的字段.你可以使用这些
$myOrder-> getBillingAddress() – > getAddress_type()和
$myOrder-> getBillingAddress() – > getLastname().
编辑:根据craig.michael.morris的答案更改代码
以上是脚本宝典为你收集整理的php – 出口订单从Magento出货全部内容,希望文章能够帮你解决php – 出口订单从Magento出货所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。