simplez Posted June 20, 2012 Share Posted June 20, 2012 How do I get the mpn number from the db? It's on row 11 in the code but not showing up in the result? <?php $path = str_replace('/autorun','',str_replace('/controlpanel','',dirname($_SERVER['SCRIPT_FILENAME'])).'/'); $path = '../'; require($path.'start/autorun.php'); $file = $path.'googlebase.txt'; $fh = fopen($file, 'w'); $headerline .= "id\t"; $headings[0] = 'id'; $headings[1] = 'title'; $headings[2] = 'description'; $headings[3] = 'link'; $headings[4] = 'price'; $headings[5] = 'brand'; $headings[6] = 'condition'; $headings[7] = 'image_link'; $headings[8] = 'quantity'; $headings[9] = 'model_number'; $headings[10] = 'availability'; $headings[11] = 'MPN'; fwrite($fh, implode("\t",$headings)."\n"); # Products (+ Reviews) $products = $db->query('SELECT * FROM products WHERE parent_id = 0 AND enabled = 1 AND hidden = 0 AND id IN (SELECT product_id FROM products_categories) ORDER BY salesrank ASC LIMIT 2000'); $products = $products->getFullArray(); foreach ($products as $product) { $productattributes = getProductAttributes($product['id']); $manufacturer = getManufacturer($product['manufacturer_id']); $images = getAllProductImages($product['id'], '500', '500'); $mainimage = $images[0]; unset($images[0]); # Write Line $row = array(); $row[0] = $product['id']; $row[1] = $product['title']; $row[2] = $product['metadescription']; $row[3] = URL_SITE.$product['pagename'].'/'; $row[4] = $product['price']/100; $row[5] = $manufacturer['name']; $row[6] = 'new'; $row[7] = URL_SITE.$mainimage['resized']; $row[8] = '100'; $row[9] = $productattributes['Model']; $row[10] = 'in stock'; $row[11] = $productattributes['MPN']; fwrite($fh, implode("\t",$row)."\n"); } fclose($fh); ?> Quote Link to comment https://forums.phpfreaks.com/topic/264528-trying-to-add-a-line-to-this-script/ Share on other sites More sharing options...
Jessica Posted June 20, 2012 Share Posted June 20, 2012 MPN is the value in the name column. The gibberish that I suspect you want is the value of the `value` column. Rather than echoing $productattributes['MPN'] you would echo $productattributes['value'] Quote Link to comment https://forums.phpfreaks.com/topic/264528-trying-to-add-a-line-to-this-script/#findComment-1355659 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.