Skip to content

Commit

Permalink
Merge pull request #74 from w3bdesign/develop
Browse files Browse the repository at this point in the history
Fix Algolia images
  • Loading branch information
w3bdesign authored Sep 14, 2020
2 parents a6f18a0 + a80be14 commit 860a56a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
10 changes: 5 additions & 5 deletions algolia-woo-indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 6 additions & 11 deletions classes/class-algolia-woo-indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,19 +503,14 @@ 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( '/<img.*?src=[\'"]( . * ? )[\'"].*?>/i', $product->get_image(), $matches );
$product_image = implode( $matches[1] );
preg_match('/<img(.*)src(.*)=(.*)"(.*)"/U', $product->get_image(), $result);
$product_image = array_pop($result);
/**
* Build the record array using the information from the WooCommerce product
*/
Expand All @@ -534,12 +529,12 @@ 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_all( '/<img.*?src=[\'"]( . * ? )[\'"].*?>/i', $product->get_image(), $matches );
$product_image = implode( $matches[1] );
preg_match('/<img(.*)src(.*)=(.*)"(.*)"/U', $product->get_image(), $result);
$product_image = array_pop($result);

/**
* Build the record array using the information from the WooCommerce product
*/
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 860a56a

Please sign in to comment.