Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom Virtuemart Export PHP script; I created this some time ago for a Joomla 1.5 installation
<html>
<head>
</head>
<body>
<?php
// Please note this was developed for a Joomla 1.5 installation
// www.sgvulcan.com
$host = "localhost"; //database location
$user = "user"; //database username
$pass = "pass"; //database password
$db_name = "database"; //database name
$wtxt='';
//database connection
$link = mysql_connect($host, $user, $pass);
mysql_select_db($db_name);
$myFile = "product_export.csv";
$fh = fopen($myFile, 'w');
$sqlstr = mysql_query("SELECT * FROM jos_vm_product");
if (mysql_numrows($sqlstr) != 0) {
while ($row = mysql_fetch_array($sqlstr)) {
// category id
$sql_cat_id = mysql_query("SELECT * FROM jos_vm_product_category_xref WHERE product_id = " .
$row['product_id']);
$cat_row = mysql_fetch_array($sql_cat_id);
fwrite($fh, "\"" . base64_encode($cat_row['category_id']) . "\"" . ";" );
// category name
$sql_catname_id = mysql_query("SELECT * FROM jos_vm_category WHERE category_id = " .
$cat_row['category_id']);
$catname_row = mysql_fetch_array($sql_catname_id);
fwrite($fh, "\"" . base64_encode($catname_row['category_name']) . "\"" . ";" );
// product name
fwrite($fh, "\"" . base64_encode($row['product_name']) . "\"" . ";" );
// product sku
fwrite($fh, "\"" . base64_encode($row['product_sku']) . "\"" . ";" );
// product short description
fwrite($fh, "\"" . base64_encode($row['product_s_desc']) . "\"" . ";" );
// full size photo
fwrite($fh, "\"" .
base64_encode("http://www.thewebsite.com/components/com_virtuemart/shop_image/product/" .
$row['product_full_image']) . "\"" . ";" );
// empty
fwrite($fh, "\"" . "\"" . ";" );
// empty
fwrite($fh, "\"" . "\"" . ";" );
// empty
fwrite($fh, "\"" . "\"" . ";" );
// empty
fwrite($fh, "\"" . "\"" . ";\r\n" );
}
}
mysql_close($link);
$domain = $_SERVER['HTTP_HOST'];
$url = "http://" . $domain . "/folder/" . $myFile;
echo "File is available at ";
echo "\n<a href=\"" . $url . "\">" . $url . "</a>";
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.