Version Description
Download this release
Release Info
Developer | wahid0003 |
Plugin | CTX Feed – WooCommerce Product Feed Manager Plugin |
Version | 2.2.7 |
Comparing to | |
See all releases |
Code changes from version 2.2.6 to 2.2.7
- README.txt +4 -0
- includes/class-woo-feed.php +1 -1
- includes/classes/class-woo-feed-products.php +170 -11
- woo-feed.php +27 -16
README.txt
CHANGED
@@ -270,6 +270,10 @@ Using pro version:
|
|
270 |
|
271 |
== Changelog ==
|
272 |
|
|
|
|
|
|
|
|
|
273 |
= 2.2.6(2018-02-15) =
|
274 |
* Added: Jet.com Template added
|
275 |
* Added: Wish.com Template added
|
270 |
|
271 |
== Changelog ==
|
272 |
|
273 |
+
= 2.2.7(2018-03-01) =
|
274 |
+
* Product query code improved
|
275 |
+
|
276 |
+
|
277 |
= 2.2.6(2018-02-15) =
|
278 |
* Added: Jet.com Template added
|
279 |
* Added: Wish.com Template added
|
includes/class-woo-feed.php
CHANGED
@@ -70,7 +70,7 @@ class Woo_Feed
|
|
70 |
public function __construct()
|
71 |
{
|
72 |
$this->woo_feed = 'woo-feed';
|
73 |
-
$this->version = '2.2.
|
74 |
|
75 |
$this->load_dependencies();
|
76 |
$this->set_locale();
|
70 |
public function __construct()
|
71 |
{
|
72 |
$this->woo_feed = 'woo-feed';
|
73 |
+
$this->version = '2.2.7';
|
74 |
|
75 |
$this->load_dependencies();
|
76 |
$this->set_locale();
|
includes/classes/class-woo-feed-products.php
CHANGED
@@ -69,6 +69,38 @@ class Woo_Feed_Products
|
|
69 |
public $pi;
|
70 |
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
/**
|
73 |
* Get All Products
|
74 |
* @since 2.2.0
|
@@ -104,18 +136,20 @@ class Woo_Feed_Products
|
|
104 |
$this->feedRule['is_variations'] = 'n';
|
105 |
}
|
106 |
|
107 |
-
$query = new WC_Product_Query( $arg );
|
108 |
-
$products = $query->get_products();
|
109 |
|
110 |
-
|
111 |
-
//return $products;
|
112 |
|
113 |
$this->pi = 1; # Product Index
|
114 |
-
foreach ( $products as $key => $
|
|
|
|
|
|
|
|
|
115 |
if ( $prod->is_type( 'simple' ) )
|
116 |
{
|
117 |
|
118 |
-
$id = $prod->get_id();
|
119 |
$simple = new WC_Product_Simple( $id );
|
120 |
|
121 |
if(!is_object($simple)){
|
@@ -222,7 +256,7 @@ class Woo_Feed_Products
|
|
222 |
|
223 |
}
|
224 |
else if ( $prod->is_type( 'external' ) ) {
|
225 |
-
|
226 |
$external = new WC_Product_External( $id );
|
227 |
|
228 |
if(!is_object($external)){
|
@@ -329,7 +363,7 @@ class Woo_Feed_Products
|
|
329 |
// }
|
330 |
}
|
331 |
else if ( $prod->is_type( 'grouped' ) ) {
|
332 |
-
|
333 |
$grouped = new WC_Product_Grouped( $id );
|
334 |
|
335 |
if(!is_object($grouped)){
|
@@ -436,7 +470,6 @@ class Woo_Feed_Products
|
|
436 |
}
|
437 |
else if ( $prod->is_type( 'variable' ) ) {
|
438 |
|
439 |
-
$id = $prod->get_id();
|
440 |
$variable = new WC_Product_Variable( $id );
|
441 |
|
442 |
if(!is_object($variable)){
|
@@ -556,10 +589,136 @@ class Woo_Feed_Products
|
|
556 |
// }
|
557 |
|
558 |
# Don't Include Variations for Facebook
|
559 |
-
if ( $this->feedRule['provider'] != 'facebook' ) {
|
560 |
-
$this->getWC3Variations( $variable->get_available_variations(),$variable);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
561 |
}
|
|
|
562 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
563 |
}
|
564 |
|
565 |
$this->pi ++;
|
69 |
public $pi;
|
70 |
|
71 |
|
72 |
+
|
73 |
+
public function wooProductQuery($arg) {
|
74 |
+
|
75 |
+
global $wpdb;
|
76 |
+
|
77 |
+
|
78 |
+
$limit="";
|
79 |
+
$offset="";
|
80 |
+
if($arg['limit']!="" && $arg['limit']!="-1" && $arg['limit']>0){
|
81 |
+
$limit=$arg['limit'];
|
82 |
+
$limit="LIMIT $limit";
|
83 |
+
|
84 |
+
|
85 |
+
if($arg['offset']!="" && $arg['offset']!="-1"){
|
86 |
+
$offset=$arg['offset'];
|
87 |
+
$offset="OFFSET $offset";
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
$query = "SELECT DISTINCT {$wpdb->prefix}posts.ID
|
94 |
+
FROM {$wpdb->prefix}posts
|
95 |
+
LEFT JOIN {$wpdb->prefix}term_relationships ON ({$wpdb->prefix}posts.ID = {$wpdb->prefix}term_relationships.object_id)
|
96 |
+
LEFT JOIN {$wpdb->prefix}term_taxonomy ON ({$wpdb->prefix}term_relationships.term_taxonomy_id = {$wpdb->prefix}term_taxonomy.term_taxonomy_id)
|
97 |
+
LEFT JOIN {$wpdb->prefix}postmeta ON ({$wpdb->prefix}posts.ID = {$wpdb->prefix}postmeta.post_id)
|
98 |
+
WHERE {$wpdb->prefix}posts.post_status = 'publish' AND {$wpdb->prefix}posts.post_type IN ('product','product_variation')
|
99 |
+
ORDER BY ID DESC $limit $offset";
|
100 |
+
$products = $wpdb->get_results($query, ARRAY_A );
|
101 |
+
return $products;
|
102 |
+
}
|
103 |
+
|
104 |
/**
|
105 |
* Get All Products
|
106 |
* @since 2.2.0
|
136 |
$this->feedRule['is_variations'] = 'n';
|
137 |
}
|
138 |
|
139 |
+
// $query = new WC_Product_Query( $arg );
|
140 |
+
// $products = $query->get_products();
|
141 |
|
142 |
+
$products = $this->wooProductQuery($arg);
|
|
|
143 |
|
144 |
$this->pi = 1; # Product Index
|
145 |
+
foreach ( $products as $key => $productId ) {
|
146 |
+
$prod=wc_get_product($productId['ID']);
|
147 |
+
|
148 |
+
$id = $prod->get_id();
|
149 |
+
|
150 |
if ( $prod->is_type( 'simple' ) )
|
151 |
{
|
152 |
|
|
|
153 |
$simple = new WC_Product_Simple( $id );
|
154 |
|
155 |
if(!is_object($simple)){
|
256 |
|
257 |
}
|
258 |
else if ( $prod->is_type( 'external' ) ) {
|
259 |
+
|
260 |
$external = new WC_Product_External( $id );
|
261 |
|
262 |
if(!is_object($external)){
|
363 |
// }
|
364 |
}
|
365 |
else if ( $prod->is_type( 'grouped' ) ) {
|
366 |
+
|
367 |
$grouped = new WC_Product_Grouped( $id );
|
368 |
|
369 |
if(!is_object($grouped)){
|
470 |
}
|
471 |
else if ( $prod->is_type( 'variable' ) ) {
|
472 |
|
|
|
473 |
$variable = new WC_Product_Variable( $id );
|
474 |
|
475 |
if(!is_object($variable)){
|
589 |
// }
|
590 |
|
591 |
# Don't Include Variations for Facebook
|
592 |
+
// if ( $this->feedRule['provider'] != 'facebook' ) {
|
593 |
+
// $this->getWC3Variations( $variable->get_available_variations(),$variable);
|
594 |
+
// }
|
595 |
+
|
596 |
+
}
|
597 |
+
else if ( $prod->is_type( 'variation' ) && $this->feedRule['provider'] != 'facebook') {
|
598 |
+
$variation=new WC_Product_Variation($id);
|
599 |
+
|
600 |
+
if(!is_object($variation)){
|
601 |
+
continue;
|
602 |
+
}
|
603 |
+
|
604 |
+
# Parent Info
|
605 |
+
$parent=wc_get_product($variation->get_parent_id());
|
606 |
+
$parentInfo=$variation->get_parent_data();
|
607 |
+
$variationTitle= $parentInfo['title'];
|
608 |
+
|
609 |
+
# Set Variation Description
|
610 |
+
$description=$variation->get_description();
|
611 |
+
if(empty($description)){
|
612 |
+
$description=$parent->get_description();
|
613 |
}
|
614 |
+
$description=$this->remove_short_codes($description);
|
615 |
|
616 |
+
# Set Variation Short Description
|
617 |
+
$short_description=$variation->get_short_description();
|
618 |
+
if(empty($short_description)){
|
619 |
+
$short_description=$parent->get_short_description();
|
620 |
+
}
|
621 |
+
$short_description=$this->remove_short_codes($short_description);
|
622 |
+
|
623 |
+
$this->productsList[ $this->pi ]["id"] = $variation->get_id();
|
624 |
+
$this->productsList[ $this->pi ]["title"] = $variationTitle;
|
625 |
+
$this->productsList[ $this->pi ]["description"] = $description;
|
626 |
+
$this->productsList[ $this->pi ]['variation_type'] = $variation->get_type();
|
627 |
+
|
628 |
+
$this->productsList[ $this->pi ]['short_description'] = $short_description;
|
629 |
+
$this->productsList[ $this->pi ]['product_type'] = strip_tags(wc_get_product_category_list($variation->get_parent_id(),">",""));
|
630 |
+
$this->productsList[ $this->pi ]['link'] = $variation->get_permalink();
|
631 |
+
$this->productsList[ $this->pi ]['ex_link'] = $variation->get_permalink();
|
632 |
+
|
633 |
+
|
634 |
+
# Featured Image
|
635 |
+
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
|
636 |
+
if ( has_post_thumbnail( $id ) && !empty($image[0])):
|
637 |
+
|
638 |
+
$this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
|
639 |
+
$this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
|
640 |
+
else:
|
641 |
+
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $variation->get_parent_id() ), 'single-post-thumbnail' );
|
642 |
+
$this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
|
643 |
+
$this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
|
644 |
+
endif;
|
645 |
+
|
646 |
+
# Additional Images
|
647 |
+
$attachmentIds = $variation->get_gallery_image_ids();
|
648 |
+
$imgUrls = array();
|
649 |
+
if ( $attachmentIds && is_array( $attachmentIds ) ) {
|
650 |
+
$mKey = 1;
|
651 |
+
foreach ( $attachmentIds as $attachmentId ) {
|
652 |
+
$imgUrls[$mKey] =$this->get_formatted_url( wp_get_attachment_url( $attachmentId ));
|
653 |
+
$this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[$mKey];
|
654 |
+
$mKey ++;
|
655 |
+
}
|
656 |
+
|
657 |
+
}
|
658 |
+
|
659 |
+
$this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
|
660 |
+
$this->productsList[ $this->pi ]['condition'] = "New";
|
661 |
+
$this->productsList[ $this->pi ]['type'] = $variation->get_type();
|
662 |
+
$this->productsList[ $this->pi ]['is_bundle'] = "no";
|
663 |
+
$this->productsList[ $this->pi ]['multipack'] = "";
|
664 |
+
$this->productsList[ $this->pi ]['visibility'] = $variation->get_catalog_visibility();
|
665 |
+
$this->productsList[ $this->pi ]['rating_total'] = $variation->get_rating_count();
|
666 |
+
$this->productsList[ $this->pi ]['rating_average'] = $variation->get_average_rating();
|
667 |
+
$this->productsList[ $this->pi ]['tags'] = strip_tags(wc_get_product_tag_list($id,","));
|
668 |
+
$this->productsList[ $this->pi ]['item_group_id'] = $variation->get_parent_id();
|
669 |
+
$this->productsList[ $this->pi ]['sku'] = $variation->get_sku();
|
670 |
+
$this->productsList[ $this->pi ]['availability'] = $this->availability( $id );
|
671 |
+
$this->productsList[ $this->pi ]['quantity'] = $variation->get_stock_quantity();
|
672 |
+
$this->productsList[ $this->pi ]['sale_price_sdate'] = $variation->get_date_on_sale_from();
|
673 |
+
$this->productsList[ $this->pi ]['sale_price_edate'] = $variation->get_date_on_sale_to();
|
674 |
+
$this->productsList[ $this->pi ]['price'] = $variation->get_regular_price();
|
675 |
+
$this->productsList[ $this->pi ]['sale_price'] = $variation->get_sale_price();
|
676 |
+
$this->productsList[ $this->pi ]['weight'] = $variation->get_weight();
|
677 |
+
$this->productsList[ $this->pi ]['width'] = $variation->get_width();
|
678 |
+
$this->productsList[ $this->pi ]['height'] = $variation->get_height();
|
679 |
+
$this->productsList[ $this->pi ]['length'] = $variation->get_length();
|
680 |
+
$this->productsList[ $this->pi ]['shipping_class'] = $variation->get_shipping_class();
|
681 |
+
|
682 |
+
|
683 |
+
# Sale price effective date
|
684 |
+
$from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
|
685 |
+
$to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
|
686 |
+
if ( ! empty( $from ) && ! empty( $to ) ) {
|
687 |
+
$from = date( "c", strtotime( $from ) );
|
688 |
+
$to = date( "c", strtotime( $to ) );
|
689 |
+
$this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
|
690 |
+
} else {
|
691 |
+
$this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
|
692 |
+
}
|
693 |
+
|
694 |
+
# Get all Attributes and their values
|
695 |
+
$data=$variation->get_data();
|
696 |
+
$attributes=$data['attributes'];
|
697 |
+
if(!empty($attributes)){
|
698 |
+
foreach ($attributes as $aKey=>$attr){
|
699 |
+
$this->productsList[ $this->pi ][$aKey] = $variation->get_attribute($aKey);
|
700 |
+
}
|
701 |
+
}
|
702 |
+
|
703 |
+
|
704 |
+
// # Get all Product Post Meta and Their Values
|
705 |
+
// $metas=get_post_meta($id);
|
706 |
+
// if(!empty($metas)){
|
707 |
+
// foreach ($metas as $mKey=>$meta){
|
708 |
+
// if($mKey!="_product_attributes"){
|
709 |
+
// $metaValue=get_post_meta($id,$mKey,true);
|
710 |
+
// $this->productsList[ $this->pi ]["wf_cattr_".$mKey]=(!empty($metaValue))?$metaValue:"";
|
711 |
+
// }
|
712 |
+
// }
|
713 |
+
// }
|
714 |
+
//
|
715 |
+
// # Get all Product Taxonomies and Their values
|
716 |
+
// $taxonomies=get_post_taxonomies($id);
|
717 |
+
// if(!empty($taxonomies)){
|
718 |
+
// foreach ($taxonomies as $tKey=>$taxonomy){
|
719 |
+
// $this->productsList[ $this->pi ]["wf_taxo_".$taxonomy]=strip_tags(get_the_term_list($id,$taxonomy,"",",",""));
|
720 |
+
// }
|
721 |
+
// }
|
722 |
}
|
723 |
|
724 |
$this->pi ++;
|
woo-feed.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
* Plugin Name: WooCommerce Product Feed
|
17 |
* Plugin URI: https://webappick.com/
|
18 |
* Description: This plugin generate WooCommerce product feed for Shopping Engines like Google Shopping,Facebook Product Feed,eBay,Amazon,Idealo and many more..
|
19 |
-
* Version: 2.2.
|
20 |
* Author: WebAppick
|
21 |
* Author URI: https://webappick.com/
|
22 |
* License: GPL v2
|
@@ -272,21 +272,32 @@ add_action('wp_ajax_get_product_information', 'woo_feed_get_product_information'
|
|
272 |
function woo_feed_get_product_information(){
|
273 |
check_ajax_referer('wpf_feed_nonce');
|
274 |
|
275 |
-
if(woo_feed_wc_version_check(3.2)){
|
276 |
-
$query=new WC_Product_Query(array(
|
277 |
-
'limit' => -1,
|
278 |
-
'status' => 'publish',
|
279 |
-
'orderby' => 'date',
|
280 |
-
'order' => 'DESC',
|
281 |
-
'return' => 'ids',
|
282 |
-
));
|
283 |
-
$products=$query->get_products();
|
284 |
-
$totalProducts=count($products);
|
285 |
-
}else{
|
286 |
-
$products=wp_count_posts('product');
|
287 |
-
$variations=wp_count_posts('product_variation');
|
288 |
-
$totalProducts=$products->publish + $variations->publish;
|
289 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
$data=array('product'=>$totalProducts);
|
292 |
|
16 |
* Plugin Name: WooCommerce Product Feed
|
17 |
* Plugin URI: https://webappick.com/
|
18 |
* Description: This plugin generate WooCommerce product feed for Shopping Engines like Google Shopping,Facebook Product Feed,eBay,Amazon,Idealo and many more..
|
19 |
+
* Version: 2.2.7
|
20 |
* Author: WebAppick
|
21 |
* Author URI: https://webappick.com/
|
22 |
* License: GPL v2
|
272 |
function woo_feed_get_product_information(){
|
273 |
check_ajax_referer('wpf_feed_nonce');
|
274 |
|
275 |
+
// if(woo_feed_wc_version_check(3.2)){
|
276 |
+
// $query=new WC_Product_Query(array(
|
277 |
+
// 'limit' => -1,
|
278 |
+
// 'status' => 'publish',
|
279 |
+
// 'orderby' => 'date',
|
280 |
+
// 'order' => 'DESC',
|
281 |
+
// 'return' => 'ids',
|
282 |
+
// ));
|
283 |
+
// $products=$query->get_products();
|
284 |
+
// $totalProducts=count($products);
|
285 |
+
// }else{
|
286 |
+
// $products=wp_count_posts('product');
|
287 |
+
// $variations=wp_count_posts('product_variation');
|
288 |
+
// $totalProducts=$products->publish + $variations->publish;
|
289 |
+
// }
|
290 |
+
|
291 |
+
global $wpdb;
|
292 |
+
$query = "SELECT DISTINCT {$wpdb->prefix}posts.ID
|
293 |
+
FROM {$wpdb->prefix}posts
|
294 |
+
LEFT JOIN {$wpdb->prefix}term_relationships ON ({$wpdb->prefix}posts.ID = {$wpdb->prefix}term_relationships.object_id)
|
295 |
+
LEFT JOIN {$wpdb->prefix}term_taxonomy ON ({$wpdb->prefix}term_relationships.term_taxonomy_id = {$wpdb->prefix}term_taxonomy.term_taxonomy_id)
|
296 |
+
WHERE {$wpdb->prefix}posts.post_type IN ('product','product_variation') AND {$wpdb->prefix}posts.post_status = 'publish'
|
297 |
+
ORDER BY ID";
|
298 |
+
$products = $wpdb->get_results($query, OBJECT );
|
299 |
+
|
300 |
+
$totalProducts=count($products);
|
301 |
|
302 |
$data=array('product'=>$totalProducts);
|
303 |
|