0

I have an existing web site with thousands of products. I have several storefronts and all products are available on all stores using the same product images with the same image role settings (i.e. base, small, thumbnail).

I have produced new product images for a subset of the products and want to replace the existing product images in Magento with these new images.

I created an import file with SKU and references to the new images. After running the import, all product images changed to the new versions as expected. The problem though, is that the image roles were not maintained for the storefronts, only for the default view. So, for instance, the image intended as a thumbnail is no longer set as a thumbnail for the storefronts.

To resolve this I tried creating individual import files for each storefront (by including store_view_code and not only SKU as above) where I re-import the product images. This was successful and the image role is now set for the storefront. BUT, the import also resets the product URL back to the default URL and thus makes the product unavailable on the old storefront URL. The product URL was not included in the import. If I do include it, it does set it to what is in the import file and not the default but I don't want to have to include the URL in my image import. Changing the URL on storefront imports even though this column is not included must be some core Magento bug.

So, my question is if anyone knows of a way to import images for a multi-store setup which maintains the image roles for all storefronts. Either by making the default import role settings apply to all storefronts or by making a storefront import not change the URL or through some other way.

  • are the product images always the same across storefronts or just for this import – iphigenie Apr 24 at 8:04
  • also, what is the scope of the image attributes currently? is it store view, website or global? – iphigenie Apr 24 at 8:12
  • The product images are always the same across storefronts. Prior to migration to M1, the scope of the image roles was storefront. It's no obvious in the M2 admin what the scope is but I would guess it's still storefront. – Klistrian Apr 27 at 11:26
0
+50

I hesitate to answer because I don't have time to test but two ideas come to mind. But I'll put in suggestions and will edit once you answer the comments with more details. But it smells as if the image attribute is being updated but the gallery settings are not, maybe.

It would be useful for you to give an idea of the format of the import files you used in your first and second try, what are the headers? just in case I can spot a field that could help.

First idea, I wonder if changing the scope of the three image attributes to website before the import of your original website file might work. What is the scope of these attributes for you at the moment?

Though what I havent tested is what happens to the old data and whether it doesn't reapper if you then change the scope back. I know the data usually isnt deleted when you change scope.

Second, the assignment of image to thumbnail/small image etc. role can be done via SQL. I have had to do it a few times with data migrations. We probably can craft a query that selects the information for the default and then reinserts it to apply to the store views.

Background information

I had problems in migration as the behaviour of "hide from product page" was different so have notes to remember for next time - they might be useful

Images are in two parallel systems

  1. (image,small_image,thumbnail) attribute, where the path to the image is stored in catalog_product_entity_varchar. It also tracks store_id

  2. (gallery) attribute, which is stored in the catalog_product_entity_media_gallery... 4 tables. One thing that is tracked here for example is the "hide from product page gallery" flag. mg_catalog_product_entity_media_gallery_value contains store_id

These are SEPARATE attributes with their own value_id.

The catalog_product_entity_media_gallery_value_to_entity table maps the gallery entries to the product entity, but it does not map to the image attributes, because there can (now, in m2) be multiple attributes with the same image

The connection between gallery entry and image entry is through the value field in catalog_product_entity_media_gallery which will be the same as the value field in catalog_product_entity_varchar - i.e. the image file name

Investigation: try to figure out which of these is missing entries and recreate them, by comparing one of your imported images in those 5 tables with one done through the admin interface. You'll need the attribute id of the three image attributes and a product id

But the scope approach or setting more information in the feed is less work if it works

| improve this answer | |
  • Great info, thanks a lot! Now let's hope something here can help me solve things. Changing the scope of image roles to global prior to running the import sounds like a good idea. Any clue on how that can be done? Would have to be via a PHP or SQL script given the amount of products and images. – Klistrian Apr 27 at 11:34
  • Hi @Klistrian you can change the scope in the Magento admin - stores -> attributes -> product - Assuming you have a clone you can test on change the scope then try the import. We could be lucky it could be enough – iphigenie Apr 28 at 13:25
  • Ah, wasn't aware these attributes could be found there. Switching them to global definitely feels like it could help. I've done this now, just waiting for a reindex of 9760 products... So can't say if it did the trick but I',m gonna go ahead and award you the bounty anyway for the effort and great input. – Klistrian Apr 29 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.