SHARE
TWEET

FoxyShop Export Script

sparkweb Jun 10th, 2014 315 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. //This is a basic export script. Edit as you need.
  3. //Save this file as page-foxyshop-export.php in your theme folder
  4. //Then create a page called "FoxyShop Export" and view it
  5.  
  6. header('Content-type: text/csv');
  7. header('Content-Disposition: attachment; filename="foxyshop-export.csv"');
  8.  
  9. $args = array('post_type' => 'foxyshop_product', 'post_status' => 'publish', 'posts_per_page' => -1);
  10. $the_query = new WP_Query( $args );
  11. while ( $the_query->have_posts() ) :
  12.         $the_query->the_post();
  13.  
  14.         $post_id = $the_query->post->ID;
  15.         $product = foxyshop_setup_product($post_id);
  16.  
  17.         echo '"' . str_replace('"', '""', get_the_title()) . '"'; //title
  18.         echo ',"' . str_replace('"', '""', $product['code']) . '"'; //code
  19.         echo ',"' . str_replace('"', '""', $product['description']) . '"'; //description
  20.         echo ',"' . str_replace('"', '""', $product['price']) . '"'; //price
  21.         echo "\n";
  22.  
  23. endwhile;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top