How to prevent duplicating product images by image name

Permalink Browser Info Environment
I need to be able to import an xml of products, choosing "Import product images", and have it only import the images that don't already exist in the concrete5 file manager.

I have read the support request covering this and understand that it is a tricky proposition with no "best" answer:
http://www.concrete5.org/marketplace/addons/ecommerce-import/suppor...

For my purposes, I want the tool to recognize existing files based on file name only (without worrying about whether the image has changed), and assign those to the products appropriately. I know that all of my images will have distinct file names.

Does anyone have any advice for implementing something like this? I'm assuming it requires modifying helpers\import.php, but I'm not sure where. Also, let me know if this would be overly complicated.

Type: Discussion
Status: New
alseageo
View Replies: View Best Answer
tbcrowe replied on at Permalink Best Answer Reply
tbcrowe
I have added support this functionality to version 2.4.6. Please note that in order to use this functionality you must define a value in your config/site.php as follows:
define('IMPORT_MATCH_IMAGE_FILES_BY_NAME', true);

This feature is disabled by default because it may produce undesirable behavior for some users. Also, it will make importing products with images slower.

Finally, please note that files are matched by comparing the basename of the image in the import XML file to the "Filename" value of existing images. Also, if the "Add product images to 'Product Images' file set?" option is checked when importing, Import will only match files in that product set.
alseageo replied on at Permalink Reply
alseageo
Thank you so much for implementing this. It is exactly what I needed. Thanks again for making this great add-on.
alseageo replied on at Permalink Reply
alseageo
This doesn't appear to be working for me anymore. I'm not sure if it ever was working entirely properly - I had to move onto another project shortly after implementing it. Now I'm in a situation where I need to upload about 400 products with images, and many of them end up duplicated in the File Manager on my staging server.

I'm running eCommerce Import 2.4.7 with eCommerce 2.8.8. Regardless of the options I set in the Product Import page, whatever I choose "yes" for "Import product images?" it re-imports them in the file database. The IMPORT_MATCH_IMAGE_FILES_BY_NAME flag is still set in the config. Can you confirm that this is working for you?


Environment Information

# concrete5 Version
5.6.1

# concrete5 Packages
Advanced Forms (1.10), Attributes Slider (1.0.0), Breadcrumbs (2.0), Designer Content (3.1.1), eCommerce (2.8.8), eCommerce Import (2.4.7), Expand / Collapse (1.2.1), Google Docs Viewer (1.0), Google Map (Premium) (2.1), Login (1.1.1), Multiple Domains (1.3.2), Nontab Scheduler (1.1), Page List Teasers (1.2), Page Redirect (1.4), Page Selector Attribute (1.1), Slate Theme (1.4), Zone Based Shipping (1.9.0.2).

# concrete5 Overrides
blocks/multiple_domains_autonav, blocks/image_description, blocks/html, blocks/search, blocks/page_list, blocks/file, blocks/image, blocks/orbit_slider, blocks/product_list, blocks/content, blocks/product, blocks/attributes_slider, blocks/button_foundation, blocks/login, blocks/autonav, blocks/pic_left_text_right, blocks/form, controllers/register.php, controllers/checkout, elements/orders, elements/cart_item_list.php, elements/product, elements/checkout, elements/profile, helpers/import.php, helpers/ancestorpages.php, helpers/productattribute.php, js/ccm.core.commerce.cart.js, libraries/payment, libraries/request.php, mail/validate_user_email.php, mail/order.php, mail/receipt.php, models/core_commerce, models/product, models/attribute, models/payment_override_README.txt, single_pages/login.php, single_pages/register.php, single_pages/dashboard, themes/clearview_fishscan, themes/fishscan_bootstrap, themes/blank_page, themes/fishscan_skeleton, themes/foundation, themes/slate_custom, themes/slate_iv, tools/filecheck.php, tools/set_page_permissions.php

# Server Software
Apache

# Server API
cgi-fcgi

# PHP Version
5.2.17

# PHP Extensions
bcmath, bz2, calendar, cgi-fcgi, ctype, curl, date, dba, dbase, dom, exif, filter, ftp, gd, gettext, gmp, hash, iconv, imap, json, ldap, libxml, mbstring, mcrypt, mhash, mime_magic, mysql, mysqli, ncurses, odbc, openssl, pcntl, pcre, PDO, pdo_dblib, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, posix, pspell, readline, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, SQLite, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend Optimizer, zip, zlib.

# PHP Settings
max_execution_time - 30
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 1000
memory_limit - 128M
post_max_size - 10M
safe_mode - Off
safe_mode_exec_dir - <i>no value</i>
safe_mode_gid - Off
safe_mode_include_dir - <i>no value</i>
sql.safe_mode - Off
upload_max_filesize - 10M
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
odbc.max_links - Unlimited
odbc.max_persistent - Unlimited
pcre.backtrack_limit - 200000
pcre.recursion_limit - 200000
pgsql.max_links - Unlimited
pgsql.max_persistent - Unlimited
session.cache_limiter - nocache
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
safe_mode_allowed_env_vars - PHP_
safe_mode_protected_env_vars - LD_LIBRARY_PATH

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.