public static function setList($list) { $sql = 'UPDATE {{catalog}} SET available=0'; DB::exec($sql); foreach ($list as $partname => $items) { $sql = 'SELECT tree FROM {{catalog}} WHERE partname="' . $partname . '"'; $parent = DB::getOne($sql); if ($parent) { $available = 0; foreach ($items as $size => $item) { $sql = 'SELECT id FROM {{tree}} WHERE parent=' . $parent . ' AND name="' . $size . '"'; $tree = DB::getOne($sql); if (!$tree) { $sql = 'SELECT id FROM {{tree}} WHERE parent=' . $parent . ' AND path="' . $size . '"'; $tree = DB::getOne($sql); } foreach ($item as $k => $f) { $sql = 'SELECT type FROM {{fields}} WHERE module=6 AND path="' . $k . '"'; $r = DB::getOne($sql); $row = array('field' => Fields::$types[$r]['type'], 'path' => $k, 'value' => $f); Price::updateField($tree, $row); if ($k == 'numberRetailSales' && $f > 0) { $available = 1; } } } $sql = 'UPDATE {{catalog}} SET available=' . $available . ' WHERE tree=' . $parent; DB::exec($sql); } } }