我有以下代码来覆盖V2.php
class Sigma_Sales_Model_Order_Api_V2 extends Mage_Sales_Model_Order_Api_V2
{
public function info($orderIncrementId)
{
$result = parent::info( $orderIncrementId );
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
$orderItems = $order->getItemsCollection();
$skuQtyArray = array();
foreach ($orderItems as $item)
{
$product_id = $item->product_id;
$product_sku = $item->sku;
$item_id = $item->getItemId();
$tax_percent = $item->gettaxPercent();
$product_qty = $item->getQtyOrdered();
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $product_sku);
$productType=$product->getTypeID();
if($productType=='simple')
{
$skuQtVal = $product_sku."=".$item_id;
$skuQtyArray[] = $skuQtVal;
}
}
$result['simple_product_skus'] = array_unique($skuQtyArray);
return $result;
}
}
现在我正在访问
<?php
$client = new SoapClient('localhost/magento/index.php/api/v2_soap/index?wsdl=1');
$session = $client->login('testuser', 'testuser');
$result = $client ->salesOrderInfo($session, '100000026');
print_r($result);
?>
输出就像
stdClass Object
(
------
------
------
[status_history] => Array
(
[0] => stdClass Object
(
[parent_id] => 72
[created_at] => 2013-11-08 14:42:11
[is_customer_notified] => 1
[status] => pending
)
)
[simple_product_skus] => Array
(
[0] => ASL-B346-67-64-98=155=166=1.0000=0.0000
[1] => ASL-B346-67-64-98=156=116=1.0000=0.0000
)
)
我想将simple_product_skus作为stdClass对象就像我正在获取status_history。
我怎样才能得到这个请帮助。
答案 0 :(得分:0)
我认为这会让你得到你想要的东西:
$result['simple_product_skus'] = (object)array_unique($skuQtyArray);
这是将数组类型转换为标准的php对象。