I hope someone can help.
The following piece of php code (see below) is used to pull all the available products from a database and save them locally to a xml file (somefile.xml) so that google can come every day and and pick it to keep our merchant account or also known as google base up to date.
Since my inventory has grown to over 200K products, google will not accept the file any more as it is over 20 meg big and has asked me to split it in smaller files.
So I'm looking for a way to make this query save the products in multiple files, let's say create a brand new file every 10000 rows (or products) with a new file name in sequence (e.g somefile1.xml, somefile2.xml, etc etc...) while maintaining the xml file header and footer in each file.
$fp = fopen(BASE_PATH.'/somefile.xml','w');
$db->query("
SELECT ".DB_PREFIX."products.*,
WHERE ".DB_PREFIX."products.available='Yes'
ORDER BY title
");
///header
$xmlPacket =
'<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title>'.$settings["GlobalSiteName"].'</title>
<link>'.$settings["GlobalHttpUrl"].'</link>
while($db->moveNext()){
$product_url = $db->col["product_url"];
$name = $db->col["title"];
$condition = $db->col["condition"];
///products
$xmlPacket .=
"\n<item>
<title>".st_normalize($name)." (SKU ".st_normalize($pid).")</title>
<link>".st_normalize($product_url)."</link>
<g:condition>".st_normalize($condition)."</g:condition>
</item>\n";
}
///footer
$xmlPacket .=
'</channel>
</rss>';
fwrite($fp,$xmlPacket);
fclose($fp);
Please if someone has any idea how to accomplish this, please share any thoughts.
Thanks and have a nice day!