@@ -45,7 +45,15 @@ public function __wakeup() {
4545 throw new \Exception ( 'Cannot serialize singleton ' );
4646 }
4747
48- public function get_list_args () {
48+ /**
49+ * Get default query args to retrieve products for the feed.
50+ *
51+ * @param string $lang The current language associated with the feed. Language slug or empty string if
52+ * site isn't multilingual.
53+ *
54+ * @return array
55+ */
56+ public function get_list_args ( $ lang = '' ) {
4957 $ default_args = array (
5058 'limit ' => - 1 ,
5159 'orderby ' => 'date ' ,
@@ -61,7 +69,7 @@ public function get_list_args() {
6169 /**
6270 * Export only the categories selected in BO
6371 */
64- $ current_language = ShoppingFeedHelper::current_language ();
72+ $ current_language = ! empty ( $ lang ) ? $ lang : ShoppingFeedHelper::current_language ();
6573 $ export_categories = ShoppingFeedHelper::get_sf_feed_export_categories ( $ current_language );
6674 if ( ! empty ( $ export_categories ) ) {
6775 $ categories = [];
@@ -76,7 +84,7 @@ public function get_list_args() {
7684 $ default_args ['category ' ] = $ categories ;
7785 }
7886
79- return wp_parse_args ( ShoppingFeedHelper::wc_products_custom_query_args (), $ default_args );
87+ return wp_parse_args ( ShoppingFeedHelper::wc_products_custom_query_args ( $ lang ), $ default_args );
8088 }
8189
8290 /**
@@ -92,8 +100,17 @@ public function get_list() {
92100 }
93101 }
94102
95- public function get_products ( $ args = array () ) {
96- $ query = new \WC_Product_Query ( wp_parse_args ( $ args , $ this ->get_list_args () ) );
103+ /**
104+ * Get a list of product to include in the feed.
105+ *
106+ * @param array $args Query args for the `WC_Product_Query`.
107+ * @param string $lang The current language associated with the feed. Language slug or empty string if
108+ * site isn't multilingual.
109+ *
110+ * @return array
111+ */
112+ public function get_products ( $ args = array (), $ lang = '' ) {
113+ $ query = new \WC_Product_Query ( wp_parse_args ( $ args , $ this ->get_list_args ( $ lang ) ) );
97114
98115 return $ query ->get_products ();
99116 }
0 commit comments