From 5bef325653474cccb220b265db8a08d6819d176e Mon Sep 17 00:00:00 2001 From: Anton Bashurov Date: Wed, 20 Feb 2019 20:26:32 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D1=81=D0=BA=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=BA=D0=BE=20=D0=BA=D0=B0=D1=80=D1=82=D0=B8=D0=BD=D0=BE=D0=BA?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B8=20=D1=81=D0=B8=D0=BD=D1=85=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20=D1=81=201=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit При обновлении изображений оставалась всегда одна, при такой обработке зальются все изображения. Явная ошибка. --- simpla/cml/1c_exchange.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/simpla/cml/1c_exchange.php b/simpla/cml/1c_exchange.php index a357666..9e4bfee 100755 --- a/simpla/cml/1c_exchange.php +++ b/simpla/cml/1c_exchange.php @@ -686,15 +686,19 @@ function import_product($xml_product) // Обновляем изображение товара if(isset($xml_product->Картинка)) { + $simpla->db->query('SELECT id FROM __images WHERE product_id=? ORDER BY position', $product_id); + $img_ids = $simpla->db->results('id'); + foreach ($img_ids as $img_id) + { + if(!empty($img_id)) + $simpla->products->delete_image($img_id); + } + foreach($xml_product->Картинка as $img) { $image = basename($img); if(!empty($image) && is_file($dir.$image) && is_writable($simpla->config->original_images_dir)) { - $simpla->db->query('SELECT id FROM __images WHERE product_id=? ORDER BY position LIMIT 1', $product_id); - $img_id = $simpla->db->result('id'); - if(!empty($img_id)) - $simpla->products->delete_image($img_id); rename($dir.$image, $simpla->config->original_images_dir.$image); $simpla->products->add_image($product_id, $image); }