/** * @param ImportProduct $product * @param &$images * @param &$thumbnail * @throws Exception */ private function getImages($product, &$images, &$thumbnail) { $localProduct = $this->modelCatalogProduct->getProduct($product->getLocalProductId()); foreach ($this->modelCatalogProduct->getProductImages($product->getLocalProductId()) as $image) { if (file_exists(DIR_IMAGE . $image['image']) && is_file(DIR_IMAGE . $image['image'])) { unlink(DIR_IMAGE . $image['image']); } } if (file_exists(DIR_IMAGE . $localProduct['image']) && is_file(DIR_IMAGE . $localProduct['image'])) { unlink(DIR_IMAGE . $localProduct['image']); } /** @var ModelToolImage $modelToolImage */ $modelToolImage = $this->load->model('tool/image'); try { $thumbnail = $modelToolImage->download($product->getThumbnailUrl()); } catch (Exception $e) { $error = "Couldn't download a thumbnail '" . $product->getThumbnailUrl() . "' for product " . $product->getId(); $this->getLogger()->write($error); $this->getLogger()->write($e->getMessage()); $this->data['notifications']['error'] .= "{$error}<br />"; } foreach ($product->getImages() as $imageUrl) { try { $images[] = array('image' => $modelToolImage->download($imageUrl)); } catch (Exception $e) { $error = "Couldn't download an image '{$imageUrl}' for product " . $product->getId(); $this->getLogger()->write($error); $this->data['notifications']['error'] .= "{$error}<br />"; } } }