Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imported images are not attached / linked to products in Media Library #27281

Closed
3 tasks done
thinkjarvisdesignandmarketing opened this issue Aug 11, 2020 · 33 comments · Fixed by #40076
Closed
3 tasks done
Labels
focus: csv import/export Issues related to CSV import and export. plugin: woocommerce Issues related to the WooCommerce Core plugin. priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. team: Proton WC Core development and maintenance type: bug The issue is a confirmed bug.

Comments

@thinkjarvisdesignandmarketing

Please provide us with the information requested in this bug report. Without these details, we won't be able to fully evaluate this issue.
Bug reports lacking detail, or for any other reason than to report a bug, may be closed without action.

Prerequisites (mark completed items with an [x]):

  • [X ] I have have carried out troubleshooting steps and I believe I have found a bug.
  • [X ] I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

Describe the bug
A clear and concise description of what the bug is.
When using the import function to update products, the image attachment is not updated in the media library. This means that most SEO plugins like Yoast SEO are not given the correct image as a social sharing image. On a shop with over 1000 products it is way too much work to go through and update every image so the attachments show.

Please can you update the import process to include updates to image attachments:

The CSV bulk upload process for products that do not exist:

  1. Upload processed images to the media library
  2. include the full url in the CSV file
  3. Import the CSV containing the product info and the image
  4. The product is now complete
  5. The media library attachments have not updated during the import.
  6. The images are not included in the XML sitemap either

This issue needs to be investigated fully as it is a big problem on large stores where you would never manually add the products.

Expected behavior
A clear and concise description of what you expected to happen.

When importing a CSV where the images are already in the media library:

  1. The image attachment should update to reflect the changes made in the shop feature images.
  2. This will allow SEO plugins to see which image is associated with each page and update the XML sitemaps accordingly.

Actual behavior
A clear and concise description of what actually happens. Please be as descriptive as possible;

When importing a CSV where the images are already in the media library:

  1. The image attachment does not update, so any SEO plugins that look at the featured image for use as a social sharing image do not work as expected.
  2. The XML sitemaps does not show the feature image in the image count.

Steps to reproduce the bug (We need to be able to reproduce the bug in order to fix it.)
Steps to reproduce the bug:

  1. Use any Woocommerce theme

  2. Use any wordpress version (ideally latest)

  3. Follow the steps below:

  4. Upload processed images to the media library

  5. include the full url in the CSV file

  6. Import the CSV containing the product info and the image

  7. The product is now complete

  8. The ERROR: The media library attachments have not updated during the import.

  9. The ERROR: The images are not included in the XML sitemap either

Screenshots
If applicable, add screenshots to help explain your problem.

screenshot1

screenshot2

Isolating the problem (mark completed items with an [x]):

  • I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • This bug happens with a default WordPress theme active, or Storefront.
  • I can reproduce this bug consistently using the steps above.

WordPress Environment
We use the WooCommerce System Status Report to help us evaluate the issue.
Without this report we won't be able to fully evaluate this issue.

`

WordPress Environment

WordPress address (URL): https://www.simplyneedlecraft.com
Site address (URL): https://www.simplyneedlecraft.com
WC Version: 4.3.2
REST API Version: ✔ 1.0.10
WC Blocks Version: ✔ 2.7.3
Action Scheduler Version: ✔ 3.1.6
WC Admin Version: ✔ 1.3.1
Log Directory Writable: ✔
WP Version: 5.4.2
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_GB
External object cache: –

Server Environment

Server Info: Apache
PHP Version: 7.3.21
PHP Post Max Size: 64 MB
PHP Time Limit: 50000
PHP Max Input Vars: 5000
cURL Version: 7.64.0
OpenSSL/1.1.1d

SUHOSIN Installed: –
MySQL Version: 5.7.30-log
Max Upload Size: 64 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

Database

WC Database Version: 4.3.2
WC Database Prefix: wpet_
Total Database Size: 99.22MB
Database Data Size: 89.09MB
Database Index Size: 10.13MB
wpet_woocommerce_sessions: Data: 56.09MB + Index: 2.05MB + Engine InnoDB
wpet_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wpet_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_woocommerce_order_itemmeta: Data: 0.09MB + Index: 0.09MB + Engine InnoDB
wpet_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wpet_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_actionscheduler_actions: Data: 0.06MB + Index: 0.11MB + Engine InnoDB
wpet_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_actionscheduler_logs: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wpet_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_comments: Data: 0.06MB + Index: 0.09MB + Engine InnoDB
wpet_layerslider: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_layerslider_revisions: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_options: Data: 15.39MB + Index: 0.41MB + Engine InnoDB
wpet_postmeta: Data: 9.52MB + Index: 4.03MB + Engine InnoDB
wpet_posts: Data: 2.52MB + Index: 0.64MB + Engine InnoDB
wpet_termmeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wpet_terms: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wpet_term_relationships: Data: 0.39MB + Index: 0.22MB + Engine InnoDB
wpet_term_taxonomy: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wpet_tm_taskmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_tm_tasks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_usermeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wpet_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wpet_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wpet_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wpet_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_wc_product_meta_lookup: Data: 0.25MB + Index: 0.39MB + Engine InnoDB
wpet_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_woocommerce_square_customers: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_wpmailsmtp_tasks_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_yoast_indexable: Data: 3.52MB + Index: 1.03MB + Engine InnoDB
wpet_yoast_indexable_hierarchy: Data: 0.05MB + Index: 0.05MB + Engine InnoDB
wpet_yoast_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_yoast_primary_term: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_yoast_seo_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_yoast_seo_meta: Data: 0.14MB + Index: 0.00MB + Engine InnoDB

Post Type Counts

attachment: 2311
avia_framework_post: 36
flamingo_contact: 3
flamingo_inbound: 2
nav_menu_item: 172
oembed_cache: 3
page: 15
post: 3
product: 1224
product_variation: 661
revision: 73
shop_coupon: 2
shop_order: 44
shop_order_refund: 5
wpcf7_contact_form: 1

Security

Secure connection (HTTPS): ✔
Hide errors from visitors: ✔

Active Plugins (14)

WPElite Plugins Updater: by WPElitePlugins – 1.0.1
Archive Control: by Jesse Sutherland – 1.3.3
Auto Image Attributes From Filename With Bulk Updater: by Arun Basil Lal – 1.6
Contact Form 7: by Takayuki Miyoshi – 5.2.1
Stop Generating Unnecessary Thumbnails: by codexpert – 3.0.4
Jetpack by WordPress.com: by Automattic – 8.8.1
Kwayy HTML Sitemap: by Kwayy Infotech – 3.1
reCAPTCHA for WooCommerce: by WPElitePlugins – 1.0.9 – Installed version not tested with active version of WooCommerce 4.3.2
WooCommerce Square: by WooCommerce – 2.1.6
WooCommerce: by Automattic – 4.3.2
Yoast SEO: by Team Yoast – 14.7
WP Mail SMTP: by WPForms – 2.2.1
WP-Optimize - Clean, Compress, Cache: by David Anderson
Ruhani Rabin
Team Updraft – 3.1.2

ReCaptcha v2 for Contact Form 7: by IQComputing – 1.2.7

Inactive Plugins (0)

Dropin Plugins (1)

advanced-cache.php: advanced-cache.php

Settings

API Enabled: –
Force SSL: –
Currency: GBP (£)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: downloadable (downloadable)
external (external)
grouped (grouped)
simple (simple)
subscription (subscription)
variable (variable)
variable subscription (variable-subscription)
virtual (virtual)

Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)

Connected to WooCommerce.com: ✔

WC Pages

Shop base: #3068 - /shop/
Basket: #2897 - /basket/
Checkout: #2898 - /checkout/
My account: ❌ Page visibility should be public
Terms and conditions: #35 - /terms-conditions/

Theme

Name: thinkjarvis
Version: 1.0
Author URL: https://www.thomasjarvisdesign.co.uk
Child Theme: ✔
Parent Theme Name: Enfold
Parent Theme Version: 4.7.5
Parent Theme Author URL: https://kriesi.at
WooCommerce Support: ✔

Templates

Overrides: thinkjarvis/woocommerce/archive-product.php
thinkjarvis/woocommerce/checkout/form-shipping.php

Square

Environment: Production
Tokenization Enabled: –
Debug Mode: Off

Action Scheduler

Complete: 132
Oldest: 2020-07-22 15:48:19 +0100
Newest: 2020-08-10 17:27:52 +0100

Pending: 1
Oldest: 2020-08-12 18:15:01 +0100
Newest: 2020-08-12 18:15:01 +0100

`

The System Status Report is found in your WordPress admin under **WooCommerce > Status**. 
Please select “Get system report”, then “Copy for support”, and then paste it here.

`

WordPress Environment

WordPress address (URL): https://www.simplyneedlecraft.com
Site address (URL): https://www.simplyneedlecraft.com
WC Version: 4.3.2
REST API Version: ✔ 1.0.10
WC Blocks Version: ✔ 2.7.3
Action Scheduler Version: ✔ 3.1.6
WC Admin Version: ✔ 1.3.1
Log Directory Writable: ✔
WP Version: 5.4.2
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_GB
External object cache: –

Server Environment

Server Info: Apache
PHP Version: 7.3.21
PHP Post Max Size: 64 MB
PHP Time Limit: 50000
PHP Max Input Vars: 5000
cURL Version: 7.64.0
OpenSSL/1.1.1d

SUHOSIN Installed: –
MySQL Version: 5.7.30-log
Max Upload Size: 64 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

Database

WC Database Version: 4.3.2
WC Database Prefix: wpet_
Total Database Size: 99.22MB
Database Data Size: 89.09MB
Database Index Size: 10.13MB
wpet_woocommerce_sessions: Data: 56.09MB + Index: 2.05MB + Engine InnoDB
wpet_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wpet_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_woocommerce_order_itemmeta: Data: 0.09MB + Index: 0.09MB + Engine InnoDB
wpet_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wpet_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_actionscheduler_actions: Data: 0.06MB + Index: 0.11MB + Engine InnoDB
wpet_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_actionscheduler_logs: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wpet_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_comments: Data: 0.06MB + Index: 0.09MB + Engine InnoDB
wpet_layerslider: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_layerslider_revisions: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_options: Data: 15.39MB + Index: 0.41MB + Engine InnoDB
wpet_postmeta: Data: 9.52MB + Index: 4.03MB + Engine InnoDB
wpet_posts: Data: 2.52MB + Index: 0.64MB + Engine InnoDB
wpet_termmeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wpet_terms: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wpet_term_relationships: Data: 0.39MB + Index: 0.22MB + Engine InnoDB
wpet_term_taxonomy: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wpet_tm_taskmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_tm_tasks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_usermeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wpet_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wpet_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wpet_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wpet_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_wc_product_meta_lookup: Data: 0.25MB + Index: 0.39MB + Engine InnoDB
wpet_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_woocommerce_square_customers: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_wpmailsmtp_tasks_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_yoast_indexable: Data: 3.52MB + Index: 1.03MB + Engine InnoDB
wpet_yoast_indexable_hierarchy: Data: 0.05MB + Index: 0.05MB + Engine InnoDB
wpet_yoast_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_yoast_primary_term: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_yoast_seo_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wpet_yoast_seo_meta: Data: 0.14MB + Index: 0.00MB + Engine InnoDB

Post Type Counts

attachment: 2311
avia_framework_post: 36
flamingo_contact: 3
flamingo_inbound: 2
nav_menu_item: 172
oembed_cache: 3
page: 15
post: 3
product: 1224
product_variation: 661
revision: 73
shop_coupon: 2
shop_order: 44
shop_order_refund: 5
wpcf7_contact_form: 1

Security

Secure connection (HTTPS): ✔
Hide errors from visitors: ✔

Active Plugins (14)

WPElite Plugins Updater: by WPElitePlugins – 1.0.1
Archive Control: by Jesse Sutherland – 1.3.3
Auto Image Attributes From Filename With Bulk Updater: by Arun Basil Lal – 1.6
Contact Form 7: by Takayuki Miyoshi – 5.2.1
Stop Generating Unnecessary Thumbnails: by codexpert – 3.0.4
Jetpack by WordPress.com: by Automattic – 8.8.1
Kwayy HTML Sitemap: by Kwayy Infotech – 3.1
reCAPTCHA for WooCommerce: by WPElitePlugins – 1.0.9 – Installed version not tested with active version of WooCommerce 4.3.2
WooCommerce Square: by WooCommerce – 2.1.6
WooCommerce: by Automattic – 4.3.2
Yoast SEO: by Team Yoast – 14.7
WP Mail SMTP: by WPForms – 2.2.1
WP-Optimize - Clean, Compress, Cache: by David Anderson
Ruhani Rabin
Team Updraft – 3.1.2

ReCaptcha v2 for Contact Form 7: by IQComputing – 1.2.7

Inactive Plugins (0)

Dropin Plugins (1)

advanced-cache.php: advanced-cache.php

Settings

API Enabled: –
Force SSL: –
Currency: GBP (£)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: downloadable (downloadable)
external (external)
grouped (grouped)
simple (simple)
subscription (subscription)
variable (variable)
variable subscription (variable-subscription)
virtual (virtual)

Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)

Connected to WooCommerce.com: ✔

WC Pages

Shop base: #3068 - /shop/
Basket: #2897 - /basket/
Checkout: #2898 - /checkout/
My account: ❌ Page visibility should be public
Terms and conditions: #35 - /terms-conditions/

Theme

Name: thinkjarvis
Version: 1.0
Author URL: https://www.thomasjarvisdesign.co.uk
Child Theme: ✔
Parent Theme Name: Enfold
Parent Theme Version: 4.7.5
Parent Theme Author URL: https://kriesi.at
WooCommerce Support: ✔

Templates

Overrides: thinkjarvis/woocommerce/archive-product.php
thinkjarvis/woocommerce/checkout/form-shipping.php

Square

Environment: Production
Tokenization Enabled: –
Debug Mode: Off

Action Scheduler

Complete: 132
Oldest: 2020-07-22 15:48:19 +0100
Newest: 2020-08-10 17:27:52 +0100

Pending: 1
Oldest: 2020-08-12 18:15:01 +0100
Newest: 2020-08-12 18:15:01 +0100

`

@juliaamosova
Copy link
Contributor

Hi @thinkjarvisdesignandmarketing,

Thank you for submitting the issue. However, I can’t reproduce the issue you reported using the steps you provided. Everything is working as expected on my end.

Below are the steps I took to document the process:

  1. I created a product without an image:

1

  1. I added an image to the Media library and copied its URL:

2

  1. I exported products using built-in WooCommerce product exporter by navigating to Products/All Products/Export:

0 1

  1. Next, I added the image URL I copied in step 2 in the image row in the exported CSV file and saved the file:

3

4

  1. Imported the CSV file back to the site using built-in WooCommerce product importer by navigating to Products/All Products/Import:

0 2

  1. I checked All Products view and saw the product had an image as expected:

5

  1. Product page also had that same image as expected:

6

In regards to your issue: are you using built-in WooCommerce products importer/exporter? I see on your screenshot that there is Attach button next to the image :

attach

This Attach button is not a part of the WooCommerce Core.

Furthermore, I see that you have several plugins installed and that you don’t use one of our default themes which could cause an issue. Please test your site for theme and plugins conflict. To do that, you’d need to deactivate all plugins except for WooCommerce and switch the default theme such as Storefront. Then test again.

If the issue is resolved with the default theme and all plugins deactivated, it means that one of your plugins or a theme is causing the issue. You will then need to enable it one by one and test every time you do that in order to figure out which plugin is causing the issue.

The ERROR: The images are not included in the XML sitemap either

WooCommerce itself doesn't generate an XML sitemap. It is usually done using a 3rd party plugin. I assume you use the Yoast SEO plugin to generate an XML sitemap. I recommend you connect with their team to see if they can help you further with that.

@juliaamosova juliaamosova added status: can't reproduce Issues that can't be reproduced. needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. labels Aug 13, 2020
@thinkjarvisdesignandmarketing
Copy link
Author

Thank you for your attempts at re-creating the problem.
The uploaded to column is part of Wordpress core in the media library. The problem is that it does not get updated when products are imported in bulk.

If you were to browse to the Rick and Morty (love the test by the way) product and manually set the featured image while editing the product directly, the image becomes attached to the post. It does not make this association when you upload in bulk. (all images remain unattached in Wordpress Core).

Further to your test - The final step in your investigation should have been to open the media library so you can see that the image is not attached to a post in the system. Therefore the rest of the system cannot see which image is associated with which page. This is causing problems with SEO plugins like Yoast which uses the featured image as the social share image.
without the attachment to the page being updated on upload it does not correctly associate the share image with the page. This is a Woo Commerce bulk upload issue which affects the wider system and common setup used by a large proportion of store owners.

Can you take another look? and see if the attachment was made when you used the bulk importer to change the image for the rick and morty product.

Perhaps try creating the product from scratch using the bulk upload from CSV rather than creating Rick and Morty first?

@juliaamosova juliaamosova added needs: triage feedback Issues for which we requested feedback from the author and received it. and removed status: can't reproduce Issues that can't be reproduced. needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. labels Aug 18, 2020
@tammullen
Copy link
Contributor

Hi @thinkjarvisdesignandmarketing

Sorry for the delay in replying

As mentioned we see that you have several plugins installed and that you don’t use one of our default themes which could cause an issue. Please confirm if you performed initial troubleshooting such as testing for theme and plugins conflict on your site? To do that, you’d need to deactivate all plugins except for WooCommerce and switch the default theme such as Storefront. Then test again.

If the issue is resolved with the default theme and all plugins deactivated, it means that one of your plugins or a theme is causing the issue. You will then need to enable it one by one and test every time you do that in order to figure out which plugin is causing the issue.

@tammullen tammullen added needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. and removed needs: triage feedback Issues for which we requested feedback from the author and received it. labels Mar 25, 2021
@thinkjarvisdesignandmarketing
Copy link
Author

Thanks for keeping this thread alive. I'll check and get back to you.

However The default Import and export functions are the same regardless of the theme or plugins used.

This is about making the system more robust for end users who dont know about custom meta data.

For Yoast to pick up the feature image rather than explicitly stating a social share image in the settings.

It is possible to export the Yoast Custom metadata with each product, so the featured image URL can be copied into the Yoast meta data columns.

However this still does not attach the image to the post in the way that it should.

@rrennick rrennick added needs: triage feedback Issues for which we requested feedback from the author and received it. and removed needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. labels Apr 13, 2021
@com2
Copy link

com2 commented Jun 3, 2021

I can confirm the same issue as reported here. I have the feeling @juliaamosova failed to understand the issue. When it is her screenshot, she does not seem to see that even there the imported image is still unattached, which was the whole idea of this issue report. When it is not her screenshot, then she should try to reproduce again and look at the image in the Media library if it is still unattached.

I underline that it is not the issue that the images are not imported, not attached to the products, do not show up in de product views. The issue is that the Media Library is no consistent with this, because it still indicates the image as unattached.

This is very annoying because the whole idea of that indication is that users can do some rubbish management. What happens when an ignorant user starts deleting images because they seem not to be in use? I foresee mayor disaster and complaints when this bug is not taken serious. I have to instruct my client to not delete any media library content even though it seems unused. He or his colleagues will forget and one day I see myself re-importing all products and images.

@AashikP
Copy link
Collaborator

AashikP commented Sep 3, 2021

Hi there!

Thank you for taking the time to report this bug, we really appreciate your help. I can reproduce it on my end.

When a product image is manually added, it is Attached to the product when viewed in Media Library. However, even though a CSV import updates the product image correctly, it is not attached to the product itself when viewed through the media library

https://d.pr/i/TewlQZ+

https://d.pr/i/T7IQtb+

I'm also updating the title to better reflect the same.

Priority of this issue will be assigned shortly after we'd go through a round of prioritization. Please note it may take a couple of days.

@AashikP AashikP added focus: csv import/export Issues related to CSV import and export. type: bug The issue is a confirmed bug. and removed needs: triage feedback Issues for which we requested feedback from the author and received it. labels Sep 3, 2021
@AashikP AashikP changed the title Image attachments during CSV Import not working Imported images are not attached / linked to products in Media Library Sep 3, 2021
@thinkjarvisdesignandmarketing
Copy link
Author

Thanks AashikP! Looking forward to getting a fix for this in one of the future builds of WooCommerce.

Will there be a notification on this post when a solution has been found?

@AashikP
Copy link
Collaborator

AashikP commented Sep 6, 2021

Will there be a notification on this post when a solution has been found?

As long as you've subscribed to this issue, you will receive email notifications for any comments on this.

https://d.pr/i/2EmX9K+

@HameedFarah
Copy link

Any updates on this issue?
Does anyone have any idea how to reattach the products images?

@pleinairman
Copy link

pleinairman commented Oct 26, 2021

Same problem here, but I am not adding products in bulk. I add products one at a time and select "set product image". After the product is published, I can go to the media library and see that the image is not attached. This is a problem, because when I delete products, I want to be able to go to the media library, filter on images that are unattached, and delete them. The only way this would work is for the image to be attached when the product is created and, I am assuming, when the product is deleted, the image becomes unattached - correct? Otherwise, the only way to delete product-related images would be to hunt for them manually.

@realmofevil
Copy link

realmofevil commented Oct 30, 2021

Same problem here, but I am not adding products in bulk. I add products one at a time and select "set product image". After the product is published, I can go to the media library and see that the image is not attached. This is a problem, because when I delete products, I want to be able to go to the media library, filter on images that are unattached, and delete them. The only way this would work is for the image to be attached when the product is created and, I am assuming, when the product is deleted, the image becomes unattached - correct? Otherwise, the only way to delete product-related images would be to hunt for them manually.

Same problem. +1
I have some images that are uploaded separately from the product creation process, then added them as product gallery images manually but they still show up in Media when filtered as Unattached. Luckily I now saw on the screenshots that there is an attach button when you view the media as a list which I used in my case because they were below 30 but this won't work if you have hundreds of media files. Not sure why they show up as unattached when I attached them already obviously but that looks like the same bug.

@jmruas
Copy link

jmruas commented Feb 24, 2022

When we import somes images they are always unattached to the posts. Just test import posts first, then import images and you see. This is a Wordpress issue.

@thinkjarvisdesignandmarketing
Copy link
Author

Hi Jmruas,
I do not understand your comment. I think you are saying that if you follow this same process with the default Wordpress importer that feature images are not attached to the posts. This is a different process and would not use a CSV file in the same way product data is imported and processed.

This is a WooCommerce issue.
The import/export of Wordpress posts has a different intent to WooCommerce uploads. It does not use CSV files to start with.

This is an issue with WooCommerce CSV Imports.

If the issue exists when importing other content it is a seperate issue and should be raised with WordPress.

I am replying to try and stop the Moderators from remove any commits or potential commits from this issue.

@jmruas
Copy link

jmruas commented Feb 24, 2022

Media Sync - a free plugin with 24kb - solve the problem. I tried and it works.

@jmruas
Copy link

jmruas commented Feb 24, 2022 via email

@thinkjarvisdesignandmarketing
Copy link
Author

Looking at the description of Media Sync you have misunderstood this issue.

The issue is that when you import product data via CSV and include image URLs, the media attachements do not update - This means that plugins like Yoast struggle to automatically select an image for Social shares and if you tried to tidy up the media library with any tools it will think the images are not in use.

Media Sync is used to add items to the Wordpress database if you manually add them to the Uploads folder. Not to set page attachements.

@jmruas
Copy link

jmruas commented Feb 24, 2022 via email

@thinkjarvisdesignandmarketing
Copy link
Author

No worries jmruas thank you for contributing.

I know it takes time for a member of the WooCommerce team to pick up or be allocated a known bug. I didnt want them to remove it from the bug tag.

I do not have great enough knowledge of the upload process to tackle this issue myself. Hoping it gets allocated to someone soon.

@gomlers
Copy link

gomlers commented Apr 29, 2022

I can confirm this error report

Woocommerce Version 6.4.1
Tool: Tools -> Import -> WooCommerce products (CSV)_

Problem
When you import a CSV containing at least column headers: SKU, Name and Images, the images are not attached automatically to the products imported.

The products will show the correct images on the front-end and back-end as well, but the images in the media library is "unattached".

Issues existing because of this:

  • SEO plugins will have problems optimizing
  • When cleaning DB, you will risk cleaning out product images, since they seems to be unattached - even though they should not be.

Hoping for a fix soon!
import-products-unattached-images
import-products-unattached-images_csv

@peterfabian peterfabian added the priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. label May 5, 2022
@peterfabian
Copy link
Contributor

Since we assign the image to the correct product, I assume attaching it shouldn't be that much more difficult. PRs are welcome.

@bb3cpo
Copy link

bb3cpo commented Oct 22, 2022

I have the same problem when I use the bulk upload with CSV for products. The images are shown as "Unattached" in Media Librady although they are shown in the front-end.

@pegues
Copy link

pegues commented Dec 6, 2022

Using a CSV file to import over 1200 products. All data transfers except for media. Migrating from Shopify to WooCommerce.

@thinkjarvisdesignandmarketing
Copy link
Author

Using a CSV file to import over 1200 products. All data transfers except for media. Migrating from Shopify to WooCommerce.

This is an unrelated issue by the sounds of it. The WordPress default CSV file import does not import images from third parties.
The CSV file allows you to specify the URL of the image but does not actually import it into your WordPress media library.

If you want to import images directly from Shopify you may be able to do it using https://www.wpallimport.com/
I am using this plugin at the moment to import product data from third parties onto two websites.

As the thread creator the issue I raised is still a problem in WooCommerce.

@pegues
Copy link

pegues commented Dec 8, 2022

Using a CSV file to import over 1200 products. All data transfers except for media. Migrating from Shopify to WooCommerce.

This is an unrelated issue by the sounds of it. The WordPress default CSV file import does not import images from third parties. The CSV file allows you to specify the URL of the image but does not actually import it into your WordPress media library.

If you want to import images directly from Shopify you may be able to do it using https://www.wpallimport.com/ I am using this plugin at the moment to import product data from third parties onto two websites.

As the thread creator the issue I raised is still a problem in WooCommerce.

I'm using the WooCommerce importer for products, not WordPress import for post types. The WooCommerce importer allows you to import products and associated meta data and images from other sources via a CSV file with field mapping. The importer has issues with loading the media despite correct mapping. WooCommerce's solution is to use a 3rd party tool, Cart2Cart. So... there is an issue with the "WooCommerce" importer - you can even download all media from the "migtated-from" solution such as Shopify and load them into the WP media lib. After doing that you can change the path to images in the CSV, which should definitely have no issue with loading the media at that point despite cors or any other issues. And still, the media is not imported.

I've gone ahead and created a migration script that will load the images, which may even solve your problem. But it should not be necessary to have to do so. And, I won't share the solution because it would then prevent WooCommerce from fixing all these import issues they seem to not worry about.

@thinkjarvisdesignandmarketing
Copy link
Author

@pegues
Thanks for this.
As above wpallimport can also do this as a third party tool.

The issue on this ticket is that the image attachements dont generate when using WooCommerce default import/export functions. Not platform specific.

It means that when you specify URLs on the import CSV file WooCommerce/WordPress does not automatically associate them with the post (No attachement ID) even though the image is clearly set as the featured image.

Someone else did some digging as above and found an issue with the order that the imports are processed. So there is a bug in the default WooCommerce importer.

Try Wp All Import for your specific problem. I have used this with success for data imports from CSV and FTP feeds for clients recently - and it re-attaches the images correctly.

@erikdemarco
Copy link
Contributor

This is an issue with WooCommerce CSV Imports.

This not just woocommerce import issue. If you create a product from admin panel and set featured image or gallery image. all of this images also will not attached to the product post.

@LevelUpGit
Copy link

Hi, we also came across this issue, but found simple solution with this SQL https://wordpress.stackexchange.com/questions/275548/attach-unattached-featured-images-to-respective-posts, it just needs to be extended to work with gallery images. Someone can make it into a plugin.

@SapphireINT
Copy link

Not sure if anyone is still looking or searching for a fix so I am sharing in case I can be of help. I spent many hours trying to deal with this dilemma and found the solution. I changed my uploads folder to wp-content/uploads/wpallimport/files/

Now whenever I import images, they attach to the products with no issues.

@thinkjarvisdesignandmarketing
Copy link
Author

thinkjarvisdesignandmarketing commented Apr 5, 2023

@SapphireINT
This is to do with the default Woocommerce importer not WP All Import.

I am a WPAllImport user as well I have a studio license. All Import does not suffer these issues but the default WooCommerce importer does.

This is a bug in WooCommerce that has not been resolved yet

You do not need to change the uploads folder when using WPAllImport it does attach featured images correctly to posts.

This Github issue is still unresolved but @LevelUpGit has posted a solution using some SQL commands that works by modifying the database.

I hope this helps

@SapphireINT
Copy link

From my experience, when first importing with WP Allimport with url's located elsewhere, no problem attaching at all. When I manually add images and import my products using a csv file with the filename or url, the images don't attach. They do associate with the correct product but do not attach. I've tried many different ways and cannot get them to attach to the product. If you could enlighten me on how you get the images manually added to attach to the product, that would be great.

I don't use the WooCommerce import.

I did try the SQL but it did not work. It was no issue at all moving my images to the WP All import directory. I worked with my hosting provider and now, not one single issue. And moving forward, it is now seamless and I don't have to bother with a 'fix'.

These back and forth, reading others comments and experiences is how we learn and share. Thank you for the feedback

@thinkjarvisdesignandmarketing
Copy link
Author

Thanks @SapphireINT I wasnt doubting your suggestion but I have not encountered that specific issue myself with gallery images not getting the right attachements.

I am trying to keep this thread clear and open so hopefully someone in the Woocommerce import/export team picks it up - The issue raised in this thread is still active.

Thank you for sharing your solution.

@plexus77
Copy link

If anyone needs a quick fix for this then the following code will make it so that when the product is saved any images in the product gallery will be attached to the post. It doesn't detach images though, this is probably not needed in most cases. Would be easy to do if you changed the priority and retrieved the previous version of the product gallery and did a diff between that and the new one detaching the product from any images that are in the old one and not the new one.

add_action( 'woocommerce_process_product_meta', function ( $post_id, $post ) {
    global $wpdb;
    $attachment_ids = isset( $_POST['product_image_gallery'] ) ? array_filter( explode( ',', wc_clean( $_POST['product_image_gallery'] ) ) ) : array();

    // update posts in the $attachment_ids array to have post_parent = $post_id
    $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE ID IN (" . implode( ',', $attachment_ids ) . ")", $post_id ) );
}, 21, 2 );

@rrennick rrennick mentioned this issue Sep 7, 2023
11 tasks
@rrennick rrennick added the team: Proton WC Core development and maintenance label Oct 13, 2023
@NBSUKLTD
Copy link

This is still a issue but yes the following SQL script fixed this for me.

UPDATE wp_posts AS p INNER JOIN ( SELECT p.ID AS attachment_id, pm.post_id AS post_id FROM wp_posts p JOIN wp_postmeta pm ON pm.meta_value = p.ID WHERE ( pm.meta_key = '_thumbnail_id' AND p.post_type = 'attachment' AND p.post_parent = 0 ) ) AS b ON p.ID = b.attachment_id SET p.post_parent = b.post_id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: csv import/export Issues related to CSV import and export. plugin: woocommerce Issues related to the WooCommerce Core plugin. priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. team: Proton WC Core development and maintenance type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.