From 9f65c541d387c89587cd138c7859ed57ff2d1b17 Mon Sep 17 00:00:00 2001 From: w3bdesign <45217974+w3bdesign@users.noreply.github.com> Date: Tue, 15 Sep 2020 00:37:01 +0200 Subject: [PATCH 1/6] Debug Woo images --- classes/class-algolia-woo-indexer.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/classes/class-algolia-woo-indexer.php b/classes/class-algolia-woo-indexer.php index cd4462d..e753e48 100644 --- a/classes/class-algolia-woo-indexer.php +++ b/classes/class-algolia-woo-indexer.php @@ -503,17 +503,13 @@ function () { foreach ( $products as $product ) { /** - * Check if product is in stock if $index_in_stock is set to 0 + * Check if product is in stock if $index_in_stock is set to 1 */ if ( '1' === $index_in_stock && $product->is_in_stock() ) { /** * Extract image from $product->get_image() */ - - print_r ( $product->get_image()); - - preg_match_all( '//i', $product->get_image(), $matches ); $product_image = implode( $matches[1] ); /** @@ -538,6 +534,12 @@ function () { /** * Extract image from $product->get_image() */ + + + print_r ( $product->get_image()); + die("Images"); + wp_die("Images"); + preg_match_all( '//i', $product->get_image(), $matches ); $product_image = implode( $matches[1] ); /** From ff2e758db3937fb560dbd652faffcb9ff8f9fc0f Mon Sep 17 00:00:00 2001 From: w3bdesign <45217974+w3bdesign@users.noreply.github.com> Date: Tue, 15 Sep 2020 00:40:09 +0200 Subject: [PATCH 2/6] Debug image matches --- classes/class-algolia-woo-indexer.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/classes/class-algolia-woo-indexer.php b/classes/class-algolia-woo-indexer.php index e753e48..0e1343c 100644 --- a/classes/class-algolia-woo-indexer.php +++ b/classes/class-algolia-woo-indexer.php @@ -536,12 +536,24 @@ function () { */ - print_r ( $product->get_image()); - die("Images"); - wp_die("Images"); + + preg_match_all( '//i', $product->get_image(), $matches ); $product_image = implode( $matches[1] ); + + + echo "Matches: "; + print_r($matches); + + + + + + + die("Images"); + wp_die("Images"); + /** * Build the record array using the information from the WooCommerce product */ From 3f9a6c89258c750647293583844395ad625028ed Mon Sep 17 00:00:00 2001 From: w3bdesign <45217974+w3bdesign@users.noreply.github.com> Date: Tue, 15 Sep 2020 00:44:47 +0200 Subject: [PATCH 3/6] Increase version number --- algolia-woo-indexer.php | 10 +++++----- classes/class-algolia-woo-indexer.php | 8 ++++++++ readme.txt | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/algolia-woo-indexer.php b/algolia-woo-indexer.php index 565eab2..61085c7 100644 --- a/algolia-woo-indexer.php +++ b/algolia-woo-indexer.php @@ -5,11 +5,11 @@ * Text Domain: algolia-woo-indexer * Author: Daniel F * Requires at least: 5.3 - * Tested up to: 5.4 - * Requires PHP: 7.2 - * WC requires at least: 4.2.0 - * WC tested up to: 4.3.0 - * Version: 1.0.1 + * Tested up to: 5.5 + * Requires PHP: 7.3 + * WC requires at least: 4.5.0 + * WC tested up to: 4.5.2 + * Version: 1.0.2 * * @package algolia-woo-indexer * @license GNU version 3 diff --git a/classes/class-algolia-woo-indexer.php b/classes/class-algolia-woo-indexer.php index 0e1343c..95e2fa7 100644 --- a/classes/class-algolia-woo-indexer.php +++ b/classes/class-algolia-woo-indexer.php @@ -546,6 +546,14 @@ function () { echo "Matches: "; print_r($matches); + echo "Image: "; + + print_r($product->get_image()); + + echo ($product->get_image()); + + echo "Matches: "; + diff --git a/readme.txt b/readme.txt index 36c8fe6..f71bd9e 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: Daniel F Tags: algolia, woocommerce, search, algolia search, algolia indexing Requires at least: not tested -Tested up to: 5.4 +Tested up to: 5.5.1 Stable tag: 1.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html From be3d7ca2eb6369bd748d3242b51d9d95e23d0bed Mon Sep 17 00:00:00 2001 From: w3bdesign <45217974+w3bdesign@users.noreply.github.com> Date: Tue, 15 Sep 2020 00:51:21 +0200 Subject: [PATCH 4/6] Update class-algolia-woo-indexer.php --- classes/class-algolia-woo-indexer.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/classes/class-algolia-woo-indexer.php b/classes/class-algolia-woo-indexer.php index 95e2fa7..3c0638a 100644 --- a/classes/class-algolia-woo-indexer.php +++ b/classes/class-algolia-woo-indexer.php @@ -540,11 +540,16 @@ function () { preg_match_all( '//i', $product->get_image(), $matches ); + + $product_image = implode( $matches[1] ); + preg_match('/get_image(), $result); + $foo = array_pop($result); - echo "Matches: "; - print_r($matches); + + echo "Foo Matches: "; + print_r($foo); echo "Image: "; From 3688f53833ef316f40de1eb93e7ea8ac22f785aa Mon Sep 17 00:00:00 2001 From: w3bdesign <45217974+w3bdesign@users.noreply.github.com> Date: Tue, 15 Sep 2020 00:53:55 +0200 Subject: [PATCH 5/6] Fix images with Algolia search --- classes/class-algolia-woo-indexer.php | 37 +++------------------------ 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/classes/class-algolia-woo-indexer.php b/classes/class-algolia-woo-indexer.php index 3c0638a..8e4bfcd 100644 --- a/classes/class-algolia-woo-indexer.php +++ b/classes/class-algolia-woo-indexer.php @@ -510,8 +510,8 @@ function () { /** * Extract image from $product->get_image() */ - preg_match_all( '//i', $product->get_image(), $matches ); - $product_image = implode( $matches[1] ); + preg_match('/get_image(), $result); + $product_image = array_pop($result); /** * Build the record array using the information from the WooCommerce product */ @@ -533,39 +533,10 @@ function () { /** * Extract image from $product->get_image() - */ - - - - - - preg_match_all( '//i', $product->get_image(), $matches ); - - - $product_image = implode( $matches[1] ); + */ preg_match('/get_image(), $result); - $foo = array_pop($result); - - - echo "Foo Matches: "; - print_r($foo); - - echo "Image: "; - - print_r($product->get_image()); - - echo ($product->get_image()); - - echo "Matches: "; - - - - - - - die("Images"); - wp_die("Images"); + $product_image = array_pop($result); /** * Build the record array using the information from the WooCommerce product From a80be14f576eb65e6afc819f2538a82677e7290a Mon Sep 17 00:00:00 2001 From: w3bdesign <45217974+w3bdesign@users.noreply.github.com> Date: Tue, 15 Sep 2020 01:02:24 +0200 Subject: [PATCH 6/6] Update class-algolia-woo-indexer.php --- classes/class-algolia-woo-indexer.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/classes/class-algolia-woo-indexer.php b/classes/class-algolia-woo-indexer.php index 8e4bfcd..5650911 100644 --- a/classes/class-algolia-woo-indexer.php +++ b/classes/class-algolia-woo-indexer.php @@ -506,7 +506,6 @@ function () { * Check if product is in stock if $index_in_stock is set to 1 */ if ( '1' === $index_in_stock && $product->is_in_stock() ) { - /** * Extract image from $product->get_image() */ @@ -530,11 +529,9 @@ function () { * Do not check if product is in stock if $index_in_stock is set to 0 */ if ( '0' === $index_in_stock ) { - /** * Extract image from $product->get_image() - */ - + */ preg_match('/get_image(), $result); $product_image = array_pop($result);