Additional Images Magento

How to add the additional images to the configurable magento product

$importDir = Mage::getBaseDir('media') . DS;
 // additional images
        if ($import_product[29] != '') {
            $addImages = explode(",", trim($import_product[29]));
            foreach ($addImages as $additional_image) {
                $image_directory = $dir .DS.'data'.DS. trim($additional_image);
                if (file_exists($image_directory)) {
                    $product->addImageToMediaGallery($image_directory, null, false, false);
                } else {
                    $image_directory = $dir . 'data' . DS . 'comingsoon.jpg';
                    $product->addImageToMediaGallery($image_directory, null, false, false);
                }
            }
            echo 'Additional images for product ' . $product->getName() . ' ' . $product->getId() . ' imported successfully' . PHP_EOL;
        }

Share this Tutorial