magmodules / magento2-sooqr

Sooqr Connect for Magento® 2
https://www.magmodules.eu/sooqr-connect.html
Other
2 stars 3 forks source link

Lower scope images not having types resulting in missing image links #62

Closed jdereus87 closed 3 months ago

jdereus87 commented 6 months ago

Describe the bug After a magento update from 2.4.2 to 2.4.6-p3 and the sooqr update from 1.1.8 to 2.0.3 about 70 of the 3000 products are missing an image(link) in the feed.

To Reproduce Run the feed. I have debugged using xDebug. The following seems to happen

  1. Magmodules\Sooqr\Model\ProductData\Repository->getProductData():138 retrieves the image data from the Magmodules\Sooqr\Service\ProductData\AttributeCollector\Data class in which you combine images and types
  2. Magmodules\Sooqr\Model\ProductData\Repository->addImageData():248 gets its image data from the prepared image data.
  3. addImageData():279 sometimes has a storeId = 0 array or sometimes a 0 and 1 store arrays. It loops through 0 or 1 depending on on its presence. However when looping through store 1, it finds images, but it does not find an image with a 'image' type set, resulting in a empty image link.
  4. empty image link -> empty image on the feed -> empty image on sooqr.

Expected behavior All products in the feed have images

Actual behavior Some products are missing images.

The above can ofcourse also be a misconfiguration resulting from the update and/or something else. But if there is no image link found in store 1, is it not better to have a fallback on scope 0?

Frank-Magmodules commented 6 months ago

Hello @jdereus87 , we appreciate your detailed issue description and the effort you've put into debugging this. We've managed to reproduce the issue and are now actively working on finding a solution. We'll keep you updated and share the resolution with you as soon as it's available!

Frank-Magmodules commented 6 months ago

Hi There @jdereus87 ,

It seems there wasn't a fallback mechanism in place for cases where there was no small_image, thumbnail, or image set in the gallery. We've fixed this by implementing a fix that sets the first image as a fallback before attempting to retrieve the correct image. Could you please try again using the updated branch available here: https://github.com/magmodules/magento2-sooqr/tree/fix/62-image-fallback

Please inform me if this solution functions as expected. If it does, we'll proceed to merge it into the upcoming release.

jdereus87 commented 6 months ago

@Frank-Magmodules I tested your fix. I think as a fallback it works well (even better then my fix, since it guarantees there is always an image set). A small drawback is however that in the cases the fallback is needed, it might not set the base image selected by the merchant on the global scope.

I composer patched it by just using your loop a second time (though I admit it might not be the most elegant way): if(empty($productData['image'])){ ksort($imageData[0]); foreach ($imageData[0] as $image) { if (in_array($imageSource, $image['types'])) { $productData['image'] = $image['file']; } } } I think combining your fix with my suggestion above would cover everything in this niche case. Thanks again for taking up this issue.

Marvin-Magmodules commented 6 months ago

Hi @jdereus87, we need a bit more time for this, as found some inconsistencies and having a hard time reproducing this. Can you confirm that the media_gallery attribute is set to Global scope? As looks like on a vanilla Magento installation this behavior is not reproducible. Nevertheless we are trying to make the right edits for this (in the meantime merged the fallback for partial fix of the issue).

Frank-Magmodules commented 4 months ago

Hey there @jdereus87, since this issue has been ongoing for a while, I'm curious if it's still persisting in the latest version of the plugin as we've made quite a few improvements and changes to the feed. Thanks a bunch!

Frank-Magmodules commented 4 months ago

HI, There @jdereus87 ,

Hereby an extra notification on this issue that you reported earlier. We rolled out a new version featuring overall improvements to the parent/simple relations as well as the image links. Could you kindly confirm if this also addresses the issue you reported?

Frank-Magmodules commented 3 months ago

Hi @jdereus87,

Due to inactivity, I’m closing this issue for now. If it is still relevant to you, please feel free to reopen it or contact us directly.