小编rah*_*unr的帖子

如何将SOAP响应转换为PHP数组?

我无法在php中将SOAP响应转换为Array.

这是代码

 $response = $client->__doRequest($xmlRequest,$location,$action,1);
Run Code Online (Sandbox Code Playgroud)

这是SOAP响应.

<soap:envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:body>
<searchflightavailability33response xmlns="http://FpwebBox.Fareportal.com/Gateway.asmx">
<searchflightavailability33result>
    &lt;Fareportal&gt;&lt;FpSearch_AirLowFaresRS&gt;&lt;CntKey&gt;1777f5a7-7824-46ce-a0f8-33d5e6e96816&lt;/CntKey&gt;&lt;Currency CurrencyCode="USD"/&gt;&lt;OriginDestinationOptions&gt;&lt;OutBoundOptions&gt;&lt;OutBoundOption segmentid="9W7008V21Feb14"&gt;&lt;FlightSegment etc....
    </searchflightavailability33result>
</searchflightavailability33response>
</soap:body>
</soap:envelope>;
Run Code Online (Sandbox Code Playgroud)

我使用以下方法转换为数组,但我得到空输出.

1.echo '<pre>';print_r($client__getLastResponse());
2.echo '<pre>';print_r($response->envelope->body->searchflightavailability33response);
3.echo '<pre>';print_r($client->SearchFlightAvailability33($response));
     4.simplexml_load_string($response,NULL,NULL,"http://schemas.xmlsoap.org/soap/envelope/");  

5.echo '<pre>';print_r($client->SearchFlightAvailability33($response));
Run Code Online (Sandbox Code Playgroud)

请指教.

php xml soap soap-client

19
推荐指数
4
解决办法
5万
查看次数

如何在magento中添加新项目之前清除/删除购物车项目?

我尝试使用以下代码删除/清除购物车商品,它已删除购物车中的所有商品.但未添加新商品/商品.

二手代码

1.Mage::getSingleton('checkout/session')->clear();
2.Mage::getSingleton('checkout/cart')->truncate();
3.$quote = Mage::getSingleton('checkout/session')->getQuote(); 
$quote->delete();
4.Mage::getSingleton('checkout/cart')->truncate()->save();
5.Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
6.foreach( Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item ){
    Mage::getSingleton('checkout/cart')->removeItem( $item->getId() )->save();
}
7.$cartHelper = Mage::helper('checkout/cart');
        $items = $cartHelper->getCart()->getItems();       
        foreach ($items as $item)
        {
                $itemId = $item->getItemId();
                $cartHelper->getCart()->removeItem($itemId)->save();
        }

8.$quote = Mage::getSingleton('checkout/session')->getQuote();
$item = $quote->getItemByProduct($product);
$quote->removeItem($item->getId());

9.$quote->removeAllItems();
Run Code Online (Sandbox Code Playgroud)

请任何人建议我以上我的要求.谢谢你提前.

谢谢arumugam

magento

1
推荐指数
1
解决办法
8457
查看次数

标签 统计

magento ×1

php ×1

soap ×1

soap-client ×1

xml ×1