Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

vtx888

Newbie
  
  • Posts

    2
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

vtx888's Achievements

Newbie

Newbie (1/14)

  • First Post
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

1

Reputation

  1. 1) в таблице attribute создаем новое поле в конце oc_filter, по умолчанию null 2) attribute_form.tpl перед </form> <div class="form-group"> <label class="col-sm-2 control-label" for="input-sort-order">Display in oc_filter</label> <div class="col-sm-10"> <div class="checkbox"> <label> <?php if ($oc_filter) { ?> <input type="checkbox" name="oc_filter" value="1" checked="checked" id="input-oc_filter" /> <?php } else { ?> <input type="checkbox" name="oc_filter" value="1" id="input-oc_filter" /> <?php } ?> &nbsp; </label> </div> </div> </div> 3) контроллер attribute.php в функции protected function getForm(), после if (isset($this->request->post['sort_order'])) { $data['sort_order'] = $this->request->post['sort_order']; } elseif (!empty($attribute_info)) { $data['sort_order'] = $attribute_info['sort_order']; } else { $data['sort_order'] = ''; } вставляем if (isset($this->request->post['oc_filter'])) { $data['oc_filter'] = $this->request->post['oc_filter']; } elseif (!empty($attribute_info)) { $data['oc_filter'] = $attribute_info['oc_filter']; } else { $data['oc_filter'] = 0; } 4) модель attribute.php меняем функцию public function editAttribute($attribute_id, $data) { $this->db->query("UPDATE " . DB_PREFIX . "attribute SET attribute_group_id = '" . (int)$data['attribute_group_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', oc_filter = '" . (int)$data['oc_filter'] . "' WHERE attribute_id = '" . (int)$attribute_id . "'"); $this->db->query("DELETE FROM " . DB_PREFIX . "attribute_description WHERE attribute_id = '" . (int)$attribute_id . "'"); foreach ($data['attribute_description'] as $language_id => $value) { $this->db->query("INSERT INTO " . DB_PREFIX . "attribute_description SET attribute_id = '" . (int)$attribute_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'"); } } 5) в модели фильтра ocfilter.php меняем кусок if (!empty($data['copy_attribute'])) { .......... } на if (!empty($data['copy_attribute'])) { $this->db->query("UPDATE " . DB_PREFIX . "product_attribute SET text = TRIM(text)"); $last_option_id *= 3; $last_value_id *= 3; //ocfilter_option+ $this->db->query("INSERT IGNORE INTO " . DB_PREFIX . "ocfilter_option (option_id, status, type, sort_order) SELECT (attribute_id + '" . (int)$last_option_id . "'), '1' AS status, '" . $this->db->escape($data['copy_type']) . "' AS type, sort_order FROM " . DB_PREFIX . "attribute where oc_filter ='1'"); //ocfilter_option_description+ $this->db->query("INSERT IGNORE INTO " . DB_PREFIX . "ocfilter_option_description (option_id, language_id, name) SELECT (ad.attribute_id + '" . (int)$last_option_id . "'), ad.language_id, ad.name FROM " . DB_PREFIX . "attribute_description ad LEFT JOIN " . DB_PREFIX . "attribute att ON (att.attribute_id = ad.attribute_id) where att.oc_filter ='1'"); //ocfilter_option_value+ $this->db->query("INSERT IGNORE INTO " . DB_PREFIX . "ocfilter_option_value (option_id, value_id) SELECT (pa.attribute_id + '" . (int)$last_option_id . "'), CRC32(CONCAT(pa.attribute_id, CONCAT(UCASE(LEFT(TRIM(pa.text), 1)), LCASE(SUBSTRING(TRIM(pa.text), 2))))) FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute att ON (att.attribute_id = pa.attribute_id) WHERE att.oc_filter ='1' and pa.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY pa.attribute_id, CONCAT(UCASE(LEFT(TRIM(pa.text), 1)), LCASE(SUBSTRING(TRIM(pa.text), 2)))"); //ocfilter_option_value_description+ $this->db->query("INSERT IGNORE INTO " . DB_PREFIX . "ocfilter_option_value_description (option_id, value_id, language_id, name) SELECT (pa.attribute_id + '" . (int)$last_option_id . "'), CRC32(CONCAT(pa.attribute_id, CONCAT(UCASE(LEFT(TRIM(pa.text), 1)), LCASE(SUBSTRING(TRIM(pa.text), 2))))), pa.language_id, TRIM(pa.text) FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute att ON (att.attribute_id = pa.attribute_id) WHERE att.oc_filter ='1' and pa.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY pa.attribute_id, CONCAT(UCASE(LEFT(TRIM(pa.text), 1)), LCASE(SUBSTRING(TRIM(pa.text), 2)))"); $this->load->model('localisation/language'); $languages = $this->model_localisation_language->getLanguages(); //ocfilter_option_value_description+ foreach ($languages as $language) { if ($language['language_id'] != $this->config->get('config_language_id')) { $this->db->query("INSERT IGNORE INTO " . DB_PREFIX . "ocfilter_option_value_description (option_id, value_id, language_id, name) SELECT (pa.attribute_id + '" . (int)$last_option_id . "'), (SELECT CRC32(CONCAT(pa2.attribute_id, CONCAT(UCASE(LEFT(TRIM(pa2.text), 1)), LCASE(SUBSTRING(TRIM(pa2.text), 2))))) FROM " . DB_PREFIX . "product_attribute pa2 WHERE pa2.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa2.product_id = pa.product_id AND pa2.attribute_id = pa.attribute_id LIMIT 1 ) AS value_id, '" . (int)$language['language_id'] . "', CONCAT(UCASE(LEFT(TRIM(pa.text), 1)), LCASE(SUBSTRING(TRIM(pa.text), 2))) FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute att ON (att.attribute_id = pa.attribute_id) WHERE att.oc_filter ='1' and pa.language_id = '" . (int)$language['language_id'] . "' GROUP BY pa.attribute_id, CONCAT(UCASE(LEFT(TRIM(pa.text), 1)), LCASE(SUBSTRING(TRIM(pa.text), 2)))"); } } //ocfilter_option_value_to_product $this->db->query("INSERT IGNORE INTO " . DB_PREFIX . "ocfilter_option_value_to_product (product_id, option_id, value_id) SELECT pa.product_id, (pa.attribute_id + '" . (int)$last_option_id . "'), CRC32(CONCAT(pa.attribute_id, CONCAT(UCASE(LEFT(TRIM(pa.text), 1)), LCASE(SUBSTRING(TRIM(pa.text), 2))))) AS value_id FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute att ON (att.attribute_id = pa.attribute_id) WHERE att.oc_filter ='1' and pa.language_id = '" . (int)$this->config->get('config_language_id') . "'"); // Separate if (!empty($data['ocfilter_attribute_separator'])) { $separator = (string)$data['ocfilter_attribute_separator']; $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "ocfilter_option_value_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' AND TRIM(name) LIKE '%" . $this->db->escape($separator) . "%'"); foreach ($query->rows as $result) { $values = explode($separator, $result['name']); foreach ($values as $value) { $value = $this->utf8_ucfirst(trim($value)); if (!$value) { continue; } $value_query = $this->db->query("SELECT value_id FROM " . DB_PREFIX . "ocfilter_option_value_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' AND option_id = '" . (int)$result['option_id'] . "' AND LCASE(TRIM(name)) = '" . $this->db->escape(utf8_strtolower($value)) . "'"); if ($value_query->num_rows) { $value_id = $value_query->row['value_id']; } else { $this->db->query("INSERT INTO " . DB_PREFIX . "ocfilter_option_value (option_id) VALUES ('" . (int)$result['option_id'] . "')"); $value_id = $this->db->getLastId(); $this->db->query("INSERT INTO " . DB_PREFIX . "ocfilter_option_value_description (option_id, value_id, language_id, name) VALUES ('" . (int)$result['option_id'] . "', '" . $this->db->escape($value_id) . "', '" . (int)$this->config->get('config_language_id') . "', '" . $this->db->escape($value) . "')"); } $this->db->query("INSERT INTO " . DB_PREFIX . "ocfilter_option_value_to_product (product_id, option_id, value_id) SELECT oov2p.product_id, '" . (int)$result['option_id'] . "', '" . $this->db->escape($value_id) . "' FROM " . DB_PREFIX . "ocfilter_option_value_to_product oov2p WHERE oov2p.option_id = '" . (int)$result['option_id'] . "' AND oov2p.value_id = '" . $this->db->escape($result['value_id']) . "'"); } if ($values) { $this->db->query("DELETE FROM `" . DB_PREFIX . "ocfilter_option_value` WHERE value_id = '" . $this->db->escape($result['value_id']) . "'"); $this->db->query("DELETE FROM `" . DB_PREFIX . "ocfilter_option_value_description` WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' AND value_id = '" . $this->db->escape($result['value_id']) . "'"); $this->db->query("DELETE FROM `" . DB_PREFIX . "ocfilter_option_value_to_product` WHERE option_id = '" . (int)$result['option_id'] . "' AND value_id = '" . $this->db->escape($result['value_id']) . "'"); } } } } 6) поставить нужные чеки в редактировании аттрибутов
Guest
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.