Images & EE assets

Image export flow

Product images are only getting exported trough the ‘Magento image export’ export profiles. Not trough the ‘Magento export’ profiles. Unlike the product data that is getting processed by Magento’s queue, image creation is done trough separate API calls before sending data to the queue. This means that the products must first be created or exist in Magento before we can add images.

The following message will be shown when you want to push image data for products that are not available in Magento: Skipping the following image(s) exports. The product with sku %s wasn't available yet in Magento.

This could mean two things:

  • The product is not available in Magento because we never exported it.
  • Magento’s operation queue is still importing and creating products from the previous ‘Magento export’ profile. In this case wait for the previous job to be completed first.

Why image mappings are important

Because we want each image to be created only once it is important to know which image is already available in Magento’s product gallery while we’re exporting. For this we add an image mapping item for each image that is getting created. In this mapping we use the Akeneo’s image filename as code and Magento’s internal media id. The linked id in this mapping is the reference to the product. On each image mapping item a hash of the image content is stored.

How image mappings are getting validated

Because image creation is a memory consuming proces it is important to create images only when necessary. Our connector works as follows.

  • For each product we are exporting we create a list of currently linked Magento Images. This is a list of all product images available in Magento.
  • We also create an Akeneo image mapping list for this product. This is a list of all Akeneo image mappings for the current product.
  • We check each mapping item to see if it’s Magento id is present in the Magento list. If not, we remove this mapping. This behaviour could be a result of removing images in Magento directly.
  • Then we check if an image needs to be created. We do this by searching Akeneo for an image mapping with the same filename and product id. If a mapping is found AND the image hash of this mapping is equal to the image hash we are working with, we don’t need to create a new image. Instead we use the Magento image mapping id for relinking the already existing image to our product. Otherwise we create a new image and save the response id into a new mapping item.
Image name formatting

If you take a look at the configuration documentation page you’ll find the setting ‘reformat_image_name’. This setting allows you to choose between two different ways on how image names must be stored in Magento. If this setting is disabled the following name formatting will be used:

{first-79-characters-of-image-name}_{first-4-characters-of-akeneo-sha1}.{extension}

We do this because Magento image names are limited on 90 characters when creating trough API. It is also important that the image names are always unique.

If this setting is active we create the image name the following way:

{sku}.{sku}.{attribute_code}.{full_image_name}.{extension}

This name is also unique, but has no limitation in length and can be a problem.

Image roles

It is possible to create your own image role attributes and link them to the gallery. You do this by configuring the image attribute code the following way.

Export types

First add the image to the ‘image attributes’ configuration. This causes an image to be added to the gallery. Then add the same image attribute code to the ‘attributes codes’ configuration. By doing this, a new image role will be created in Magento. This role will also get linked to the correct image.

It is also possible to link an image to an already existing Magento image role. Therefore we need to add the attribute code to the ab mapping.

Export types

Disabling images

If you want to disable specific images in Magento’s product gallery, you can do this by adding the ‘disable_images’ setting to your oro config table. All attribute codes in this comma separated list will get exported with the disabled flag. Check the ‘tab 1 - configuration’ page for more information.

Since the 6.5.0 version of the connector it is also possible to use localizable attributes for disabling images. This way we can enable / disable images for specific storeviews. When using localizable image or asset collection attributes each image is getting disabled by default and only if the image locale is equal to the configured storeview locale the image will get enabled. Here it is important to wait for the queue to be finished to see the result.

Configuration EE assets

Just like normal product images (image attributes) also EE assets attributes can be exported. Before doing this it is important to configure the ‘asset_attribute’ database configuration setting. See reference configuration manual for more information.

You can control the image gallery positions by changing your image attributes configuration sort order. For example. Let’s assume we have the following attributes available.

image_1, image_2, image_3 asset_collection_1

and we put this in our export configuration: image_3,asset_collection_1,image_1,image_2

In this case image_3 will come fist in the gallery, then all asset collection images with their own sort order and then image_1 & 2.

Be aware that image positioning is something completely different then image roles. Positioning is being used in your image gallery on Magento’s frontend. Roles are being used to determine which image must be used as the thumbnail image, main image, etc..