public/admin/controller/catalog/product.php:1351 — вместо вывода только привязанных к товару атрибутов, теперь получает ВСЕ атрибуты из БД, сгруппированные по группам, и сопоставляет с сохранёнными значениями.
public/admin/view/template/catalog/product_form.twig:494 — вместо таблицы с автокомплитом и кнопками добавления/удаления, теперь статический вывод: группы атрибутов панелями, слева название, справа textarea. JS-код addAttribute/attributeautocomplete удалён. public/admin/model/catalog/product.php:25,183 — в addProduct() и editProduct() добавлена проверка !empty($text) — сохраняются только заполненные textarea, пустые пропускаются.
This commit is contained in:
@@ -25,13 +25,12 @@ class ModelCatalogProduct extends Model {
|
||||
if (isset($data['product_attribute'])) {
|
||||
foreach ($data['product_attribute'] as $product_attribute) {
|
||||
if ($product_attribute['attribute_id']) {
|
||||
// Removes duplicates
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' AND attribute_id = '" . (int)$product_attribute['attribute_id'] . "'");
|
||||
|
||||
foreach ($product_attribute['product_attribute_description'] as $language_id => $product_attribute_description) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' AND attribute_id = '" . (int)$product_attribute['attribute_id'] . "' AND language_id = '" . (int)$language_id . "'");
|
||||
if (!empty($product_attribute_description['text'])) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' AND attribute_id = '" . (int)$product_attribute['attribute_id'] . "' AND language_id = '" . (int)$language_id . "'");
|
||||
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET product_id = '" . (int)$product_id . "', attribute_id = '" . (int)$product_attribute['attribute_id'] . "', language_id = '" . (int)$language_id . "', text = '" . $this->db->escape($product_attribute_description['text']) . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET product_id = '" . (int)$product_id . "', attribute_id = '" . (int)$product_attribute['attribute_id'] . "', language_id = '" . (int)$language_id . "', text = '" . $this->db->escape($product_attribute_description['text']) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -186,11 +185,10 @@ class ModelCatalogProduct extends Model {
|
||||
if (!empty($data['product_attribute'])) {
|
||||
foreach ($data['product_attribute'] as $product_attribute) {
|
||||
if ($product_attribute['attribute_id']) {
|
||||
// Removes duplicates
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' AND attribute_id = '" . (int)$product_attribute['attribute_id'] . "'");
|
||||
|
||||
foreach ($product_attribute['product_attribute_description'] as $language_id => $product_attribute_description) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET product_id = '" . (int)$product_id . "', attribute_id = '" . (int)$product_attribute['attribute_id'] . "', language_id = '" . (int)$language_id . "', text = '" . $this->db->escape($product_attribute_description['text']) . "'");
|
||||
if (!empty($product_attribute_description['text'])) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET product_id = '" . (int)$product_id . "', attribute_id = '" . (int)$product_attribute['attribute_id'] . "', language_id = '" . (int)$language_id . "', text = '" . $this->db->escape($product_attribute_description['text']) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user