我工作上的一个在线商店在世的平台,并击中一个主要障碍:由于某些原因 我无法弄清楚如何出口目前的订单(与航运信息/装运类型/等)。 没有任何人有任何建议?这似乎是,如果它应该是一个最基本的东西,对于一个体系这样做,但我没有能够找出如何。

谢谢你提前对你有所帮助,

安迪

有帮助吗?

解决方案

看到您希望这个用于发货,您可能想询问处理您的运输的人是否有某种API,这样您就可以构建/购买/下载适当的运输模块,并免除了使用CSV文件的麻烦。

如果你真的想要一个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-&gt; getBillingAddress());你会看到像“address_type”这样的字段和“姓氏”。你可以用它们 $ myOrder-&gt; getBillingAddress() - &gt; getAddress_type()和 $ myOrder-&gt; getBillingAddress() - &gt; getLastname()。

修改: 根据craig.michael.morris的回答更改了代码

其他提示

我正在实施您的解决方案,并注意到它只返回所有外键的第一个值,如帐单邮寄地址,送货地址,付款等...

这可以通过更改

来解决

$ myOrder-&GT;负载($ thisId);

$ myOrder-&GT;复位() - &GT;负载($ thisId);

你也可能想看看这个扩展: http://www.magentocommerce.com/extension/1158/manual-order-export

你也可以通过肥皂:这个例子是设立"localhost"和假设你已经设置了一个网服务的用户和作用在系统>>网服务的管理。

    <?php 
$time = microtime(); 
$time = explode(' ', $time); 
$time = $time[1] + $time[0]; 
$begintime = $time; 
?> 
<?php 
ini_set('error_reporting', E_ALL); 
ini_set('display_errors', 1); 
// hostname 
$host= '127.0.0.1'; 
// if store in /magento change /shop, if store in root remove /shop 
$client= new SoapClient('http://'.$host.'/magento/index.php/api/soap/?wsdl'); 

// Can be added in Magento-Admin -> Web Services with role set to admin 
$apiuser= 'soap'; 
// API key is password 
$apikey = '******'; 
$sess_id= $client->login($apiuser, $apikey); 
echo "<html>"; 
echo "<head>"; 
echo "<LINK REL=StyleSheet HREF=\"style.css\" TYPE=\"text/css\" MEDIA=screen>"; 
echo "</head>"; 
echo "<body>";

$result= $client->call($sess_id, 'sales_order.list',  array(array('status'=>array('='=>'Pending'))));
echo '<pre>';
print_r($result);
echo '<pre>';


?> 
<?php 
// Let's see how long this took… 
$time = microtime(); 
$time = explode(" ", $time); 
$time = $time[1] + $time[0]; 
$endtime = $time; 
$totaltime = ($endtime - $begintime); 
echo '<br /><br /><em>This Magento SOAP API script took ' .$totaltime. ' seconds, precisely.</em>'; 
// ...and close the HTML document 
echo "</body>"; 
echo "</html>"; 
?>

如果这有助于任何人,您可以使用发票表作为密钥。使用auth +捕获信用卡设置的magento发票意味着钱已经进入。在我们的情况下,我们只需要在phpmyadmin中运行sql查询,该查询将导出订单号和发票号以便我们协调以检查订单导出xtento的扩展工作正在进行中。这就是我们使用的:

 SELECT sales_flat_order.increment_id AS 'order', sales_flat_invoice.increment_id AS 'invoice'
   FROM sales_flat_order
  RIGHT JOIN sales_flat_invoice ON sales_flat_invoice.order_id = sales_flat_order.entity_id
  WHERE sales_flat_invoice.updated_at >= "2011-07-01 00:00:00"
  ORDER BY sales_flat_order.increment_id DESC 

如果系统不支持任何直接导出订单的方法,您可以在数据库中创建一个列出您需要导出的订单的视图。然后使用像phpMyAdmin这样的东西将视图中的数据导出为CSV。

Saho建议使用SOAP很棒,但可能需要很长时间(Apache只能分配有限的CPU资源来处理该请求)

建议你编写一个php脚本然后通过终端运行它。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top