2015-08-14 36 views
0

我正在爲我的magento商店尋找解決方案。 我想出售IT產品,我有我的供應商,誰有XML服務。但它需要發送請求,並得到迴應。帶有圖像和說明的Magento XML產品訂閱源

而我不知道如何解決這個問題。

我想通過XML來更新目錄,圖片,價格,描述等。

如果有人有任何想法,請讓我知道。

XML代碼如下所示:

3.1.2 Response 
 
<?xml version="1.0" encoding="utf-16" standalone="yes"?> 
 
<Envelope> 
 
<Body> 
 
<Response> 
 
<Header> 
 
<Control> 
 
<ReturnCode>0</ReturnCode> 
 
<ReturnText></ReturnText> 
 
</Control> 
 
</Header> 
 
<Body> 
 
<ProductId>NP300E5C-S04HU</ProductId> 
 
<PartNumber>NP300E5C-S04HU</PartNumber> 
 
<Name>NP300E5C-S04HU...</Name> 
 
<Description>Intel® Pentium® Processor B970...</Description> 
 
<Manufacturer> 
 
<ManufacturerId>A113</ManufacturerId> 
 
<ManufacturerName>Samsung</ManufacturerName> 
 
</Manufacturer> 
 
<FirstLevelCategory> 
 
<FirstLevelCategoryId>B011</FirstLevelCategoryId> 
 
<FirstLevelCategoryName>Notebook</FirstLevelCategoryName> 
 
</FirstLevelCategory> 
 
<SecondLevelCategory> 
 
<SecondLevelCategoryId>C223</SecondLevelCategoryId> 
 
<SecondLevelCategoryName>15col</SecondLevelCategoryName> 
 
</SecondLevelCategory> 
 
<ThirdLevelCategory> 
 
<ThirdLevelCategoryId>D397</ThirdLevelCategoryId> 
 
<ThirdLevelCategoryName>Intel Dual Core</ThirdLevelCategoryName> 
 
</ThirdLevelCategory> 
 
<Garanty> 
 
<GarantyMode>Szervizben</GarantyMode> 
 
<GarantyTime>1 + 1 év</GarantyTime> 
 
</Garanty> 
 
<Price>336,35 EUR</Price> 
 
<New>false</New> 
 
<Discount>false</Discount> 
 
<Stock> 
 
<StockInfo>Rendelhető</StockInfo> 
 
<HasStock>false</HasStock> 
 
<Value>0</Value> 
 
</Stock> 
 
<AdvertisementId></AdvertisementId> 
 
<AdvertisementShortDescription></AdvertisementShortDescription> 
 
<Available>true</Available> 
 
<Comparable>false</Comparable> 
 
<Currency>EUR</Currency> 
 
<DataAreaId>BSC</DataAreaId> 
 
<EndOfSales>false</EndOfSales> 
 
<IsInCart>false</IsInCart> 
 
<IsInNewsletter>false</IsInNewsletter> 
 
<IsInStock>false</IsInStock> 
 
<PictureId>6694</PictureId> 
 
<ProductFlag1>false</ProductFlag1> 
 
<ProductFlag2>false</ProductFlag2> 
 
<PurchaseInProgress>false</PurchaseInProgress> 
 
<ShippingInfo>Rendelhető</ShippingInfo> 
 
<StockInfo>Rendelhető</StockInfo> 
 
<Pictures> 12 
 

 
<Picture> 
 
<Id>6694</Id> 
 
<FileName>NP300E5C-S04HU.jpg</FileName> 
 
<Primary>true</Primary> 
 
<RecId>5637248599</RecId> 
 
<Content>[Base64 coded content of the picture]</Content> 
 
</Picture> 
 
</Pictures> 
 
</Body> 
 
</Response> 
 
</Body> 
 
</Envelope>

3.1.1 Request 
 
<?xml version="1.0" encoding="utf-8"?> 
 
<Envelope> 
 
<Body> 
 
<Request> 
 
<Base> 
 
<AuthCode>##########-##########-##########-##########</AuthCode> 
 
<Language>hu</Language> 
 
<Currency>EUR</Currency> 
 
</Base> 
 
<ProductId>NP300E5C-S04HU</ProductId> 
 
</Request> 
 
</Body> 
 
</Envelope>

+0

你還沒有解釋清楚什麼是你需要做的。 – Enigmativity

+0

我在商店裏有產品。我需要使用他們的產品照片和說明更新產品。照片和描述來自供應商通過XML,但首先我需要通過XML發送一個請求通過XML獲得響應。但我必須逐個發送請求。 – AirOPTIX

+0

這就是你應該在你的問題中說的話。 – Enigmativity

回答

0

您需要使用捲曲使用這個API請求。

$url = '$client_url'; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml')); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_file); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$result = curl_exec($ch); 
curl_close($ch); 

而且你可以解析像

$xml = new SimpleXMLElement($result); 
+0

EHH ......我覺得我不夠聰明此:( – AirOPTIX

+0

這是你需要什麼? –

+0

通過這種方法的答案,我需要逐個拉每個產品的信息,我需要一個完整的XML文件,其中包含所有產品數據在一個文件中 – AirOPTIX

-1

的$結果XML我也得到了供應商的PHP,但不知道如何使用它。

<?php 
 
$url = 'http://www.xxxxxx.hu/CompanyGroup.XmlGateway/CatalogueService/GetCatalogueItem/'; 
 
$xml = '<Envelope> 
 
      <Body> 
 
      <Request> 
 
      <Base> 
 
       <AuthCode>########-########-########-########</AuthCode> 
 
       <Language>hu</Language> 
 
       <Currency>HUF</Currency> 
 
      </Base> 
 
      <ProductId>SMT750I</ProductId> 
 
      </Request> 
 
      </Body> 
 
     </Envelope>'; 
 
$content_type = 'application/xml'; 
 
$options = array(
 
           'http'  => array(
 
           'method' => 'POST', 
 
           'header' => 'Content-type: ' . addslashes($content_type) .'\r\n' 
 
               .'Content-Length: ' . strlen($xml) . '\r\n', 
 
           'content' => $xml, 
 
          ), 
 
); 
 
$context = stream_context_create($options); 
 
$result = file_get_contents($url, false, $context); 
 
echo ($result); 
 
?>

+0

這不是問題的答案,請將其作爲新問題發佈,並刪除該答案。 – Enigmativity