WebDevStudios / wp-search-with-algolia

Improve search on your site. Autocomplete is included, along with full control over look, feel and relevance.
https://wordpress.org/plugins/wp-search-with-algolia/
138 stars 54 forks source link

On single product update image is removed #381

Closed atindersingh67 closed 9 months ago

atindersingh67 commented 9 months ago

Describe the bug I am using this plugin and facing one issue. If i do re index all content i can see the image urls in my algolia index. But on update of a single product it removes the image url from my algolia index for that product. I am using external image plugin for the images

To Reproduce Steps to reproduce the behavior: 1.Install External Image Plugin

  1. Create a product and add image as a url.
  2. Save product and re index all content.
  3. now edit the same product and just click on update button. the image will be removed from algolia index.

Expected behavior On edit product it should update or persist the image in the algolia index.

tw2113 commented 9 months ago

Hi @atindersingh67

Since this sounds very familiar, do you have an open issue on our support forums already? I know we have at least 1 forum thread about external images.

Because of that, my question still stands about order of operation and if the meta data is saved to the post already at the time of indexing, or if this external image data is being pulled in afterwards. We can't control via our plugin, what information is available at the time of indexing, thus we push what is available.

atindersingh67 commented 9 months ago

Hi @tw2113

No i did not raised this in support forum. Yes meta data is already available to the post at the time of indexing.

tw2113 commented 9 months ago

What plugin are you using for the external image aspect?

To be certain, have you checked the meta data inside the WP install to confirm, I assume, the URL is in fact saved as part of the object data?

atindersingh67 commented 9 months ago

I am using https://www.wpintense.com/product/external-images/ this plugin for external images.

Yes the url is saved as part of object. and more over if i do re index all the data it do re index the images as well

tw2113 commented 9 months ago

hmm. I'm not going to have access to that plugin, so it's hard for me to do any testing on my own.

I would assume as long as the image URL is on the algolia object/hit, it would be able to be used. Much like the permalink property is.

The only other idea I have would be somehow checking the state of the records at this point in the code: https://github.com/WebDevStudios/wp-search-with-algolia/blob/main/includes/indices/class-algolia-index.php#L379-L383

This would need to be done with something like XDebug or similar so that you can inspect everything right before the push to Algolia, to see/confirm what data is going to be put into the record.

tw2113 commented 9 months ago

Hi again @atindersingh67

It's my understanding that you're working with a person named Mark, and you're the developer of the duo. I also am seeing a correlation in user/email, which helps confirm.

Not sure if you've been reading the correspondence that I know you're CC'd on, but just in case not, I'm going to paste a reply from that support ticket here, as regarding my most recent suspicions around this issue.

Original reply:

Definitely following overall with the images and whatnot, thank you for that.

Definitely also seeing the empty array for the image property, even via the frontend with browser developer console. See attached.

As is, I’m suspecting that the plugin isn’t finding image information at the correct time, which I’ve generally said already, but I have more leads now.

We use this function to fetch image information, during the indexing process https://github.com/WebDevStudios/wp-search-with-algolia/blob/main/includes/class-algolia-utils.php#L105-L141

It makes use of the wp_get_attachment_image_src() function from WP core, and on line 127, if it didn’t get anything back, it moves on to the next image size. I’m wondering if this is the point of failure in this case.

That said, we have the algolia_get_post_images filter available, and I’m wondering if this is a case where you could potentially filter in the URL and dimensions. Although it doesn’t explain why the re-index works, unless line 127 is no longer failing at that point.

Are you by any chance able to recreate the issue with a local install, one that perhaps has debugging tools available to it like XDebug? I'd be really curious to see if that $info = wp_get_attachment_image_src( $post_thumbnail_id, $size ); line is sometimes not finding image data yet, thus causing empty image data for the Algolia indexed object.

tw2113 commented 9 months ago

Hi again @atindersingh67

Question for you, does the external image url and whatnot get stored as custom field data? If yes, I have some code for you to test some functionality with.

tw2113 commented 9 months ago

@atindersingh67 Any news or changes here? We have what we feel may be a solid lead with some things that could help with this.

tw2113 commented 9 months ago

I have been informed that Algolia has been moved away from by the original reporter, so closing this as a non-issue at the moment.