Tout d'abord, je ne suis pas un programmeur, mais j'essaie de faire quelques mods dans mon e-shop fonctionnant sur opencart alors s'il vous plaît soyez patient avec moi :) J'ai lu des tonnes de forums sur les fonctions et les personnages changeants, mais je n'ai toujours pas trouvé la réponse simple qui m'aiderait à le faire. J'essaie de faire en sorte que tous les caractères soient en minuscules, les espaces remplacés par "-" et les accents remplacés par des caractères similaires.Comment REMPLACER les caractères d'accent dans Opencart pour le référencement url
Je pense que c'est le morceau de code dans Opencart je dois modifier, mais la question est de savoir comment:
if ($data['keyword']) { $this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'product_id=" . (int)$product_id . "', keyword = '" . $this->db->escape($data['keyword']) . "'"); }
si je change ceci: . $this->db->escape($data['keyword']) . "'")
à ceci: . $this->db->escape(strtolower(trim(preg_replace('/[^a-zA-Z0-9]+/', '-', $data['keyword']), '-')))
il fait la partie du travail, mais le prochain défi est d'obtenir tous les accents remplacés. J'ai fait un function.php avec ce code:
<?php \t
function accents($string)
{
\t //search
$dia = array('á', 'ä', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ĺ', 'ň', 'ó', 'ô', 'ŕ', 'ř', 'š', 'ť', 'ú', 'ů', 'ý', 'ž', 'Á', 'Ä', 'Č', 'Ď', 'É', 'Í', 'Ľ', 'Ĺ', 'Ň', 'Ó', 'Ô', 'Ř', 'Š', 'Ť', 'Ú', 'Ý', 'Ž', ' ','\'','%');
//replace
$nodia = array('a', 'a', 'c', 'd', 'e', 'e', 'i', 'l', 'l', 'n', 'o', 'o', 'r', 'r', 's', 't', 'u', 'u', 'y', 'z', 'A', 'A', 'C', 'D', 'E', 'I', 'L', 'L', 'N', 'O', 'O', 'R', 'S', 'T', 'U', 'Y', 'Z', '-','','');
return str_replace($dia, $nodia, $string);
}
?>
Cela devrait faire la part de l'affaire, mais je ne sais pas comment le faire fonctionner avec l'autre partie de la code.
Ceci est la partie de product.php. Le fichier où il doit être aplicated ..
This is the part of product.php Would you please advice me what exactly and where to put?
<?php
class ModelCatalogProduct extends Model {
\t public function addProduct($data) {
\t \t $this->event->trigger('pre.admin.product.add', $data);
\t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_added = NOW()");
\t \t $product_id = $this->db->getLastId();
\t \t if (isset($data['image'])) {
\t \t \t $this->db->query("UPDATE " . DB_PREFIX . "product SET image = '" . $this->db->escape($data['image']) . "' WHERE product_id = '" . (int)$product_id . "'");
\t \t }
\t \t foreach ($data['product_description'] as $language_id => $value) {
\t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', tag = '" . $this->db->escape($value['tag']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
\t \t }
\t \t if (isset($data['product_store'])) {
\t \t \t foreach ($data['product_store'] as $store_id) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_store SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "'");
\t \t \t }
\t \t }
\t \t if (isset($data['product_attribute'])) {
\t \t \t foreach ($data['product_attribute'] as $product_attribute) {
\t \t \t \t if ($product_attribute['attribute_id']) {
\t \t \t \t \t foreach ($product_attribute['product_attribute_description'] as $language_id => $product_attribute_description) {
\t \t \t \t \t \t $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']) . "'");
\t \t \t \t \t }
\t \t \t \t }
\t \t \t }
\t \t }
\t \t if (isset($data['product_option'])) {
\t \t \t foreach ($data['product_option'] as $product_option) {
\t \t \t \t if ($product_option['type'] == 'select' || $product_option['type'] == 'radio' || $product_option['type'] == 'checkbox' || $product_option['type'] == 'image') {
\t \t \t \t \t if (isset($product_option['product_option_value'])) {
\t \t \t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', required = '" . (int)$product_option['required'] . "'");
\t \t \t \t \t \t $product_option_id = $this->db->getLastId();
\t \t \t \t \t \t foreach ($product_option['product_option_value'] as $product_option_value) {
\t \t \t \t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', option_value_id = '" . (int)$product_option_value['option_value_id'] . "', quantity = '" . (int)$product_option_value['quantity'] . "', subtract = '" . (int)$product_option_value['subtract'] . "', price = '" . (float)$product_option_value['price'] . "', price_prefix = '" . $this->db->escape($product_option_value['price_prefix']) . "', points = '" . (int)$product_option_value['points'] . "', points_prefix = '" . $this->db->escape($product_option_value['points_prefix']) . "', weight = '" . (float)$product_option_value['weight'] . "', weight_prefix = '" . $this->db->escape($product_option_value['weight_prefix']) . "'");
\t \t \t \t \t \t }
\t \t \t \t \t }
\t \t \t \t } else {
\t \t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', value = '" . $this->db->escape($product_option['value']) . "', required = '" . (int)$product_option['required'] . "'");
\t \t \t \t }
\t \t \t }
\t \t }
\t \t if (isset($data['product_discount'])) {
\t \t \t foreach ($data['product_discount'] as $product_discount) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_discount SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$product_discount['customer_group_id'] . "', quantity = '" . (int)$product_discount['quantity'] . "', priority = '" . (int)$product_discount['priority'] . "', price = '" . (float)$product_discount['price'] . "', date_start = '" . $this->db->escape($product_discount['date_start']) . "', date_end = '" . $this->db->escape($product_discount['date_end']) . "'");
\t \t \t }
\t \t }
\t \t if (isset($data['product_special'])) {
\t \t \t foreach ($data['product_special'] as $product_special) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_special SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$product_special['customer_group_id'] . "', priority = '" . (int)$product_special['priority'] . "', price = '" . (float)$product_special['price'] . "', date_start = '" . $this->db->escape($product_special['date_start']) . "', date_end = '" . $this->db->escape($product_special['date_end']) . "'");
\t \t \t }
\t \t }
\t \t if (isset($data['product_image'])) {
\t \t \t foreach ($data['product_image'] as $product_image) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($product_image['image']) . "', sort_order = '" . (int)$product_image['sort_order'] . "'");
\t \t \t }
\t \t }
\t \t if (isset($data['product_download'])) {
\t \t \t foreach ($data['product_download'] as $download_id) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_download SET product_id = '" . (int)$product_id . "', download_id = '" . (int)$download_id . "'");
\t \t \t }
\t \t }
\t \t if (isset($data['product_category'])) {
\t \t \t foreach ($data['product_category'] as $category_id) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_category SET product_id = '" . (int)$product_id . "', category_id = '" . (int)$category_id . "'");
\t \t \t }
\t \t }
\t \t if (isset($data['product_filter'])) {
\t \t \t foreach ($data['product_filter'] as $filter_id) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_filter SET product_id = '" . (int)$product_id . "', filter_id = '" . (int)$filter_id . "'");
\t \t \t }
\t \t }
\t \t if (isset($data['product_related'])) {
\t \t \t foreach ($data['product_related'] as $related_id) {
\t \t \t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "' AND related_id = '" . (int)$related_id . "'");
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$product_id . "', related_id = '" . (int)$related_id . "'");
\t \t \t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$related_id . "' AND related_id = '" . (int)$product_id . "'");
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$related_id . "', related_id = '" . (int)$product_id . "'");
\t \t \t }
\t \t }
\t \t if (isset($data['product_reward'])) {
\t \t \t foreach ($data['product_reward'] as $customer_group_id => $product_reward) {
\t \t \t \t if ((int)$product_reward['points'] > 0) {
\t \t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_reward SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$customer_group_id . "', points = '" . (int)$product_reward['points'] . "'");
\t \t \t \t }
\t \t \t }
\t \t }
\t \t if (isset($data['product_layout'])) {
\t \t \t foreach ($data['product_layout'] as $store_id => $layout_id) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_layout SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
\t \t \t }
\t \t }
\t \t if (isset($data['keyword'])) {
\t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'product_id=" . (int)$product_id . "', keyword = '" . $this->db->escape($this->accents($data['keyword'])) . "'");
\t \t }
\t \t if (isset($data['product_recurrings'])) {
\t \t \t foreach ($data['product_recurrings'] as $recurring) {
\t \t \t \t $this->db->query("INSERT INTO `" . DB_PREFIX . "product_recurring` SET `product_id` = " . (int)$product_id . ", customer_group_id = " . (int)$recurring['customer_group_id'] . ", `recurring_id` = " . (int)$recurring['recurring_id']);
\t \t \t }
\t \t }
\t \t $this->cache->delete('product');
\t \t $this->event->trigger('post.admin.product.add', $product_id);
\t \t return $product_id;
\t }
\t public function editProduct($product_id, $data) {
\t \t $this->event->trigger('pre.admin.product.edit', $data);
\t \t $this->db->query("UPDATE " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_modified = NOW() WHERE product_id = '" . (int)$product_id . "'");
\t \t if (isset($data['image'])) {
\t \t \t $this->db->query("UPDATE " . DB_PREFIX . "product SET image = '" . $this->db->escape($data['image']) . "' WHERE product_id = '" . (int)$product_id . "'");
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "'");
\t \t foreach ($data['product_description'] as $language_id => $value) {
\t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', tag = '" . $this->db->escape($value['tag']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "'");
\t \t if (isset($data['product_store'])) {
\t \t \t foreach ($data['product_store'] as $store_id) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_store SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "'");
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "'");
\t \t if (!empty($data['product_attribute'])) {
\t \t \t foreach ($data['product_attribute'] as $product_attribute) {
\t \t \t \t if ($product_attribute['attribute_id']) {
\t \t \t \t \t foreach ($product_attribute['product_attribute_description'] as $language_id => $product_attribute_description) {
\t \t \t \t \t \t $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']) . "'");
\t \t \t \t \t }
\t \t \t \t }
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int)$product_id . "'");
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value WHERE product_id = '" . (int)$product_id . "'");
\t \t if (isset($data['product_option'])) {
\t \t \t foreach ($data['product_option'] as $product_option) {
\t \t \t \t if ($product_option['type'] == 'select' || $product_option['type'] == 'radio' || $product_option['type'] == 'checkbox' || $product_option['type'] == 'image') {
\t \t \t \t \t if (isset($product_option['product_option_value'])) {
\t \t \t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_option_id = '" . (int)$product_option['product_option_id'] . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', required = '" . (int)$product_option['required'] . "'");
\t \t \t \t \t \t $product_option_id = $this->db->getLastId();
\t \t \t \t \t \t foreach ($product_option['product_option_value'] as $product_option_value) {
\t \t \t \t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET product_option_value_id = '" . (int)$product_option_value['product_option_value_id'] . "', product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', option_value_id = '" . (int)$product_option_value['option_value_id'] . "', quantity = '" . (int)$product_option_value['quantity'] . "', subtract = '" . (int)$product_option_value['subtract'] . "', price = '" . (float)$product_option_value['price'] . "', price_prefix = '" . $this->db->escape($product_option_value['price_prefix']) . "', points = '" . (int)$product_option_value['points'] . "', points_prefix = '" . $this->db->escape($product_option_value['points_prefix']) . "', weight = '" . (float)$product_option_value['weight'] . "', weight_prefix = '" . $this->db->escape($product_option_value['weight_prefix']) . "'");
\t \t \t \t \t \t }
\t \t \t \t \t }
\t \t \t \t } else {
\t \t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_option_id = '" . (int)$product_option['product_option_id'] . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', value = '" . $this->db->escape($product_option['value']) . "', required = '" . (int)$product_option['required'] . "'");
\t \t \t \t }
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");
\t \t if (isset($data['product_discount'])) {
\t \t \t foreach ($data['product_discount'] as $product_discount) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_discount SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$product_discount['customer_group_id'] . "', quantity = '" . (int)$product_discount['quantity'] . "', priority = '" . (int)$product_discount['priority'] . "', price = '" . (float)$product_discount['price'] . "', date_start = '" . $this->db->escape($product_discount['date_start']) . "', date_end = '" . $this->db->escape($product_discount['date_end']) . "'");
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "'");
\t \t if (isset($data['product_special'])) {
\t \t \t foreach ($data['product_special'] as $product_special) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_special SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$product_special['customer_group_id'] . "', priority = '" . (int)$product_special['priority'] . "', price = '" . (float)$product_special['price'] . "', date_start = '" . $this->db->escape($product_special['date_start']) . "', date_end = '" . $this->db->escape($product_special['date_end']) . "'");
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
\t \t if (isset($data['product_image'])) {
\t \t \t foreach ($data['product_image'] as $product_image) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($product_image['image']) . "', sort_order = '" . (int)$product_image['sort_order'] . "'");
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "'");
\t \t if (isset($data['product_download'])) {
\t \t \t foreach ($data['product_download'] as $download_id) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_download SET product_id = '" . (int)$product_id . "', download_id = '" . (int)$download_id . "'");
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
\t \t if (isset($data['product_category'])) {
\t \t \t foreach ($data['product_category'] as $category_id) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_category SET product_id = '" . (int)$product_id . "', category_id = '" . (int)$category_id . "'");
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_filter WHERE product_id = '" . (int)$product_id . "'");
\t \t if (isset($data['product_filter'])) {
\t \t \t foreach ($data['product_filter'] as $filter_id) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_filter SET product_id = '" . (int)$product_id . "', filter_id = '" . (int)$filter_id . "'");
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "'");
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE related_id = '" . (int)$product_id . "'");
\t \t if (isset($data['product_related'])) {
\t \t \t foreach ($data['product_related'] as $related_id) {
\t \t \t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "' AND related_id = '" . (int)$related_id . "'");
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$product_id . "', related_id = '" . (int)$related_id . "'");
\t \t \t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$related_id . "' AND related_id = '" . (int)$product_id . "'");
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$related_id . "', related_id = '" . (int)$product_id . "'");
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_reward WHERE product_id = '" . (int)$product_id . "'");
\t \t if (isset($data['product_reward'])) {
\t \t \t foreach ($data['product_reward'] as $customer_group_id => $value) {
\t \t \t \t if ((int)$value['points'] > 0) {
\t \t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_reward SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$customer_group_id . "', points = '" . (int)$value['points'] . "'");
\t \t \t \t }
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "'");
\t \t if (isset($data['product_layout'])) {
\t \t \t foreach ($data['product_layout'] as $store_id => $layout_id) {
\t \t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_layout SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
\t \t \t }
\t \t }
\t \t $this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query = 'product_id=" . (int)$product_id . "'");
\t \t if ($data['keyword']) {
\t \t \t $this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'product_id=" . (int)$product_id . "', keyword = '" . $this->db->escape($this->accents($data['keyword'])) . "'");
\t \t }
\t \t $this->db->query("DELETE FROM `" . DB_PREFIX . "product_recurring` WHERE product_id = " . (int)$product_id);
\t \t if (isset($data['product_recurring'])) {
\t \t \t foreach ($data['product_recurring'] as $product_recurring) {
\t \t \t \t $this->db->query("INSERT INTO `" . DB_PREFIX . "product_recurring` SET `product_id` = " . (int)$product_id . ", customer_group_id = " . (int)$product_recurring['customer_group_id'] . ", `recurring_id` = " . (int)$product_recurring['recurring_id']);
\t \t \t }
\t \t }
\t \t $this->cache->delete('product');
\t \t $this->event->trigger('post.admin.product.edit', $product_id);
\t }
\t public function copyProduct($product_id) {
\t \t $query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
\t \t if ($query->num_rows) {
\t \t \t $data = $query->row;
\t \t \t $data['sku'] = '';
\t \t \t $data['upc'] = '';
\t \t \t $data['viewed'] = '0';
\t \t \t $data['keyword'] = '';
\t \t \t $data['status'] = '0';
\t \t \t $data['product_attribute'] = $this->getProductAttributes($product_id);
\t \t \t $data['product_description'] = $this->getProductDescriptions($product_id);
\t \t \t $data['product_discount'] = $this->getProductDiscounts($product_id);
\t \t \t $data['product_filter'] = $this->getProductFilters($product_id);
\t \t \t $data['product_image'] = $this->getProductImages($product_id);
\t \t \t $data['product_option'] = $this->getProductOptions($product_id);
\t \t \t $data['product_related'] = $this->getProductRelated($product_id);
\t \t \t $data['product_reward'] = $this->getProductRewards($product_id);
\t \t \t $data['product_special'] = $this->getProductSpecials($product_id);
\t \t \t $data['product_category'] = $this->getProductCategories($product_id);
\t \t \t $data['product_download'] = $this->getProductDownloads($product_id);
\t \t \t $data['product_layout'] = $this->getProductLayouts($product_id);
\t \t \t $data['product_store'] = $this->getProductStores($product_id);
\t \t \t $data['product_recurrings'] = $this->getRecurrings($product_id);
\t \t \t $this->addProduct($data);
\t \t }
\t }
Salut Billy, merci beaucoup pour votre réponse. J'ai d'abord essayé l'option avec iconv, mais elle a remplacé les accents par "?" Maintenant, j'essaie d'utiliser les accents mais je fais quelque chose de mal. Je reçois erreur fatale: Appel à la méthode non définie ModelCatalogProduct :: accents() dans /home/public_html/web/admin/model/catalog/product.php à la ligne 270. Je ne suis pas sûr de savoir comment ajouter la fonction en tant que méthode de classe quelque part dans ce fichier modèle product.php – Magnettoo
J'ai démontré que dans le premier bloc. Ajoutez-le juste à la fin avant que le cours soit fermé.Si vous n'êtes pas sûr, jetez un œil à toutes les autres méthodes et à leur apparence. Vous avez juste besoin de l'ajouter de la même manière que toutes les autres méthodes - un peu comme une fonction normale, mais assurez-vous juste que c'est dans la classe '{' braces '}' – billynoah
Trié. Fonctionne comme un charme. Merci beaucoup Billy – Magnettoo