NEW FEATURE Wildcard on gallery paths#128
Conversation
This new feature enables the use of wildcard (*) on image paths on the media_gallery field. By enabling this feature, it simplifies image paths in media_gallery column, from something like this (/demo1/image1.jpg;/demo1/image2.jpg;/demo1/image3.jpg) to this (/demo1/*.jpg) Added option to turn this feature on and off. Tested in Linux server, need testing in windows
Originally, when the same image is added to gallery more than once, if image label is not specified, the label will be updated with null, as result it resets image labels. This has 2 downsides: 1. It resets any manually saved labels through Magento backend. 2. This is not good with the wildcard feature. Because magmi handles images in this order (I believe): base image, gallery, small image and at last thumbnail, the label of base image will be reset to null when gallery contains wildcard path. This fix basically checks if image label is not specified, do not update the label to null.
Solution: if OS is windows, then replace '/' in the pattern with the properly escaped path separator regex string for windows - '\\\\'
|
Maybe I shall add more information about this feature and some use cases. The main benefits of this feature are:
I will show you how to use the wildcard feature with these use cases: Case 0: TestingWe have only 1 prodoct to be imported and this product has several images as shown: CSV: (Without wildcard feature) sku,image,media_gallery... demo1,/image1.jpg,/image1.jpg;/image2.jpg;/image3.jpg CSV: (with wildcard feature on) sku,image,media_gallery... demo1,/image1.jpg,/*.jpg When we have more products and more images, Obviously if we keep all images in the image source folder, all images will be added to every product because of '/*.jpg'. We need to do some work on image renaming and/or file structures. Consider this scenario for the following cases: Case 1: Images are organised into foldersWith the scenario above, we have manually organised the product into folders like this: /demo2/image4.jpg CSV: sku,image,media_gallery... demo1,/demo1/image1.jpg,/demo1/*.jpg demo2,/demo2/image4.jpg,/demo2/*.jpg ... Now the media_gallery column has a fix pattern, we can remove the column with help from Value Replace plugin sku,image,... demo1,/demo1/image1.jpg,... demo2,/demo2/image4.jpg,... Value Replacer: Note that we can NOT remove the media_gallery column without the wildcard feature in this case. Case 2: Images are renamed properlyWith the scenario above, we have manually renamed the product images like this: /demo2_1.jpg CSV: sku,image,media_gallery... demo1,/demo1_1.jpg,/demo1*.jpg demo2,/demo2_1.jpg,/demo2*.jpg ... Now the image column also has a fix pattern, we can further remove the column with help from Value Replace sku,.... demo1,... demo1,... Value Replacer: Note that we can remove the image and media_gallery column without the wildcard feature in this case. The wildcard feature simply shortens the new value for media_gallery. Without the wildcard feature, the new value for media_gallery would be like this: /{item.sku}_1.jpg;/{item.sku}_2.jpg;/{item.sku}_3.jpg Case 3: Images are renamed and organised into foldersWith the scenario above, we have manually renamed the product images and organised them into folders like this: /demo2/1.jpg CSV: sku,image,media_gallery... demo1,/demo1/1.jpg,/demo1/*.jpg demo2,/demo2/1.jpg,/demo2/*.jpg Important: because the images now have duplicated name in different folders, we need to use the image renaming feature to prevent problems. For example: Again we can remove the image and media_gallery column with help from Value Replacer plugin sku,.... demo1,... demo1,... Value Replacer: |
If this feature is turned on, it will assign the base image of the first associated simple to be the base image, thumbnail and small image of the configurable, AND add all gallery images of associated simples to the configurable. 'back' image label support is added. If both features are turned on , When auto adding images to the gallery of configurable, it will clear any existing 'back' label and set the base image of the second simple to 'back'. The labels of simple products will not be affected. Options are added to switch both features on and off.
If this feature is turned on, it will assign the base image of the first associated simple to be the base image, thumbnail and small image of the configurable, AND add all gallery images of associated simples to the configurable. 'back' image label support is also added. If BOTH features are turned on, when auto adding images to the gallery of configurable, it will clear any existing 'back' label and set the base image of the second simple to 'back'. The labels of simple products will not be affected. Options are added to switch both features on and off.
Make sure $values is not empty before insert into database
This new feature enables the use of wildcard (*) on image paths on the media_gallery field.
By enabling this feature, it simplifies image paths in media_gallery column,
from something like this (/demo1/image1.jpg;/demo1/image2.jpg;/demo1/image3.jpg)
to this (/demo1/*.jpg)
Added option to turn this feature on and off.
Tested in Linux server, need testing in windows