2015-08-14 28 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