CSV output add a column?
-
Hi Guys,
First I’d like to explain I am not good at this whole PHP thing so if I offend anyone by my complete and utter dumbness I apologise in advance. I’ve spent the last few days trying to find a solution to my problem and have give up so thought I would ask for the help of the community. The developer of the theme I am using has said the thing addition I need is really simple to do so rather than pay for it I would like to see if it is that simple.
Anyway I have a compare theme that out puts my products in CSV format and I want to add an extra field that outputs the product permalink (The one on my site). I have narrowed it down to a section of code, I know this as I can get the header I added I just can’t get the output under that header it just shows as blank.
this is the code and I have added everything concerning PROD_URL. I just don’t know I should put behind $d[‘PROD_URL’]
// Other fields $data['FULLNAME'] = str_replace(';',',',$post->post_title); $q = "SELECT m.name, p.price, p.shipping, p.deeplink, p.voucher, p.feed_product_image FROM ".$wpdb->prefix.'pc_products'." p,".$wpdb->prefix.'pc_products_merchants'." m WHERE p.id_merchant = m.slug AND p.id_product = '".$pr->id_product."'"; $merchants = $wpdb->get_results($q); foreach($merchants as $merchant) { $d = $data; $d['PRICE'] = str_replace(';',',',$merchant->price); $d['SHIPPING'] = str_replace(';',',',$merchant->shipping); $d['IMAGE'] = str_replace(';',',',$merchant->feed_product_image); $d['MERCHANT'] = str_replace(';',',',$merchant->name); $d['DEEPLINK'] = str_replace(';',',',$merchant->deeplink); $d['DESCRIPTION'] = str_replace(';',',',str_replace(array("\r\n", "\n", "\r"),' ',strip_tags(stripslashes($post->post_content)))); $d['GLOBAL_DESCRIPTION'] = str_replace(';',',',str_replace(array("\r\n", "\n", "\r"),' ',strip_tags(stripslashes($pr->product_description)))); $d['VOUCHER'] = str_replace(';',',',$merchant->voucher); $d['PROD_URL'] = I dont know what to add here????? $products[] = $d; } } ?> <div id="icon-link-manager" class="icon32"></div> <h2><?php _e('Export Feed','framework'); ?></h2> <p><?php _e('Copy the content from the textpane below into your text editor and save as a .csv file','framework'); ?></p> <?php echo '<textarea rows="20" style="width:98%;">'; echo 'UID;CATEGORIES;BRAND;FULL NAME;PRICE;SHIPPING;IMAGE;RETAILER;DEEPLINK;DESCRIPTION;GLOBAL_DESCRIPTION;VOUCHER;PROD_URL'."\n"; for($i=0;$i < count($products); $i++) { echo implode(';',$products[$i]); if($i != count($products) -1) echo "\n"; } echo '</textarea>';Any help would be greatly appreciated.
Kind Regards
Daniel
The topic ‘CSV output add a column?’ is closed to new replies.