Difference between revisions of "X-Cart:How to export and import products with images"

From X-Cart 4 Classic
Jump to: navigation, search
(When importing data with images, old detail images in the "/images" directory are not overwritten and/or removed. How do I solve the problem?)
(When importing data with images, old images in the "/images" directory are neither overwritten nor removed. How do I solve the problem?)
 
(25 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
# Go to <u>Tools</u> > <u>Import/Export</u> > <u>Export data</u> section.
 
# Go to <u>Tools</u> > <u>Import/Export</u> > <u>Export data</u> section.
 
# <u>Do you wish to export images?</u>: Select '''Yes'''.
 
# <u>Do you wish to export images?</u>: Select '''Yes'''.
# <u>Data types</u>: Select '''products'''.
+
# <u>Data types</u>: Select '''PRODUCTS'''.
 
# Click '''Export'''.
 
# Click '''Export'''.
# The required CSV file is generated in X-Cart and a directory containing images is saved to <xcart_dir>/var/tmp/export_*** . The exact name of this directory can be looked up in the Export packs section. You can download this directory using FTP or SSH.
+
 
 +
{{Note1|<b>Tip:</b> If you want to export detailed and product variant images, select '''DETAILED IMAGES''' and '''PRODUCT VARIANTS''' under <u>Data types</u> section respectively.}}
 +
 
 +
The required CSV file is generated in X-Cart, and a temporary directory containing product images is saved to the <xcart_dir>/var/tmp/ directory.
 +
 
 +
You can download the generated CSV file and the temporary directory with the product images using FTP or SSH, or using your web-site Control Panel's File Manager (if any provided by your hosting company).
 +
 
 +
{{Note1|<b>Useful Tips:</b>}}
 +
 
 +
:1. The exact name of the generated CSV file, as well as the temp directory containing images, can be looked up in the Export packs section, for example:
 +
 
 +
<pre>
 +
10-20-2012 11:04 export_20121020_110455.csv - PRODUCTS
 +
 
 +
Temporary directory for images: /u/user/public_html/xcart/var/tmp/export_20121020_110455
 +
</pre>
 +
 
 +
:2. Product images of different types are exported into different sub-directories in the temp export directory, for example:
 +
 
 +
<pre>
 +
/u/user/public_html/xcart/var/tmp/export_20121020_110455/T/product_thumbnail.jpg
 +
/u/user/public_html/xcart/var/tmp/export_20121020_110455/P/product_main_image.jpg
 +
/u/user/public_html/xcart/var/tmp/export_20121020_110455/D/product_detailed_image.jpg
 +
/u/user/public_html/xcart/var/tmp/export_20121020_110455/W/product_variant_image.jpg
 +
</pre>
 +
 
 +
:In the above example, there are pre-defined sub-directories which correspond to:
 +
 
 +
::T - Product Thumbnail Images
 +
::P - Product Main Images
 +
::D - Product Detailed Images
 +
::W - Product Variant Images
 +
 
 +
:3. Accordingly, the product images info in the generated CSV file consist of two parts: sub-directory prefix (T/, P/, etc.) and image filename, for example:
 +
 
 +
<pre>
 +
[PRODUCTS]
 +
!THUMBNAIL;!IMAGE;
 +
T/product_thumbnail.jpg;P/product_main_image.jpg
 +
 
 +
[DETAILED_IMAGES]
 +
!IMAGE;
 +
D/product_detailed_image.jpg
 +
 
 +
[PRODUCT_VARIANTS]
 +
!IMAGE;
 +
W/product_variant_image.jpg
 +
</pre>
  
 
==To import products with images==
 
==To import products with images==
  
To import products with images, the CSV file must contain columns !THUMBNAIL and !IMAGE . The simplest way to get a valid file is to export a product with images (see the previous section for instructions on how to do that) and use it as a template.
+
To import products with images, you need to ensure that the CSV file contains the columns !THUMBNAIL and !IMAGE under the [PRODUCTS] section.
  
# Place the directory containing product images to a temporary directory inside X-Cart. For example, you can create a directory in <xcart_dir>/var/tmp . If you are importing products from one X-Cart to another, you can just place the directory export _***, described above, to the specified directory <xcart_dir>/var/tmp .
+
If you want to import product detailed images and product variant images as well, you need to ensure that the CSV file contains the column !IMAGE under the [DETAILED_IMAGES] and [PRODUCT_VARIANTS] sections respectively.
 +
 
 +
# Place the product images to be imported to a temporary directory inside X-Cart.
 
# On the <u>Import/Export -> Import data</u> page click <u>Import options</u>.
 
# On the <u>Import/Export -> Import data</u> page click <u>Import options</u>.
# <u>Directory where images are located</u>: enter the absolute(!) path to the directory, where you have placed the images. The absolute path to the X-Cart directory can be looked up on the Tools->Summary page in the Environment info section.
+
# <u>Directory where images are located</u>: enter the absolute (!) path to the directory, where you have placed the images.
# Select the required file.
+
# Select the required CSV file.
 
# Select the required delimiter.
 
# Select the required delimiter.
 
# Click '''Import'''.
 
# Click '''Import'''.
  
==Troubleshooting==
+
{{Note1|<b>Useful Tips:</b>}}
 +
 
 +
:1. The simplest way to get a valid sample CSV file is to export a sample product with images (see the [[X-Cart:How_to_export_and_import_products_with_images#To_export_products_with_images | previous section]] for instructions on how to do that), and use the generated CSV file as a template.
 +
 
 +
:{{Note1|<b>Keep in mind...</b>
 +
:* The product images info in the generated CSV file includes sub-directory prefixes like T/, P/, etc. Accordingly, the exported product images are located in the corresponding sub-directories in the temp directory (see examples in the [[X-Cart:How_to_export_and_import_products_with_images#To_export_products_with_images | previous section]]).
 +
}}
 +
 
 +
:2. Use the temp directory created by exporting a sample product with images (like <xcart_dir>/var/tmp/export_***) or create another temp directory (for example <xcart_dir>/var/tmp/my_temp_dir), and upload your new product images there.
 +
 
 +
:{{Note1|<b>Keep in mind...</b>
 +
:* Images of different types (product thumbnails, product main images, etc.) should be placed in the corresponding sub-directories (T, P, etc.) in the temp directory (see examples in the [[X-Cart:How_to_export_and_import_products_with_images#To_export_products_with_images | previous section]]).
 +
:* You can remove the sub-directory prefixes (like T/, P/, etc) from the images data in your CSV file. In this case, you must upload product images of different types into a single directory.}}
 +
 
 +
:3. If you are transferring product with images from one X-Cart to another, you can just download the whole temp directory with the images exported from one store (like <xcart_dir>/var/tmp/export_***), and upload it to the directory <xcart_dir>/var/tmp of another store.
 +
 
 +
:4. The absolute path to the temp directory with your new product images consists of two parts: <xcart_dir>/ and var/tmp/export_*** (or var/tmp/my_temp_dir). The first part is the absolute path to the X-Cart directory. The absolute path to the X-Cart directory can be looked up on the [[X-Cart:Summary_Page | Summary page]] in the Environment info section.
 +
 
 +
:5. If you want to import the same CSV file with the images you have exported earlier back to your X-Cart store, you should specify the same temp export directory in the "Directory where images are located" field, for example:
 +
 
 +
<pre>
 +
Directory where images are located: /u/user/public_html/xcart/var/tmp/export_20121020_110455
 +
</pre>
 +
 
 +
:6. The import script will take the images from the temp directory specified in the field "Directory where images are located" and will import these images to the corresponding predefined sub-directories in the <xcart_dir>/images directory:
 +
 
 +
<pre>
 +
/u/user/public_html/xcart/images/T/product_thumbnail.jpg
 +
/u/user/public_html/xcart/images/P/product_main_image.jpg
 +
/u/user/public_html/xcart/images/D/product_detailed_image.jpg
 +
/u/user/public_html/xcart/images/W/product_variant_image.jpg
 +
</pre>
 +
 
 +
:{{Note1|<b>Keep in mind...</b>
 +
:* The imported images will be placed into the specified above directories if the corresponding options under [[X-Cart:Images_Location_Management | <u>'Images Location'</u>]] are set to store images in the file system, otherwise the images data is imported from the temp export directory into the X-Cart database.}}
  
===When importing data with images, old detail images in the "<xcart_dir>/images" directory are not overwritten and/or removed. How do I solve the problem?===
+
:7. It is possible to auto-generate product thumbnail images from the main product images being imported (in other words, generate thumbnails from the images specified in the !IMAGE column). This can be done by adding !GENERATE_THUMBNAIL column to your CSV file and specifying Y as the value of the column. The !THUMBNAIL column should be omitted in this case.
  
https://bt.crtdev.local/view.php?id=104503#564684
+
==See also==
 +
* [[X-Cart:Automated_Generation_of_Thumbnails_from_Product_Images_by_Import | Automated Generation of Thumbnails from Product Images by Import]]
 +
* [[X-Cart:CSV_Format_for_Various_Data_Types#Products | CSV Format for Various Data Types. Products]]
  
 +
==Troubleshooting==
  
При импорте данных с картинками, если X-Cart обнаружит в папке images картинку с тем же самым именем, что и импортируемая картинка, например с именем "detailed_image_sku17.jpg", то старая картинка удалена/переписана не будет; вместо этого к имени импортируемой картинки будет добавлен суффикс типа _01, _02, etc., т.о. в папке images будет создана картинка с именем "detailed_image_sku17_01.jpg".
+
=== When importing data with images, old images in the "<xcart_dir>/images" directory are neither overwritten nor removed. How do I solve the problem? ===
  
Для того, чтобы предотвратить "захламление" папки images старыми картинками при многократном импорте данных с картинками, рекомендуется следовать описанной ниже процедуре:
+
If, while importing data with images, X-Cart finds in the target directory, e.g., <u>images</u>, an image  with the same name as the image being imported, for instance, "detailed_image_sku17.jpg", it does not overwrite or delete the existing image; instead, it appends a suffix like _01, _02, etc. to the image being imported. Thus, in our example, in the <u>images</u> directory we get a new image named "detailed_image_sku17_01.jpg".
  
:1) Перед импортом данных с картинками, переименавать папку images, например в images_bkp;
+
To prevent cluttering up the images directory with diplicate images when importing data with images multiple times, follow these steps:
:2) Заимпортить данные с картинками;
 
:В результате, система создаст новую папку images, куда будут заимпорчены новые картинки.
 
:3) (Optional) Re-slice magnified images (если импортятся images for magnifier);
 
:4) Скопировать всё содержимое папки images в папку images_bkp (новые файлы переписать поверх старых);
 
:В результате, старые картинки в папке-приемнике (images_bkp) будут переписаны новыми картинками из папки-источника (images).
 
:5) Удалить папку images;
 
:6) Переименовать папку images_bkp в images.
 
  
Примечание: пункты 1,4-6 можно выполнить используя FTP, SSH или web-site's Control Panel File Manager.
+
# Before importing data with new images, rename the <u>images</u> directory; e.g., to <u>images_bkp</u>.
 +
# Import the data with new images.<br />This creates a new directory named <u>images</u>, where X-Cart will import the new images.
 +
# (Optional) Re-slice magnified images (if importing images for magnifier).
 +
# Copy the content of the <u>images</u> directory to the <u>images_bkp</u> directory (overwriting the old files).<br />As a result, the old images in the target directory (<u>images_bkp</u>) will be overwritten by the new images from the source directory (<u>images</u>).
 +
# Remove the <u>images</u> directory.
 +
# Rename the <u>images_bkp</u> directory to <u>images</u>.
  
[[Category:Troubleshooting]]
+
{{Note|You can complete step 1, as well as steps 4 through 6 using FTP, SSH or the File Manager in the website's Control Panel.}}
[[Category:Troubleshooting]]
 
[[Category:Troubleshooting]]
 
[[Category:Troubleshooting]]
 
  
 
[[Category:Troubleshooting]]
 
[[Category:Troubleshooting]]

Latest revision as of 15:45, 18 November 2013

To export products with images

  1. Go to Tools > Import/Export > Export data section.
  2. Do you wish to export images?: Select Yes.
  3. Data types: Select PRODUCTS.
  4. Click Export.
Tip: If you want to export detailed and product variant images, select DETAILED IMAGES and PRODUCT VARIANTS under Data types section respectively.

The required CSV file is generated in X-Cart, and a temporary directory containing product images is saved to the <xcart_dir>/var/tmp/ directory.

You can download the generated CSV file and the temporary directory with the product images using FTP or SSH, or using your web-site Control Panel's File Manager (if any provided by your hosting company).

Useful Tips:
1. The exact name of the generated CSV file, as well as the temp directory containing images, can be looked up in the Export packs section, for example:
10-20-2012 11:04	export_20121020_110455.csv 	- 	PRODUCTS

Temporary directory for images: /u/user/public_html/xcart/var/tmp/export_20121020_110455
2. Product images of different types are exported into different sub-directories in the temp export directory, for example:
/u/user/public_html/xcart/var/tmp/export_20121020_110455/T/product_thumbnail.jpg
/u/user/public_html/xcart/var/tmp/export_20121020_110455/P/product_main_image.jpg
/u/user/public_html/xcart/var/tmp/export_20121020_110455/D/product_detailed_image.jpg
/u/user/public_html/xcart/var/tmp/export_20121020_110455/W/product_variant_image.jpg
In the above example, there are pre-defined sub-directories which correspond to:
T - Product Thumbnail Images
P - Product Main Images
D - Product Detailed Images
W - Product Variant Images
3. Accordingly, the product images info in the generated CSV file consist of two parts: sub-directory prefix (T/, P/, etc.) and image filename, for example:
[PRODUCTS]
!THUMBNAIL;!IMAGE;
T/product_thumbnail.jpg;P/product_main_image.jpg

[DETAILED_IMAGES]
!IMAGE;
D/product_detailed_image.jpg

[PRODUCT_VARIANTS]
!IMAGE;
W/product_variant_image.jpg

To import products with images

To import products with images, you need to ensure that the CSV file contains the columns !THUMBNAIL and !IMAGE under the [PRODUCTS] section.

If you want to import product detailed images and product variant images as well, you need to ensure that the CSV file contains the column !IMAGE under the [DETAILED_IMAGES] and [PRODUCT_VARIANTS] sections respectively.

  1. Place the product images to be imported to a temporary directory inside X-Cart.
  2. On the Import/Export -> Import data page click Import options.
  3. Directory where images are located: enter the absolute (!) path to the directory, where you have placed the images.
  4. Select the required CSV file.
  5. Select the required delimiter.
  6. Click Import.
Useful Tips:
1. The simplest way to get a valid sample CSV file is to export a sample product with images (see the previous section for instructions on how to do that), and use the generated CSV file as a template.
Keep in mind...
  • The product images info in the generated CSV file includes sub-directory prefixes like T/, P/, etc. Accordingly, the exported product images are located in the corresponding sub-directories in the temp directory (see examples in the previous section).
2. Use the temp directory created by exporting a sample product with images (like <xcart_dir>/var/tmp/export_***) or create another temp directory (for example <xcart_dir>/var/tmp/my_temp_dir), and upload your new product images there.
Keep in mind...
  • Images of different types (product thumbnails, product main images, etc.) should be placed in the corresponding sub-directories (T, P, etc.) in the temp directory (see examples in the previous section).
  • You can remove the sub-directory prefixes (like T/, P/, etc) from the images data in your CSV file. In this case, you must upload product images of different types into a single directory.
3. If you are transferring product with images from one X-Cart to another, you can just download the whole temp directory with the images exported from one store (like <xcart_dir>/var/tmp/export_***), and upload it to the directory <xcart_dir>/var/tmp of another store.
4. The absolute path to the temp directory with your new product images consists of two parts: <xcart_dir>/ and var/tmp/export_*** (or var/tmp/my_temp_dir). The first part is the absolute path to the X-Cart directory. The absolute path to the X-Cart directory can be looked up on the Summary page in the Environment info section.
5. If you want to import the same CSV file with the images you have exported earlier back to your X-Cart store, you should specify the same temp export directory in the "Directory where images are located" field, for example:
Directory where images are located: /u/user/public_html/xcart/var/tmp/export_20121020_110455
6. The import script will take the images from the temp directory specified in the field "Directory where images are located" and will import these images to the corresponding predefined sub-directories in the <xcart_dir>/images directory:
/u/user/public_html/xcart/images/T/product_thumbnail.jpg
/u/user/public_html/xcart/images/P/product_main_image.jpg
/u/user/public_html/xcart/images/D/product_detailed_image.jpg
/u/user/public_html/xcart/images/W/product_variant_image.jpg
Keep in mind...
  • The imported images will be placed into the specified above directories if the corresponding options under 'Images Location' are set to store images in the file system, otherwise the images data is imported from the temp export directory into the X-Cart database.
7. It is possible to auto-generate product thumbnail images from the main product images being imported (in other words, generate thumbnails from the images specified in the !IMAGE column). This can be done by adding !GENERATE_THUMBNAIL column to your CSV file and specifying Y as the value of the column. The !THUMBNAIL column should be omitted in this case.

See also

Troubleshooting

When importing data with images, old images in the "<xcart_dir>/images" directory are neither overwritten nor removed. How do I solve the problem?

If, while importing data with images, X-Cart finds in the target directory, e.g., images, an image with the same name as the image being imported, for instance, "detailed_image_sku17.jpg", it does not overwrite or delete the existing image; instead, it appends a suffix like _01, _02, etc. to the image being imported. Thus, in our example, in the images directory we get a new image named "detailed_image_sku17_01.jpg".

To prevent cluttering up the images directory with diplicate images when importing data with images multiple times, follow these steps:

  1. Before importing data with new images, rename the images directory; e.g., to images_bkp.
  2. Import the data with new images.
    This creates a new directory named images, where X-Cart will import the new images.
  3. (Optional) Re-slice magnified images (if importing images for magnifier).
  4. Copy the content of the images directory to the images_bkp directory (overwriting the old files).
    As a result, the old images in the target directory (images_bkp) will be overwritten by the new images from the source directory (images).
  5. Remove the images directory.
  6. Rename the images_bkp directory to images.
Note: You can complete step 1, as well as steps 4 through 6 using FTP, SSH or the File Manager in the website's Control Panel.