tep_db_connect(); use_class('styles'); use_class('Product'); $class_s = new styles(); $dest_path = 'OTTO-Online-' . date('ymd') . '/'; if (!is_dir($dest_path)) { mkdir($dest_path, 0750); } $styles_id = tep_db_prepare_input($_GET['styles_id']); $products = array_keys($class_s->retrieveProducts($styles_id)); foreach ($products as $pid) { $p = new Product($pid); $images = array(); $main_default = $p->getImageRaw(Product::IMAGE_TYPE_DEFAULT); $main_amazon = $p->getImageRaw(Product::IMAGE_TYPE_AMAZON); $images[] = is_null($main_amazon) || $main_amazon == '' ? $main_default : $main_amazon; $total_additional_image = $p->getAdditionalImageTotal(); for ($i = 0; $i < $total_additional_image; $i++) { $images[] = $p->getImageAdditionalRaw($i); } $image_counter = 0; foreach ($images as $image) { $image_counter++; $img_location = is_file($image) ? $image : DIR_WS_IMAGES . $image; $new_filename = $p->code . '-' . $image_counter . '.jpg'; $new_location = $dest_path . $new_filename; copy($img_location, $new_location); } } echo 'All Images Created!'; tep_db_close();