Furedetsu Posted April 27, 2011 Share Posted April 27, 2011 Hi, I need my store to show "in" or "out of stock" for each product instead of quantity and with an XML feed from my supplier. My supplier gave me soms example code explaining how to get the data with PHP coding. But I would like to know what file of the Prestashop installation I need to alter? The XML feed also gives data for one product at a time and not for multiple products. Link to comment Share on other sites More sharing options...
Furedetsu Posted April 30, 2011 Author Share Posted April 30, 2011 Thanks for the reply but I, don't really know what to do with it. I'm using Prestashop 1.3.6 and I don't see Tools / Web Service to begin with. Link to comment Share on other sites More sharing options...
Furedetsu Posted May 1, 2011 Author Share Posted May 1, 2011 I really would like to use 1.4 but my template isn't compatible...But my supplier is giving me the code to use. I just don't know where to put the code. Link to comment Share on other sites More sharing options...
Furedetsu Posted May 3, 2011 Author Share Posted May 3, 2011 Nobody has a solution for 1.3.6? Link to comment Share on other sites More sharing options...
Furedetsu Posted May 4, 2011 Author Share Posted May 4, 2011 This is the code I got from my supplier. If just someone could tell me where to use it? <?php // First we need to feed the techdata SKU, for now we use 1088963 as an example $td_sku="1088963"; //Following the XML data $xmldata="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r \r <Header>\r ------\r ---------\r Full\r </Header>\r \r \r \r $td_sku\r 1\r \r "; $fp = fsockopen("intcom.xml.techdata-europe.com", 8080, $errno, $errstr, 15); //Generate the postdata on a valid way, $out4 needs to be calculated, so will be later. $out1 = "POST /Onlchk HTTP/1.0\r "; $out2 = "Content-Type: multipart/form-data; boundary=---------------------------2\r "; $out3 = "Host: intcom.xml.techdata-europe.com:8080\r "; $out5 = "Connection: close\r \r "; $out6 = "-----------------------------2\r "; $out7 = "Content-Disposition: form-data; name=\"onlinecheck\"\r \r "; $out8 = "\r -----------------------------2--"; //Calculation of the Content-Length: $tlen=strlen($out6)+strlen($out7)+strlen($xmldata)+strlen($out8); $out4 = "Content-Length: $tlen\r "; //Generate full output $out = $out1.$out2.$out3.$out4.$out5.$out6.$out7.$xmldata.$out8; fwrite($fp, $out); $retval = ""; while(!feof($fp)){$retval = "$retval".fgets($fp,128);} fclose($fp); list($headers,$body) = explode("<?xml version=\"1.0\" encoding=\"UTF-8\"?>",$retval); $doc = new DOMDocument(); $doc ->LoadXML($body); $item_ids = $doc->getElementsByTagname( "OnlineCheck" ); foreach( $item_ids as $item ) { $error_s = $item->getElementsByTagName( "Errorstatus" ); $tderror = $error_s->item(0)->nodeValue; $stock_s = $item->getElementsByTagName( "AvailabilityTotal" ); $tdstock = $stock_s->item(0)->nodeValue; // Reformatting the price to ISO compatible format $price_s = $item->getElementsByTagName( "UnitPriceAmount" ); $tdprice = str_replace('.','',$price_s->item(0)->nodeValue); $tdprice=str_replace(',','.',$tdprice); } //Rest of handling off the data under here ?> Link to comment Share on other sites More sharing options...
Recommended Posts