Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Importer Issue with Magento 1.9.1 #183

Open
nasirali opened this issue Jan 24, 2015 · 36 comments
Open

Image Importer Issue with Magento 1.9.1 #183

nasirali opened this issue Jan 24, 2015 · 36 comments

Comments

@nasirali
Copy link

I am having issue right after i upload the images, i can see them in the front and back end. However, after few minutes pass, the images disappear and the product no longer shows the images. Perhaps the cache, not sure?

On one scenario, i uploaded the images for configurable product and went in the backend to SAVE the product with images manually. This actually held up and kept the images from disappearing. I cant open and save all the products manually, the images are gone long before i would be able to finish.

Does anyone have any idea why the images arent staying put after uploading? I am using magmi v0.7.21, this start happening, i believe after i upgrade magento to 1.9.1 from 1.9.0.1.

@nasirali
Copy link
Author

I upgrade it to v0.7.22 from this git repo. I am still having the same issue.

@trs998
Copy link
Contributor

trs998 commented Jan 27, 2015

Magento 1.9.0.1 and magmi 0.7.21 - does not exhibit this issue for me.
Tested using simple products, cache enabled (clear after import to show new images on frontend)

@gfxguru
Copy link

gfxguru commented Feb 18, 2015

I can import images and view with rwd theme w/ 1.9.1

@galacticus
Copy link

I'm finding exactly the same problem with Magento 1.9.1. I am trying to import many images in the media_gallery. The import immediately shows all the images in the product in the back-end, but not on the front-end. When I click save product in the back-end all but one image disappear and I get an SQL foreign key error. I tested the same CSV file on a Magento 1.9.0.1 installation and it works just fine. I updated Magmi to 0.7.22, but I have no joy. There is definitely something up with Magento 1.9.1.

@JustinElst
Copy link
Contributor

Try disabling configurable swatches in
System > Configuration > Catalog > Configurable Swatches
That seems to fix the issue for me.
I dont know why Configurable Swatches is removing entries from the tables catalog_product_entity_media_gallery_value and catalog_product_entity_media_gallery. But ill try to find a fix..

@galacticus
Copy link

I will definitely give this a go. I wondered if the new swatches had something to do with this issue.

@straversnl
Copy link

I have the same problem, and haven't found the fix yet, but I know where the problem is. It is in app/code/core/Mage/ConfigurableSwatchers/Model/Observer. In the method loadChildProductImagesOnMediaLoad, at line 135 $eventWrapper->setProductIdsOverride($mediaProductIds);

If this line is removed, the images don't disappear. So we are a little bit closer to the problem and a fix.

Edit: This only works for the product page. The Observer is also doing something on the category (and search) pages, which removes the images. It has something to do with the function productListCollectionLoadAfter. This one calls $helper->attachGallerySetToCollection($products, $collection->getStoreId()).
In Mediafallback.php on line 321 in attachGallerySetToCollection, there is the line $images = $resourceModel->loadGallerySet($productIds, $storeId).

And in app/code/core/Mage/Catalog/model/Resource/Product/Attribute/Backend/Media.php _removeDuplicates is called from loadGallery. And there is the deleteGallery function, which can actually remove gallery images.

Edit2: temp solution. I have not tested if it breaks something, but this is my fix:
\app\code\core\Mage\ConfigurableSwatches\Helper\Mediafallback.php
line 321
$images = $resourceModel->loadGallerySet($productIds, $storeId);
$images = $resourceModel->loadGallerySet($productIds, $storeId, true);

\app\code\core\Mage\Catalog\Model\Resource\Product\Attribute\Backend\Media.php
line 288
public function loadGallerySet(array $productIds, $storeId) {
public function loadGallerySet(array $productIds, $storeId, $keepall=false) {
line 293
$this->_removeDuplicates($result);
$this->_removeDuplicates($result, $keepall);
line 83
$this->_removeDuplicates($result);
$this->_removeDuplicates($result, true);
line 93
protected function _removeDuplicates(&$result)
protected function _removeDuplicates(&$result,$keepall)
line 102
$this->deleteGallery($result[$index]['value_id']);
wordt:
if(!$keepall){
$this->deleteGallery($result[$index]['value_id']); //TODO Temp fix for media gallery problem. Core is edited, has to be fixed.
}

@dave-maude
Copy link

I also have this issue.

@Bert22, your solution meant that images all loaded into the product page where previously they didn't, but then they were deleted upon completion, meaning on the second page load, they were no longer there.

This behaviour does not seem to exist on images uploaded through the Magento admin interface. I will explore whether there are discrepancies in the database entries between Magmi and Magento admin next week.

@matteoperego
Copy link

this seems to appens if you use (import with magmi) the same image for more than one product. Duplicated images are searched through the image collection used by swatches, so all the image of all the simple product associated to a configurable one. A workaround would be to import images named differently for every product (even if the image is the same).

@PatrickCronin
Copy link
Contributor

My client is reporting that images are randomly disappearing from Magento when they open and save them in Magento's backend. We (proudly!) used Magmi to import the products, and do have multiple products with the same exact image. I'm not sure if our issue is the same as the one being reported here, however I thought I'd post in the case that anything is related. In our case, we have around 3000 configurable products, and around 9000 simples, most of which are variations of the configurables. In the last two months, we've only noticed 9 images disappear so far. They have only disappeared from configurable products; we have not noticed any images disappear from any simple products. The trigger for the images disappearing in our case appears to be when a product is opened for edit in Magento's backend. If we open a configurable product in the backend, "randomly" the product's image does not load with the model. Then when we save the product, it's saved without the image. This "randomness" happens whether or not we change any information on tab, and whether or not we visit the Image tab for the product. I haven't confirmed if images also disappear after being successfully loaded when the product is opened for edit. Another aspect I'm thinking of is that we've got the Better Configurable Products extension installed, and I've also rewritten the Product URL, Category URL and Catalog URL classes. Does any of this resonate with anyone else?

@COLASYSTEMS
Copy link

Does anyone have anything more up to date on this bug. It is a bad one. If you use swatches and then do any saving of configurable or associated simple products the images get screwed in the backend. They still seem to be ok on front end. But even then if you select a swatched product on the frontend it screws the images in the back end. Supposed to be going live soon with this .

@COLASYSTEMS
Copy link

@Bert22 thank you very much for taking the time to put that code up. I implemented it and it fixed the issues I was seeing. Obviously this is a core hack so will need to deal with that appropriately what ever that may be 2 days before live. !!

Thanks once again.

@PatrickCronin
Copy link
Contributor

To follow-up with my particular issue, which I'm still not sure is the same as the OP's: I isolated our issue to a data problem. A quick recap: products were displaying with their images without issue on the frontend, but when opened in Magento's backend, some did not appear, and then when saved in that screen, the affected images were no longer visible in the frontend as well.

The products whose images were disappearing upon being saved in Magento's backend product editor all shared an interesting characteristic: The images that happily appeared on the frontend were set in the product model in one or more of the product's image, small_image, or thumbnail attributes ($product->getImage(), $product->getSmallImage(), or $product->getImage(), but did not appear anywhere in the product's media_gallery attribute ($product->load('media_gallery'); $product->getMediaGallery();). When you add an image to a product, it should be inserted into the media_gallery no matter what [stored in catalog_product_entity_media_gallery], and then if it's going to be a thumbnail, small image, and/or base image, it's also stored in the relevant product attributes directly ('image', 'small_image', and/or 'thumbnail') [stored in catalog_product_entity_varchar]. From a data point of view, this introduces data redundancy to the system and is thus not desirable, however, there's the added performance you get when you don't have to load the media_gallery attributes, so that's the trade-off.

I wrote a quick module to find products affected by this, and add the files into the media_gallery to fix the issue. If anyone wants me to post the code, just holler.

At this point I'm still not sure what caused the products from having their image, small_image, and/or thumbnail attributes set without having those values also stored in the media_gallery--but that will come later.

@COLASYSTEMS
Copy link

@PatrickCronin your scenario sounds similar to mine but mine appears very much to do with swatches. I would be regularly deleting, loading and reloading via Magmi and because I was not regularly toggling the swatch on the front end, I wouldn't see any affect on images in the backend, and of course I would not really be looking at images in the back end very often anyway.

It was only today when I stated to test that setting inventory out of stock on a simple product member of a configurable product and therefore was re-saving the product for the 1st time after initial load that I saw it was deleting the image rows in the back end. The front end was not affected even after a full cache refresh. Actually it was screwing up all the other simple product members of that configurable product as well. Bit of a nightmare when you have thousands of products loaded.

The fix from @Bert22 definitely works to stopping it happening again for me but I'm having to go back and reload all the products into the database again via Magmi to fix the broken ones which are many. Thank god for Magmi in that case.

I have a number of swatches that use the same image so I don't think that is the issue for me.

I did not look at the database level as you have to see any discrepancies.

Regards,
Shaun.

@singalen
Copy link

@PatrickCronin please do!

@philspbr
Copy link

I have the same problem since updating to Magento 1.9.0.1 and I am NOT using Magmi but the standard Magento import function using the same image for multiple simple products. In my case, all images disappear from the frontend and backend when saving/modifying a product (in our case simple products) which had its images previously uploaded by import, I am using configurable swatches. If the images are uploaded via backend, they stay.

@PatrickCronin
Could you post your code to identify the products affected by this bug?

@singalen
Copy link

Having dived into Magento deeper than I ever wished, I'm thinking it has something to do with catalog_product_entity_media_gallery and catalog_product_entity_media_gallery_value tables, and some simple insert into ... select ... should do the job. I'll experiment with this later.

@grosykevin
Copy link

Hello, I am having a problem with configurable swatches. I import my product with magmi. When I go in my back office my images are there but when I go to my front office front it does not display my images in the media_gallery why?

@jgy3183
Copy link

jgy3183 commented Jun 23, 2015

has anyone here found a fix for this? we are having the same problem :(

@philspbr
Copy link

I tried bert22's fix but unfortunately it did not work, the images are still disappearing when saving the product in the backend. I think we just have to wait until the Magento team fixes this nasty bug and open a bug report in the issue tracker. In it's current state, the image import is not working when using configurable swatches (and vice versa).

@helirexi
Copy link

I have similar issue - after import with Magmi (use v0.7.21 and Magento_1.9.1.1, all my product are Simple, Configurable swaches is Off in admin)
All img shown on frontend but at product page admin see "No image". when export from magento standard way I see all 3 type of images have correct url's (that's why they shown on frontend)
all well before your want save product on admin backend, image url's save with empty (as in product admin - no image)
find this post http://www.blog.magepsycho.com/how-to-fix-the-issue-product-images-missing-in-backend-but-not-in-frontend/ with same problem possible fix.
Soon i will try suggested fix - write after the result here.

EDIT:
I forgot that was completely clean products (with magmi) and reimport them after with changed urls (seo issue was need this)
Then all products have new ID in magento. maybe this was my issue with images and table catalog_product_entity_media_gallery

 MariaDB [testmagento]> select * from catalog_product_entity_media_gallery;
+----------+--------------+-----------+-----------------------+
| value_id | attribute_id | entity_id | value                 |
+----------+--------------+-----------+-----------------------+
|        1 |           88 |      2804 | /l/n/lnc-019217_1.png |
+----------+--------------+-----------+-----------------------+
1 row in set (0.00 sec)

in snippet above I was manually add image in magento admin for one product. All my other images not in this table (about 1400)

How I was correct my issue:
Run magmi again but only with columns

store;websites;type;sku;image;small_image;thumbnail

and choose Keep existing and media/catalog/product/l/n/ as my import image dir (i have only this names of images, like ln-1234567, that's why this media/import dir

like at this screenshot
150628_image_admin_disappear_corr_magmi

@satyaranjan1231984
Copy link

I have similar issue - after import with Magmi. Kindly send me the solution if any one solved it.

Thanks,
Satya

@philspbr
Copy link

philspbr commented Jul 9, 2015

Magento 1.9.2 got released, anyone already checked if they resolved the bug in 1.9.2?

@singalen
Copy link

singalen commented Jul 9, 2015

Just piling up some maybe-helpful information - a blog post about images missing, not being added to Media Gallery. Examining this is still not a top priority for me 8-(
http://www.blog.magepsycho.com/how-to-fix-the-issue-product-images-missing-in-backend-but-not-in-frontend/

@sohagan
Copy link

sohagan commented Jul 20, 2015

I'm back again.

Images disappear from front end and also backend. I said earlier that @Bert22 's fix works in our integration setup but moved over to live and it doesn't. I am really baffled. Surely this has to have been fixed in core by now this is a major issue. EDIT - so this is a Magmi issue ???? Is there a bug assigned.

EDIT 2 - umm. Clarification. Our integration server is actually on 1.9.1.1 and pre-live is 1.9.1.1 however we applied the @Bert22 fix to dev 1.9.1.0 and it seems to work. Stupidly we upgraded magento and didn't re-test this bug till pre-live testing. So is the problem in 1.9.1.1 and beyond ?

If so then downgrade to 1.9.1.0 ???

@jgy3183
Copy link

jgy3183 commented Jul 21, 2015

The best workaround I found was to use magmi for the initial import - but yes, it does seem to not place the image path in the media gallery table(s). SO, with that said, what we did was run magmi, then use a SQL script to get the SKU and the path to the image to do a normal magento import using sku and image path. BUT BEFORE doing that, we had to copy the images into the media/import folder (to use the normal magento import profile)

@sohagan
Copy link

sohagan commented Jul 21, 2015

Seems my problem is to do with using the same image for base,small and thumbnail. I know I shouldn't for performance reasons but they are quite light anyway. If I comment out the _removeDuplicates() calls in Media.php, images are not deleted from the backend and the problem goes away (I think). Not very satisfactory solution so I'm going to ponder a little longer.

Why it works ok on my dev machine I have no idea but even with 1.9.1.0 installed on our pre-live box it fails.

@philspbr
Copy link

@sohagan As you mentioned correctly the problem comes from using the same image url for multiple products (even when using the magento default import and not magmi). The _removeDuplicates() did not work in our case (Magento 1.9.1.0), upon saving a product in the backend, the images disappear again. Maybe updating to 1.9.2 will solve it, I have not tested it yet.

@alisadikin008
Copy link

the truth is,images were not deleted,but only filename removed from database because the default catalog module remove duplicate image

so,the problem solving is below

override module "Mage_Catalog_Model_Resource_Product_Attribute_Backend_Media" into your own module
step: in file media.php
in function loadGallery($product,$object){
//$this->_removeDuplicates($result); please comment this
}

this solved my cases

@rvpatel
Copy link

rvpatel commented Dec 8, 2015

I have generate same issue with magento 1.9.2.2. Magmi version: 0.7.18 (Understanding)

please how to fix this :
http://stackoverflow.com/questions/30333376/swatch-images-on-magmi-imported-products-removed-when-viewing-product

@diegovandyk
Copy link

So, still no solution for this?

We've determined that the cause is the same image URL being duplicated, and that Magento will clear those duplicates, hence the product deletions.

Is there no way round this, other that loading the products in the back end?
@dweeves any luck with this?

@Randydedecker
Copy link

Randydedecker commented Apr 19, 2016

My workaround for Magento 1.9.2.4 together with the Dn'D Patch Index Url
https://www.magentocommerce.com/magento-connect/dn-d-patch-index-url-1.html

First Copy:
App/Code/Core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Media.php
To:
App/Code/Local/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Media.php

Comment out $this->_removeDuplicates($result); on line 83
As mentioned before, it works now (without Dn'D Patch!)

To make it work with the Dn'D Patch I have done this:

  • Disable the Magmi On the fly indexer v0.2 (messes up reindexes done by the Dn'D patch)

@wash34
Copy link

wash34 commented Nov 4, 2016

Hello we have the same bug in magento 1.9.3.0 with smart watches enabled.
In this magento's version you have to comment to line in App/Code/Local/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Media.php
Comment out $this->_removeDuplicates($result); on line 83
Comment out $this->_removeDuplicates($result); on line 293

It's seem to work ...

@adri2k
Copy link
Contributor

adri2k commented Jan 27, 2017

In magento 1.9.3.1 there is same problem.

Workaround:
app/code/local/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Media.php
Comment line 83 and 293:
$this->_removeDuplicates($result);

@Robdebert
Copy link

This one is 2 years old. Is there really no one trying to update Magmi? No fix for this since then? :(

Also Magento 2 is out, magmi is the only import-tool that i know of, but not working with magento 2 ?

@ladle3000
Copy link

ladle3000 commented Apr 23, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests