<?php include dirname(__FILE__) . '/config/config.inc.php'; include dirname(__FILE__) . '/init.php'; include dirname(__FILE__) . '/image_helper.php'; ini_set('max_execution_time', 0); ini_set('memory_limit', '-1'); //$codes = array('MUM0550001','MUM0550002','MUM0550003','MUM0550004','MUM0550005','MUM0550006','MUM0550007','MUM0550008','MUM0550009','MUM0550010','MUM0550011','MUM0550012','MUM0550013'); $codes = array(); foreach ($codes as $code) { $productObj = Product::getByReference($code); $reference = $productObj->reference; $images = $productObj->getImages(1); $id_product = $productObj->id; $productImages = array(); $count = 1; $failed = false; echo "For Product : {$code}"; echo PHP_EOL; flush(); foreach ($images as $k => $image) { $image = $link->getImageLink($productObj->link_rewrite, $image['id_image'], 'thickbox'); $image = (int) preg_replace('/\\D/', '', $image); $str = str_split($image); $filepath = "/var/www/indusdiva.com/img/p/"; $filepath = $filepath . implode("/", $str) . "/" . $image . "-thickbox.jpg"; $new_filename = "{$id_product}_{$count}.jpg"; $new_filename = "/var/www/indusdiva.com/gosf-images/" . $new_filename; $source_gd_image = createImageFromFile($filepath); $new_width = 483; $new_height = 660;
public function handleRelated() { global $currentIndex, $cookie, $smarty; $target_path = _PS_ADMIN_DIR_ . "/product-uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename($_FILES['related_products_file']['name']) . $_SERVER['REQUEST_TIME']; if (move_uploaded_file($_FILES['related_products_file']['tmp_name'], $target_path)) { $f = fopen($target_path, 'r'); //discard header $line = fgetcsv($f); while ($line = fgetcsv($f)) { $reference = $line[0]; $related_references = explode(",", $line[1]); $product = Product::getByReference(trim($reference)); $parent_groupID = $product->id; foreach ($related_references as $reference) { if (empty($reference)) { continue; } $product = Product::getByReference(trim($reference)); $product->id_group = $parent_groupID; if (Validate::isLoadedObject($product)) { $product->update(); } } } } }