AEMexporterwoocsvExportProduct

Class woocsvExportProduct.

Defined (1)

The class is defined in the following location(s).

/export/include/woocsvExportProduct.php  
  1. class woocsvExportProduct 
  2.  
  3. /** 
  4. * @var array 
  5. */ 
  6. public $body = array ( 
  7. "ID",  
  8. "post_author",  
  9. "post_date",  
  10. "post_date_gmt",  
  11. "post_content",  
  12. "post_title",  
  13. "post_excerpt",  
  14. "post_status",  
  15. "comment_status",  
  16. "ping_status",  
  17. "post_password",  
  18. "post_name",  
  19. "to_ping",  
  20. "pinged",  
  21. "post_modified",  
  22. "post_modified_gmt",  
  23. "post_content_filtered",  
  24. "post_parent",  
  25. "guid",  
  26. "menu_order",  
  27. "post_type",  
  28. "post_mime_type",  
  29. "comment_count",  
  30. "product_type",  
  31. ); 
  32.  
  33. /** 
  34. * @var array 
  35. */ 
  36. public $meta = array ( 
  37. '_backorders',  
  38. '_featured',  
  39. '_length',  
  40. '_manage_stock',  
  41. '_price',  
  42. '_product_url',  
  43. '_purchase_note',  
  44. '_regular_price',  
  45. '_sale_price',  
  46. '_shipping_class',  
  47. '_sku',  
  48. '_sold_individually',  
  49. '_stock',  
  50. '_stock_status',  
  51. '_tax_class',  
  52. '_tax_status',  
  53. 'total_sales',  
  54. '_virtual',  
  55. '_visibility',  
  56. '_weight',  
  57. '_height',  
  58. '_width',  
  59. '_default_attributes',  
  60. '_variation_description',  
  61. ); 
  62.  
  63. /** 
  64. * @var array 
  65. */ 
  66. public $attributes = array (); 
  67.  
  68. /** 
  69. * @var array 
  70. */ 
  71. public $category = array (); 
  72.  
  73. /** 
  74. * @var array 
  75. */ 
  76. public $tags = array (); 
  77.  
  78. /** 
  79. * @var array 
  80. */ 
  81. public $fields_needed_for_the_importer = array ( 
  82. 'product_type',  
  83. 'attributes',  
  84. 'variations',  
  85. 'categories',  
  86. 'tags',  
  87. 'product_gallery',  
  88. 'product_gallery_name',  
  89. 'featured_image',  
  90. 'featured_image_name',  
  91. ); 
  92.  
  93. /** 
  94. * woocsvExportProduct constructor. 
  95. */ 
  96. public function __construct () 
  97. $this->fillMeta(); 
  98.  
  99. $this->fillAttributes(); 
  100.  
  101. /** 
  102. */ 
  103. public function fillMeta () 
  104. global $wpdb; 
  105. $metaFields = $wpdb->get_col( " 
  106. select distinct b.meta_key from $wpdb->posts a, $wpdb->postmeta b 
  107. where post_type in ('product') 
  108. and a.ID = b.post_id 
  109. order by b.meta_key; 
  110. " ); 
  111.  
  112. $this->addToMeta( $metaFields ); 
  113.  
  114.  
  115. /** 
  116. */ 
  117. public function fillAttributes () 
  118.  
  119. $attributes = $this->getAttributes(); 
  120.  
  121. foreach ($attributes as $attribute) { 
  122. $this->attributes[] = 'pa_' . $attribute; 
  123.  
  124.  
  125. /** 
  126. * @param array $body 
  127. */ 
  128. public function addToMeta ($value) 
  129. if (is_array( $value )) { 
  130. $this->meta = array_merge( $this->meta, $value ); 
  131.  
  132. if (is_string( $value )) { 
  133. $this->meta[] = $value; 
  134.  
  135.  
  136. /** 
  137. * @return array 
  138. */ 
  139. public function allFields () 
  140. return array_unique( array_merge( $this->body, $this->meta, $this->attributes,  
  141. $this->fields_needed_for_the_importer ) ); 
  142.  
  143. /** 
  144. * @param $wpdb 
  145. * @return array 
  146. */ 
  147. public function getAttributes () 
  148.  
  149. $woocsvAttributes = new woocsvAttributes; 
  150.  
  151. return $woocsvAttributes->all(); 
  152.