I've created a script for the same. You can achieve this by executing the script on your website.
For Magento 2
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$productCollection = $objectManager->create('Magento\Catalog\Model\Product');
$configProductIds = [1,2,3,4,5,6]; //configurable product ids to update images
foreach ($configProductIds as $product_id) {
$configProduct = $productCollection->load($product_id);
$image = $configProduct->getImage();
$thumbnail = $configProduct->getThumbnail();
$smallImage = $configProduct->getSmallImage();
$_children = $configProduct->getTypeInstance()->getUsedProducts($configProduct);
foreach ($_children as $child){
$childProduct = $productCollection->load($child->getId());
$childProduct->addImageToMediaGallery($image, ['image', 'small_image', 'thumbnail'], false, false);
$childProduct->save();
}
}
For Magento 1
<?php
define('MAGENTO_ROOT', getcwd());
include_once "app/Mage.php";
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
Mage::init();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
umask(0);
Mage::app('admin');
set_time_limit(0);
ini_set('memory_limit', '2048M');
try {
$configProductIds = [1,2,3,4,5,6]; //configurable product ids to update images
foreach ($configProductIds as $product_id) {
$configProduct = Mage::getModel('catalog/product')->load($product_id);
$image = $configProduct->getImage();
$thumbnail = $configProduct->getThumbnail();
$smallImage = $configProduct->getSmallImage();
$childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($configProduct->getId());
foreach ($childIds as $childId){
$childProduct = Mage::getModel('catalog/product')->load(childId);
$childProduct->addImageToMediaGallery($image, array('image', 'small_image', 'thumbnail'), false, false);
$childProduct->save();
}
} catch (Exception $e) {
print_r($e->getMessage());
}
Hope it helps!!!