Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8040485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:54:43+00:00 2026-06-05T03:54:43+00:00

I have an import script that imports well over 2000+ products including their images.

  • 0

I have an import script that imports well over 2000+ products including their images. I run this script via CLI because I feel that this is the best way to go speed-wise even though I have the same import script available and executable at the magento admin as an extension. The script runs pretty well. Almost perfect! However, sometimes the addToImageGallery somehow malfunctions and results into some images having No Image as the default product image and the only other image as not selected as defaults at all. How do I mass-update all products to set the first image in the media gallery for the product to the default ‘base’, ‘image’ and ‘thumbnail’ image(s)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:54:45+00:00Added an answer on June 5, 2026 at 3:54 am

    I found a couple of tricks on doing this (and more) on this link:

    http://www.magentocommerce.com/boards/viewthread/59440/ (Thanks transio!)

    Although, for Magento 1.6.2.0 (which I use), the first SQL trick there (Trick 1 – Auto-set default base, thumb, small image to first image.) needs a bit of modification.

    On the second-to-the last-line there is a AND ev.attribute_id IN (70, 71, 72) part. This should point to attribute ID’s which will probably not be relevant in Magento 1.6.2.0 anymore. To fix this, using any MySQL query tool (PHPMyAdmin or MySQL Query Browser), I took a look at the catalog_product_entity_varchar table. There should be entries like:

    value_id, entity_type_id, attribute_id, store_id, entity_id, value
    ..
    146649, 4, 116, 0, 1, '2'
    146650, 4, 76, 0, 1, ''
    146651, 4, 78, 0, 1, ''
    146652, 4, 79, 0, 1, '/B/0/B05-01.jpg'
    146653, 4, 80, 0, 1, '/B/0/B05-01.jpg'
    146654, 4, 81, 0, 1, '/B/0/B05-01.jpg'
    146655, 4, 96, 0, 1, ''
    146656, 4, 100, 0, 1, ''
    146657, 4, 102, 0, 1, 'container2'
    ..
    

    My money was on the group of three image paths as possible replacements. So the resulting SQL now should be:

    UPDATE catalog_product_entity_media_gallery AS mg,
        catalog_product_entity_media_gallery_value AS mgv,
        catalog_product_entity_varchar AS ev
    SET ev.value = mg.value
    WHERE  mg.value_id = mgv.value_id
        AND mg.entity_id = ev.entity_id
        AND ev.attribute_id IN (79, 80, 81) # <-- attribute IDs updated here
        AND mgv.position = 1;
    

    So I committed to it, ran it and.. presto! All fixed! You might also want to encapsulate this in a transaction if you want. But this is out of this question’s scope.

    Well, this is the fix that worked for me so far! If there are any more out there, please share!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that imports a models.py from an app, but it will
I have a VBA script that imports a layout into an exsting drawing, its
I have the following situation. I have a PHP script that imports a CSV
I have a Python script that uses built-in modules but also imports a number
Let's assume I have a main script, main.py, that imports another python file with
I have some questions about the performance of this simple python script: import sys,
I have to run my python script as win32 service as following: aservice.py import
I have an application that can import an XML file through this terminal command
well, I have a script which processes some data, and then it imports it
I have a module that imports an Access table to MS Office Excel. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.