how to import xml into oscommerce

This blog will guide you on how to import xml into oscommerce. Entire process will guide you using three steps.
more details are as follows.

Three easy steps to import xml into oscommerce.

Step 1: Download the oscommerce module import data using “csv” format.
Install this in oscommerce. Now this plugin will be available in admin section of website.

Step 2: You need to modify following code a bit to make it working, it means you need to match field name from xml file and add them in to “attrArry” array. Oh yes, Change xml file name inside script as well.

        $attrArry = array("advertisercategory", "sku", "name", "available", "imageurl", "price", "retailprice", "currency", "manufacturer", "manufacturerid", "keywords", "description", "buyurl");
	/*Open csv file to write data*/
	$outputFile  = fopen($outputFilename, 'w+');
	$csvHeader = array("Category", "Model", "Name_en", "Quantity", "Image", "Price", "Weight", "Description_en", "Tax_Class", "Manufacturer");
	fputcsv($outputFile, $csvHeader,';','"');
	/*Open xml file to read data*/
	$xml = simplexml_load_file($inputFilename);
	if(is_object($xml->product)&&!empty($xml->product)) {
	foreach($xml->product as $productInfo) {
		if($i == 2) break;
		$strRow = array();
		foreach($attrArry as $attrName){
	  	  $strRow[] = $productInfo->$attrName;
		fputcsv($outputFile, $strRow, ';', '"');

Step 3: Once you are done with step2, Now execute this php script to convert your xml to csv file and now upload this csv into csv import script and you are done !!.

Share this nice post: