statamic-rad-pack / shopify

Integrate your Shopify products into Statamic using the Admin API.
https://statamic.com/addons/rad-pack/shopify
Other
8 stars 5 forks source link

Bug: Product image URLs are getting appended with numbers #86

Closed austriker27 closed 3 years ago

austriker27 commented 3 years ago

This just started at least a week ago? days ago, but basically looks the addon might have a bug that keeps adding a string of numbers to the end of product Image URLs. It happens every time I import which results in dozens of duplicate image files.

I updated to v1.5.2 but it still happens whenever I import an item. Erin in the discord said its probably a bug because it looks like a timestamp.

Diff screenshot:

image

Originally posted by @austriker27 in https://github.com/jackabox/statamic-shopify/discussions/85

jackabox commented 3 years ago

Is this a new thing, or has it always been doing this for you?

austriker27 commented 3 years ago

Is this a new thing, or has it always been doing this for you?

New-ish. Probably at least a week or two. Ill try to find when it started exactly.

jackabox commented 3 years ago

Is this a new thing, or has it always been doing this for you?

New-ish. Probably at least a week or two. Ill try to find when it started exactly.

No problem, if you can that would help. Along with your composer installed versions :)

austriker27 commented 3 years ago
jackabox commented 3 years ago

Cheers, sorry - the composer installed versions. Did you update Statamic/What version of the plugins did you have at each time?

austriker27 commented 3 years ago

Cheers, sorry - the composer installed versions. Did you update Statamic/What version of the plugins did you have at each time?

Ha, oops - sorry my bad!

Here's what Ive got in my composer:

 "php": "^7.3 || ^8.0",
        "aerni/imagekit": "^2.2",
        "andymnewhouse/radnight": "^1.0",
        "doublethreedigital/blaze": "^1.0",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "jackabox/statamic-shopify": "^1.5",
        "laravel/framework": "^8.0",
        "laravel/tinker": "^2.0",
        "league/flysystem-aws-s3-v3": "^1.0",
        "league/flysystem-cached-adapter": "^1.1",
        "mattrothenberg/statamic-mapbox-address": "^0.6.0",
        "simonhamp/statamic-heroicons": "^1.0",
        "spatie/browsershot": "^3.45",
        "statamic/cms": "3.1.*"

link

austriker27 commented 3 years ago

Hey Jack, any suggestions or progress on this bug? Sorry to bug you but it's pretty annoying every time I import my products... I have 50+ items and Im going through them one by one and removing the timestamp URL bits.

Thanks!

jackabox commented 3 years ago

Hey @austriker27, can you try installing the latest 1.x-dev branch changes and see if that fixes your issue?

austriker27 commented 3 years ago

Hey @austriker27, can you try installing the latest 1.x-dev branch changes and see if that fixes your issue?

Sorry I finally found some time to test this! And sadly the file appending is still happening.

What I did

The dev branch

FYI I used dev- in front of your branch name based on this SO (I didnt know this so Erin from discord helped me) thus "jackabox/statamic-shopify": "dev-1.x-dev", https://stackoverflow.com/questions/33525885/composer-require-branch-name

Screenshot of the diff:

image

jackabox commented 3 years ago

@austriker27 Got it, this isn't a bug.

The reason this seems to be happening is as one is added to the "Featured image" and the same image is added to the "gallery". This is the same image/filename but it appends the date/time because of it.

I cannot replicate these changing the timestamps locally without having changed the images on the Shopify side.

Potentially, try deleting all of the media for your products and re-importing them.

austriker27 commented 3 years ago

@austriker27 Got it, this isn't a bug.

The reason this seems to be happening is as one is added to the "Featured image" and the same image is added to the "gallery". This is the same image/filename but it appends the date/time because of it.

I cannot replicate these changing the timestamps locally without having changed the images on the Shopify side.

Potentially, try deleting all of the media for your products and re-importing them.

But this even happens when an image is in the "gallery" and is not a "featured image". This happens for all my images, not just the featured image.

Ill test deleting the image for a product and reimporting because Im desperate for a fix because right now its a giant pain manually removing image URL suffixes whenever I import my products (and I import a lot of and have a lot of images)

EDIT: After further testing, I recant! It looks like it might be only happening for the feature image like you said! Hmmmm this is a pretty not great situation because every time I run an import of products (to update quantities) then I get duplicated images. Right now I've got probably a dozen duplicated images for my 50+ products... I wonder if there's a better way than using the timestamp to append a string on to the images.

austriker27 commented 3 years ago

Im still getting this and its causing me to spend hours each week removing duplicate image suffixes - any ideas on whats going on? Im not entirely convinced its not a bug.

Screenshot showing its more than just the featured image: image

jackabox commented 3 years ago

Hey @austriker27, it's on my radar. Can I get access to your code base so I can pull it down and clone it (if that's okay) and see if I can replicate as in my 3 test environments I can't get this to replicate.

austriker27 commented 3 years ago

Hey @austriker27, it's on my radar. Can I get access to your code base so I can pull it down and clone it (if that's okay) and see if I can replicate as in my 3 test environments I can't get this to replicate.

Thank you - I'd love your expert eyes on this.

I added you to my repo!

jackabox commented 3 years ago

Hey @austriker27

The problem lies in your .env file, you currently have a / before the SHOPIFY_ASSET_PATH, as so:

SHOPIFY_ASSET_PATH="/shopify"

where it should be:

SHOPIFY_ASSET_PATH="shopify"

This leads the plugin to not find the image and returns null, so reuploads it again. The timestamp is being added as it's trying not to overwrite the old one. If you remove the / everything should work as expected.

My bad on this one, I need to ensure the docs are updated on this as these are missing.

austriker27 commented 3 years ago

Hey @austriker27

The problem lies in your .env file, you currently have a / before the SHOPIFY_ASSET_PATH, as so:

SHOPIFY_ASSET_PATH="/shopify"

where it should be:

SHOPIFY_ASSET_PATH="shopify"

This leads the plugin to not find the image and returns null, so reuploads it again. The timestamp is being added as it's trying not to overwrite the old one. If you remove the / everything should work as expected.

My bad on this one, I need to ensure the docs are updated on this as these are missing.

Oh gosh, I feel like I should have caught that too. Thanks so much for digging in! I can't wait to test this out!!