PeeJay Posted January 26, 2006 Posted January 26, 2006 Hi, I am trying to show some product listing varaibles in product_listing.php from my wholeseller by XML request. For a specific product, in product_info.php, I can send XML request, get response and parse that in PHP as I wanted. That works fine. But when I try to do that for all products in a catagory with a loop, it does not work as it suppose to. For some catagories, I get response of only couple of prodcuts and for some, all products. The code which I usein the module of product_listing.php is something like below: ....... ...... while ($listing = tep_db_fetch_array($listing_query)) { $rows++; if (($rows/2) == floor($rows/2)) { $list_box_contents[] = array('params' => 'class="productListing-even"'); } else { $list_box_contents[] = array('params' => 'class="productListing-odd"'); } $cur_row = sizeof($list_box_contents) - 1; $xml_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$listing['products_id'] . "'"); $xml_listing = tep_db_fetch_array($xml_query); for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { $lc_align = ''; $xml_request = 'My XML request to wholeseller for the product of $xml_listing['products_model']' $s = curl_init("URL"); $header[] = "Content-type: text/xml"; $header[] = "Content-length: ".strlen($xml_request); curl_setopt($s, CURLOPT_URL, "URL"); curl_setopt($s, CURLOPT_RETURNTRANSFER, 1); curl_setopt($s, CURLOPT_TIMEOUT, 60); curl_setopt($s, CURLOPT_POST, 1); curl_setopt($s, CURLOPT_HTTPHEADER, $header); curl_setopt($s, CURLOPT_POSTFIELDS, $xml_request); $xmlResponse = curl_exec ($s); curl_close($s); // I use the xml parser by Torin Walker, class named xmldocument.php $doc = new XMLDocument(); $xp = new XMLParser(); $xp->setDocument($doc); $xp->parse($xmlResponse); $doc = $xp->getDocument(); $available_qty = $doc->getValueByPath('../../QtyAvailable'); switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $lc_align = ''; $lc_text = ' ' . $listing['products_model'] . ' '; break; case 'PRODUCT_LIST_NAME': $lc_align = ''; if (isset($HTTP_GET_VARS['manufacturers_id'])) { $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>'; } else { $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> '; } break; case 'PRODUCT_LIST_QUANTITY': $lc_align = 'right'; $lc_text = ' ' . $available_qty . ' '; break; ...... ...... Does anyone have idea, where I made the mistake! Please, suggest me!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.