From ee123fb7391310852304d803572b2491b1c80eeb Mon Sep 17 00:00:00 2001 From: Fulvio Notarstefano Date: Tue, 19 Dec 2017 10:18:33 +0800 Subject: [PATCH 1/2] [#18223] Add argument to woocommerce_product_related_posts_query filter --- .../data-stores/class-wc-product-data-store-cpt.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/data-stores/class-wc-product-data-store-cpt.php b/includes/data-stores/class-wc-product-data-store-cpt.php index 1a54ba5240d..290aab76a78 100644 --- a/includes/data-stores/class-wc-product-data-store-cpt.php +++ b/includes/data-stores/class-wc-product-data-store-cpt.php @@ -1015,7 +1015,17 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da */ public function get_related_products( $cats_array, $tags_array, $exclude_ids, $limit, $product_id ) { global $wpdb; - return $wpdb->get_col( implode( ' ', apply_filters( 'woocommerce_product_related_posts_query', $this->get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit + 10 ), $product_id ) ) ); + + $args = array( + 'categories' => $cats_array, + 'tags' => $tags_array, + 'exclude_ids' => $exclude_ids, + 'limit' => $limit + 10, + ); + + $related_product_ids = (array) apply_filters( 'woocommerce_product_related_posts_query', $this->get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit + 10 ), $product_id, $args ); + + return $wpdb->get_col( implode( ' ', $related_product_ids ) ); } /** From e718d7bd4099709464f598ecd0cdcc50b56770ed Mon Sep 17 00:00:00 2001 From: Fulvio Notarstefano Date: Tue, 19 Dec 2017 17:19:10 +0800 Subject: [PATCH 2/2] [#18223] Rename var to a more apt name --- includes/data-stores/class-wc-product-data-store-cpt.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/data-stores/class-wc-product-data-store-cpt.php b/includes/data-stores/class-wc-product-data-store-cpt.php index 290aab76a78..145563a2f12 100644 --- a/includes/data-stores/class-wc-product-data-store-cpt.php +++ b/includes/data-stores/class-wc-product-data-store-cpt.php @@ -1023,9 +1023,9 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da 'limit' => $limit + 10, ); - $related_product_ids = (array) apply_filters( 'woocommerce_product_related_posts_query', $this->get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit + 10 ), $product_id, $args ); + $related_product_query = (array) apply_filters( 'woocommerce_product_related_posts_query', $this->get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit + 10 ), $product_id, $args ); - return $wpdb->get_col( implode( ' ', $related_product_ids ) ); + return $wpdb->get_col( implode( ' ', $related_product_query ) ); } /**