【问题标题】:get Order_Item_Id using magento api使用 magento api 获取 Order_Item_Id
【发布时间】:2012-07-29 04:36:07
【问题描述】:

我想在 php 中使用 magento api 在 magento 商店中创建发票。为此,我想为特定数量和项目创建发票意味着如果有人想以特定数量为一件项目开票,那么应该完成。我的代码是为 array() 或所有数量工作。 下面是创建发票的伪代码

$client = new Zend_XmlRpc_Client('http://127.0.0.1:8080/AndroidMagento/api/xmlrpc')
$session = $client->call('login', array('tester','tester'));
$saleorderno = '100000007';

Mage::init();
$order = Mage::getModel('sales/order')->load($saleorderno);
$orderItems = $order->getAllItems();
$invoiceItems = array();


foreach ($orderItems as $_eachItem) {
$invoiceItems[$_eachItem->getItemId()] = $_eachItem->getQtyOrdered();
}

$result = $client->call('call',array($session,'sales_order_invoice.create',array($saleorderno,array('order_item_id' => 9474, 'qty' => 1),'Invoice Created by Test',false,false)));

我看过这个link,在那里我发现了一些想法,但我不能完全理解。我不明白如何获得 order_item_id 的价值。???
任何想法???请建议我提前谢谢...

【问题讨论】:

    标签: php api magento xml-rpc


    【解决方案1】:

    item_id 和 product_id 是不同的 id。

    订单或报价有 item_id 和 product_id。

    你可以试试这个:

    $order = Mage::getModel('sales/order')->load($saleorderno);
    $orderItems = $order->getAllItems();
    
    foreach ($orderItems as $item){
          print_r($item->getData());
          print_r($item->getItemId()); //magic function to get ['item_id']
    }
    

    您可以在“销售/报价”模型中做到这一点。

    干杯^^

    【讨论】:

    • 感谢您的回复。但是通过使用这个我会得到 item_id 而不是 order_item_id 并且这两个是不同的。我必须使用 magento api 的 create_invoice 方法传递 order_item_id 的值。
    【解决方案2】:

    试试这个,

    echo "<pre>";
    $result = $client->call($session, 'sales_order.info', 'orderIncrementId');
    print_r($result['item_id']);
    print_r($result['product_id']);
    

    $result 将返回订单的所有信息,包括 item_id 和 product_id,

    使用 $result['item_id'] 你可以将它传递给调用

    sales_order_invoice.create

    然后做

    $result = $client->call(
        $session,
        'sales_order_invoice.create',
        array('orderIncrementId' => '200000008', 
             array('order_item_id' => $result['item_id'], 
                   'qty'           => $result['total_qty_ordered'])
        )
    );
    

    和数量,你必须从 $result['total_qty_ordered']

    首先,尝试print_r[$result];然后你会从中得到一些提示。

    ^^

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    • 2013-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-06
    相关资源
    最近更新 更多