Created
December 19, 2017 10:02
-
-
Save korrio/04dc855aa529820d8b434d494dd98301 to your computer and use it in GitHub Desktop.
export script for importing to woocommerce via product im-ex plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//ini_set('display_errors', 1); | |
//ini_set('display_startup_errors', 1); | |
//error_reporting(E_ALL); | |
//aq1.co/wordpress/csv/export.php | |
require_once("_db.php"); | |
$filename = 'export.xls'; // The file name you want any resulting file to be called | |
$db = new Database("wp_thg_import", "<YOUR-MYSQL-USERNAME>", "YOUR-MYSQL-PASSWORD", "localhost"); // $host is optional and defaults to 'localhost' | |
$all = $db->select('watches_sample'); | |
header("Content-type: application/vnd.ms-excel"); | |
header("Content-Disposition: attachment; filename=$filename"); | |
// print_r(get_family_array("Datejust")); | |
$header = array( | |
"post_title", | |
"post_name", | |
"ID", | |
"post_excerpt", | |
"post_content", | |
"post_status", | |
"menu_order", | |
"post_date", | |
"post_author", | |
"comment_status", | |
"sku", | |
"downloadable", | |
"virtual", | |
"stock", | |
"regular_price", | |
"sale_price", | |
"weight", | |
"length", | |
"width", | |
"height", | |
"tax_class", | |
"visibility", | |
"stock_status", | |
"backorders", | |
"manage_stock", | |
"tax_status", | |
"upsell_ids", | |
"crosssell_ids", | |
"featured", | |
"sale_price_dates_from", | |
"sale_price_dates_to", | |
"download_limit", | |
"download_expiry", | |
"product_url", | |
"button_text", | |
"images", | |
"downloadable_files", | |
"tax:product_type","tax:product_visibility","tax:product_cat","tax:product_tag","tax:product_shipping_class", | |
"meta:description","meta:footer_navigation_slider","meta:image","meta:ninja_woo_page_product","meta:product_description", | |
"meta:product_image","meta:subtitle","meta:title","meta:total_sales", | |
"attribute:Price","attribute_data:Price","attribute_default:Price", | |
"attribute:pa_collection","attribute_data:pa_collection","attribute_default:pa_collection", | |
"attribute:pa_dial","attribute_data:pa_dial","attribute_default:pa_dial", | |
"attribute:pa_gender","attribute_data:pa_gender","attribute_default:pa_gender", | |
"attribute:pa_material","attribute_data:pa_material","attribute_default:pa_material", | |
"attribute:pa_price","attribute_data:pa_price","attribute_default:pa_price", | |
"attribute:pa_size","attribute_data:pa_size","attribute_default:pa_size"); | |
$tr = array(); | |
$tr[0] = ""; | |
$str = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; | |
$str .= "<table>"; | |
$str .= "<tr>"; | |
$j = 1; | |
foreach($header as $v) { | |
$h .= "<th>".$v."</th>"; | |
$j++; | |
} | |
$str .= $h; | |
$str .= "</tr>"; | |
$results = $all->result_array(); | |
$i = 0; | |
foreach($results as $r) { | |
// "post_title", | |
// "post_name", | |
// "ID", | |
// "post_excerpt", | |
// "post_content", | |
// "post_status", | |
// "menu_order", | |
// "post_date", | |
// "post_author", | |
// "comment_status", | |
// "sku", | |
$empty = ""; | |
$post_title = $r['ModelName']; | |
$post_name = ""; | |
$post_id = ""; | |
$sku = $r['RMC']; | |
$filter_Gender = $r['filter_Gender']; | |
$filter_Size = $r['filter_Size']; | |
$FamilyName = $r['FamilyName']; | |
$spec_Bezel = $r['spec_Bezel']; | |
$spec_Diameter = $r['spec_Diameter']; | |
$spec_WaterResistance = $r['spec_WaterResistance']; | |
$spec_Movement = $r['spec_Movement']; | |
$spec_Calibre = $r['spec_Calibre']; | |
$spec_PowerReserve = $r['spec_PowerReserve']; | |
$spec_BraceletMaterial = $r['spec_BraceletMaterial']; | |
$spec_Clasp = $r['spec_Clasp']; | |
$spec_Winding = $r['spec_Winding']; | |
$spec_WindingCrown = $r['spec_WindingCrown']; | |
$spec_Precision = $r['spec_Precision']; | |
$spec_Oscillator = $r['spec_Oscillator']; | |
$spec_Crystal = $r['spec_Crystal']; | |
$spec_Certification = $r['spec_Certification']; | |
$pa_collection = $FamilyName; | |
$pa_dial = $r['filter_Dial']; | |
$pa_size = $r['filter_Size']; | |
$pa_material = $r['filter_Material']; | |
$pa_gender = $r['filter_Gender']; | |
// GENDER WOMEN | |
// MATERIAL PLATINUM, STEEL | |
// SIZE MID-SIZE | |
// DAIL DIAMOND PAVED DAIL | |
// COLLECTION SEA-DWELLER | |
$tr3 = "<table border=0> | |
<tbody> | |
<tr> | |
<td valign=top> | |
<div> | |
<div> | |
<strong>Brand</strong> Rolex | |
<strong>Gender</strong> {$filter_Gender} | |
<strong>Size</strong> {$filter_Size} | |
<strong>Family Name</strong> {$FamilyName} | |
<strong>Bezel</strong> {$spec_Bezel} | |
<strong>Diameter</strong> {$spec_Diameter} | |
<strong>Water Resistance</strong> {$spec_WaterResistance} | |
<strong>Movement</strong> {$spec_Movement} | |
<strong>Caliber</strong> {$spec_Calibre} | |
</div> | |
</div> | |
</td> | |
<td valign=top> | |
<div> | |
<div> | |
<strong>Power Reserve</strong> {$spec_PowerReserve} | |
<strong>Bracelet Material</strong> {$spec_BraceletMaterial} | |
<strong>Clasp</strong> {$spec_Clasp} | |
<strong>Winding</strong> {$spec_Winding} | |
<strong>Winding Crown</strong> {$spec_WindingCrown} | |
<strong>Precision</strong> {$spec_Precision} | |
<strong>Oscillator</strong> {$spec_Oscillator} | |
<strong>Crystal</strong> {$spec_Crystal} | |
<strong>Certification</strong> {$spec_Certification} | |
</div> | |
</div> | |
</td> | |
</tr> | |
</tbody> | |
</table>"; | |
$all_family = $db->select('product_family_detail',array('family_name' => $FamilyName)); | |
$res = $all_family->result_array(); | |
foreach($res as $r0) { | |
$the_title1 = $r0['title1']; | |
$the_title2 = $r0['title2']; | |
$the_description = $r0['description']; | |
$the_url = $r0['url']; | |
} | |
$tr4 = '[vc_row full_width="stretch_row" equal_height="yes" css=".vc_custom_1512752981709{background-color: #333333 !important;}"] | |
[vc_column width="1/2"] | |
[vc_row_inner css=".vc_custom_1512755522281{padding-top: 140px !important;padding-right: 10% !important;padding-bottom: 14% !important;padding-left: 10% !important;}"] | |
[vc_column_inner]' . | |
"[vc_custom_heading text=\"{$the_title1}\" font_container=\"tag:h1|text_align:left|color:%23ffffff\" | |
google_fonts=\"font_family:Arimo%3Aregular%2Citalic%2C700%2C700italic|font_style:400%20regular%3A400%3Anormal\" link=\"|||\"]" . | |
"[vc_custom_heading text=\"{$the_title2}\" font_container=\"tag:h5|text_align:left|color:%23ffffff\" | |
google_fonts=\"font_family:Arimo%3Aregular%2Citalic%2C700%2C700italic|font_style:400%20regular%3A400%3Anormal\" link=\"|||\"]" . | |
'[vc_column_text]' | |
. $the_description . | |
'[/vc_column_text] | |
[vc_empty_space height="25px"]' . | |
"[vc_btn title=\"READ MORE\" color=\"white\" link=\"url:{$the_url}|||\"]" . | |
'[/vc_column_inner][/vc_row_inner] | |
[/vc_column] | |
[vc_column width="1/2"] | |
[vc_single_image source="external_link" custom_src="http://aq1.co/wordpress/wp-content/uploads/thg/watch_assets_showcase/'.$sku.'_showcase.jpg"] | |
[/vc_column] | |
[/vc_row]'; | |
$post_excerpt = $tr3; | |
$post_content = $tr4; | |
$post_status = "publish"; | |
$menu_order = 0; | |
$post_date = "2017-11-20 10:44:21"; | |
$post_author = 1; | |
$comment_status = "open"; | |
$images = "\"http://aq1.co/wordpress/wp-content/uploads/thg/watch_assets_upright/white_background/".$sku."_upright_white-bg.jpg | | |
http://aq1.co/wordpress/wp-content/uploads/thg/watch_assets_laying_down/white_background/".$sku."_laying-down_white-bg.jpg | | |
http://aq1.co/wordpress/wp-content/uploads/thg/watch_assets_upright/white_background/".$sku."_upright_white-bg.jpg | | |
http://aq1.co/wordpress/wp-content/uploads/thg/watch_assets_dial_closeup/".$sku."_front-facing_white-bg.jpg | | |
http://aq1.co/wordpress/wp-content/uploads/thg/watch_assets_showcase/".$sku."_showcase.jpg | | |
http://aq1.co/wordpress/wp-content/uploads/thg/watch_assets_in_box/".$sku."_presentation-box.jpg\""; | |
$product_cat = $r['FamilyName']; | |
$str .= "<tr>"; | |
//1 | |
$str .= "<td>".$post_title."</td>"; | |
//2 | |
$str .= "<td>".$post_name."</td>"; | |
//3 | |
$str .= "<td>".$post_id."</td>"; | |
//4 | |
$str .= "<td>".$post_excerpt."</td>"; | |
//5 | |
$str .= "<td>".$post_content."</td>"; | |
//6 | |
$str .= "<td>".$post_status."</td>"; | |
//7 | |
$str .= "<td>".$menu_order."</td>"; | |
//8 | |
$str .= "<td>".$post_date."</td>"; | |
//9 | |
$str .= "<td>".$post_author."</td>"; | |
//10 | |
$str .= "<td>".$comment_status."</td>"; | |
//11 | |
$str .= "<td>".$sku."</td>"; | |
//12 | |
$str .= "<td></td>"; | |
//13 | |
$str .= "<td></td>"; | |
//14 | |
$str .= "<td></td>"; | |
//15 | |
$str .= "<td></td>"; | |
//16 | |
$str .= "<td></td>"; | |
//17 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//18 | |
$str .= "<td></td>"; | |
//35 | |
$str .= "<td></td>"; | |
//36 | |
$str .= "<td>".$images."</td>"; | |
//37 | |
$str .= "<td></td>"; | |
//38 | |
$str .= "<td></td>"; | |
//39 | |
$str .= "<td></td>"; | |
//40 | |
$str .= "<td>".$product_cat."</td>"; | |
//41 | |
$str .= "<td></td>"; | |
//42 | |
$str .= "<td></td>"; | |
//43 | |
$str .= "<td></td>"; | |
//44 | |
$str .= "<td></td>"; | |
//45 | |
$str .= "<td></td>"; | |
//46 | |
$str .= "<td></td>"; | |
//47 | |
$str .= "<td></td>"; | |
//48 | |
$str .= "<td></td>"; | |
//49 | |
$str .= "<td></td>"; | |
//50 | |
$str .= "<td></td>"; | |
//51 | |
$str .= "<td></td>"; | |
//52 | |
$str .= "<td></td>"; | |
//53 | |
$str .= "<td></td>"; | |
//54 | |
$str .= "<td></td>"; | |
//55 collection | |
$str .= "<td>".$pa_collection."</td>"; | |
//56 collection | |
$str .= "<td></td>"; | |
//57 collection | |
$str .= "<td>".$pa_collection."</td>"; | |
//58 dial | |
$str .= "<td>".$pa_dial."</td>"; | |
//59 dial | |
$str .= "<td></td>"; | |
//60 dial | |
$str .= "<td>".$pa_dial."</td>"; | |
//61 gender | |
$str .= "<td>".$pa_gender."</td>"; | |
//62 gender | |
$str .= "<td></td>"; | |
//63 gender | |
$str .= "<td>".$pa_gender."</td>"; | |
//64 material | |
$str .= "<td>".$pa_material."</td>"; | |
//65 material | |
$str .= "<td></td>"; | |
//66 material | |
$str .= "<td>".$pa_material."</td>"; | |
//67 | |
$str .= "<td></td>"; | |
//68 | |
$str .= "<td></td>"; | |
//69 | |
$str .= "<td></td>"; | |
//70 size | |
$str .= "<td>".$pa_size."</td>"; | |
//71 size | |
$str .= "<td></td>"; | |
//72 size | |
$str .= "<td>".$pa_size."</td>"; | |
//52attribute:Price 53attribute_data:Price 54attribute_default:Price 55attribute:pa_collection 56attribute_data:pa_collection 57attribute_default:pa_collection 58attribute:pa_dial 59attribute_data:pa_dial 60attribute_default:pa_dial 61attribute:pa_gender 62attribute_data:pa_gender 63attribute_default:pa_gender 64attribute:pa_material 65attribute_data:pa_material 66attribute_default:pa_material 67attribute:pa_price 68attribute_data:pa_price 69attribute_default:pa_price 70attribute:pa_size 71attribute_data:pa_size 72attribute_default:pa_size | |
// $pa_collection = $FamilyName; | |
// $pa_dial = $r['filter_Dial']; | |
// $pa_size = $r['filter_Size']; | |
// $pa_material = $r['filter_Material']; | |
// $pa_gender = $r['filter_Gender']; | |
$str .= "</tr>"; | |
} | |
$str .= "</table>"; | |
echo $str; | |
?> | |
eso lo puedo ejecutar en un servidor local o en la nube la sección bd pongo la bd que creo en el host no la de la web a importar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
amigo sin plugin se puede hacer para una web externa no propia