PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / 1.2.10
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel v1.2.10
trunk 0.9.0 0.9.1 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0
wp-all-export / src / App / Service / Pro / VariationOptions / VariationOptions.php
wp-all-export / src / App / Service / Pro / VariationOptions Last commit date
VariationOptions.php 4 years ago
VariationOptions.php
84 lines
1 <?php
2
3 namespace Wpae\App\Service\Pro\VariationOptions;
4
5
6 use Wpae\App\Service\VariationOptions\VariationOptionsInterface;
7 use Wpae\App\Service\VariationOptions\VariationOptions as BasicVariationOptions;
8
9 class VariationOptions extends BasicVariationOptions implements VariationOptionsInterface
10 {
11 public function preprocessPost(\WP_Post $entry)
12 {
13 $productVariationMode = \XmlExportEngine::getProductVariationMode();
14
15 if (!$this->shouldTitleBeProcessed($productVariationMode)) {
16 return $entry;
17 }
18
19 if($entry->post_type != 'product_variation') {
20 return $entry;
21 }
22
23 if ($entry->post_type == 'product_variation') {
24 $entryId = $entry->ID;
25 $entryTitle = $entry->post_title;
26 $entryStatus = $entry->post_status;
27 $entryOrder = $entry->menu_order;
28 $parentId = $entry->post_parent;
29 $parent = get_post($parentId);
30 if ( ! empty($parent) ){
31 $parent->originalPost = clone $entry;
32 $entry = $parent;
33 $entry->ID = $entryId;
34 $entry->post_status = $entryStatus;
35 $entry->menu_order = $entryOrder;
36 $entry->post_parent = $parentId;
37 if (\XmlExportEngine::getProductVariationTitleMode() == \XmlExportEngine::VARIATION_USE_DEFAULT_TITLE) {
38 $entry->post_title = $entryTitle;
39 }
40 $entry->post_type = 'product_variation';
41 }
42 }
43
44 return $entry;
45 }
46
47 public function getQueryWhere($wpdb, $where, $join, $closeBracket = false)
48 {
49 if (\XmlExportEngine::getProductVariationMode() == \XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT) {
50 return " AND ($wpdb->posts.post_type = 'product') ";
51 } else if (\XmlExportEngine::getProductVariationMode() == \XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_VARIATION) {
52
53 return " AND $wpdb->posts.ID NOT IN (
54 SELECT DISTINCT $wpdb->posts.post_parent
55 FROM $wpdb->posts
56 WHERE $wpdb->posts.post_type = 'product_variation'
57 ) AND $wpdb->posts.ID NOT IN (SELECT o.ID FROM $wpdb->posts o
58 LEFT OUTER JOIN $wpdb->posts r
59 ON o.post_parent = r.ID
60 WHERE r.post_status = 'trash' AND o.post_type = 'product_variation')
61 OR ($wpdb->posts.post_type = 'product_variation' AND $wpdb->posts.post_status <> 'trash'
62
63 AND $wpdb->posts.post_parent IN (
64 SELECT DISTINCT $wpdb->posts.ID
65 FROM $wpdb->posts $join
66 WHERE $where
67 )
68 ".$this->getVariationsWhere($where, $join)."
69 )";
70 } else {
71 return $this->defaultQuery($wpdb, $where, $join, $closeBracket);
72 }
73 }
74
75 /**
76 * @param $productVariationMode
77 * @return bool
78 */
79 private function shouldTitleBeProcessed($productVariationMode)
80 {
81 return $productVariationMode != \XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT ||
82 $productVariationMode == \XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_VARIATION;
83 }
84 }