diff --git a/classes/Image.php b/classes/Image.php index 848f90bc..f5a2c58b 100755 --- a/classes/Image.php +++ b/classes/Image.php @@ -226,27 +226,55 @@ class ImageCore extends ObjectModel $imageOld = new Image($row['id_image']); $imageNew = clone $imageOld; $imageNew->id_product = (int)($id_product_new); - // A new id is generated for the cloned image when calling add() - if ($imageNew->add()) - { - $new_path = $imageNew->getPathForCreation(); - foreach ($imagesTypes AS $imageType) - { - if (file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg')) - { - if (!Configuration::get('PS_LEGACY_IMAGES')) - $imageNew->createImgFolder(); - copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg', - $new_path.'-'.$imageType['name'].'.jpg'); - } - } - if (file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg')) - copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg', $new_path.'.jpg'); + + if($imageNew->add()) { + $new_path = $imageNew->getPathForCreation(); - self::replaceAttributeImageAssociationId($combinationImages, (int)($imageOld->id), (int)($imageNew->id)); + if(file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg')) { + copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg', $new_path.'.jpg'); + } + + foreach($imagesTypes AS $imageType) { + if(file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg')) { + if(!Configuration::get('PS_LEGACY_IMAGES')) { + $imageNew->createImgFolder(); + } + copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg', $new_path.'-'.$imageType['name'].'.jpg'); + } else { + if(!Configuration::get('PS_LEGACY_IMAGES')) { + $imageNew->createImgFolder(); + } + imageResize($new_path.'.jpg', _PS_PROD_IMG_DIR_.$imageNew->getExistingImgPath().'-'.$imageType['name'].'.jpg', (int) $imageType['width'], (int) $imageType['height']); + } + } + + self::replaceAttributeImageAssociationId($combinationImages, (int)($imageOld->id), (int)($imageNew->id)); + } else { + return FALSE; } - else - return false; + + // // A new id is generated for the cloned image when calling add() + // if ($imageNew->add()) + // { + // $new_path = $imageNew->getPathForCreation(); + // foreach ($imagesTypes AS $imageType) + // { + // if (file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg')) + // { + // if (!Configuration::get('PS_LEGACY_IMAGES')) + // $imageNew->createImgFolder(); + // copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg', + // $new_path.'-'.$imageType['name'].'.jpg'); + // } + // } + // if (file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg')) + // copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg', $new_path.'.jpg'); + + // self::replaceAttributeImageAssociationId($combinationImages, (int)($imageOld->id), (int)($imageNew->id)); + // } + // else + // return false; + } return self::duplicateAttributeImageAssociations($combinationImages); } diff --git a/modules/soflexibilite/soflexibilite.php b/modules/soflexibilite/soflexibilite.php index 70ccdefd..6bcbae82 100644 --- a/modules/soflexibilite/soflexibilite.php +++ b/modules/soflexibilite/soflexibilite.php @@ -1306,14 +1306,6 @@ class soflexibilite extends CarrierModule $soDelivery->city = $address_invoice->city; $soDelivery->country = Country::getIsoById((int)$address_invoice->id_country); }*/ - $address_delivery = new Address((int)$params['cart']->id_address_delivery); - if (Validate::isLoadedObject($address_delivery)) { - $soDelivery->address1 = $address_delivery->address1; - $soDelivery->address2 = $address_delivery->address2; - $soDelivery->postcode = $address_delivery->postcode; - $soDelivery->city = $address_delivery->city; - $soDelivery->country = Country::getIsoById((int)$address_delivery->id_country); - } // OCARAT modif update for customizations if ($this->ps15x) { @@ -1430,13 +1422,15 @@ class soflexibilite extends CarrierModule require_once dirname(__FILE__).'/classes/SoFlexibiliteWebService.php'; // Customer Name - $address = Db::getInstance()->ExecuteS('SELECT * FROM ps_socolissimo_delivery_info WHERE id_cart = '.pSQL((int)$order->id_cart)); + /*$address = Db::getInstance()->ExecuteS('SELECT * FROM ps_socolissimo_delivery_info WHERE id_cart = '.pSQL((int)$order->id_cart)); if(count($address) > 0) { $address = $address[0]; } if (!empty($address['prname']) && !empty($address['prname'])) { $fullname = sprintf('%s %s', $address['prfirstname'], $address['prname']); - } elseif (!empty($soDelivery->firstname) && !empty($soDelivery->lastname)) { + } else*/ + + if (!empty($soDelivery->firstname) && !empty($soDelivery->lastname)) { $fullname = sprintf('%s %s', $soDelivery->firstname, $soDelivery->lastname); } else { $fullname = sprintf('%s %s', $customer_address->firstname, $customer_address->lastname); @@ -1482,7 +1476,8 @@ class soflexibilite extends CarrierModule 'name' => $fullname, 'libelle' => in_array($soDelivery->type, array('DOM', 'DOS', 'BOM', 'BOS')) ? '' : $soDelivery->libelle, 'prid' => $soDelivery->id_point ? sprintf('%06s', $soDelivery->id_point) : null, - 'company' => $soDelivery->company ? $soDelivery->company : $customer_address->company, + /*'company' => $soDelivery->company ? $soDelivery->company : $customer_address->company,*/ + 'company' => $soDelivery->company, 'prname' => isset($relay_informations->nom) ? $relay_informations->nom : '', 'address1' => isset($relay_informations->adresse1) ? $relay_informations->adresse1 : ( in_array($soDelivery->type, array('DOM', 'DOS', 'BOM', 'BOS')) ? @@ -1498,7 +1493,7 @@ class soflexibilite extends CarrierModule 'city' => isset($relay_informations->localite) ? $relay_informations->localite : $soDelivery->city, 'country' => isset($relay_informations->libellePays) ? $relay_informations->libellePays : ( Tools::strlen($soDelivery->country) == 2 ? - Country::getNameById($this->context->employee->id_lang, Country::getByIso($soDelivery->country)) : + Country::getNameById($this->context->employee->id_lang, strtolower($soDelivery->country) == 'fr'? 8: Country::getByIso($soDelivery->country)) : $soDelivery->country ), 'iso_country' => isset($relay_informations->codePays) ? $relay_informations->codePays : $soDelivery->country,