diff --git a/classes/Product.php b/classes/Product.php index e1668a59c..ffd025451 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3051,7 +3051,7 @@ class ProductCore extends ObjectModel return array(); if (!$res = Db::getInstance()->executeS(' - SELECT pa.id_product, a.color, a.id_attribute, pac.id_product_attribute + SELECT pa.id_product, a.color, pac.id_product_attribute FROM '._DB_PREFIX_.'product_attribute pa '.Shop::addSqlAssociation('product_attribute', 'pa').' JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_product_attribute = product_attribute_shop.id_product_attribute) @@ -3068,7 +3068,7 @@ class ProductCore extends ObjectModel if (Tools::isEmpty($row['color'])) continue; - $colors[(int)$row['id_product']][] = array('id_product_attribute' => (int)$row['id_product_attribute'], 'color' => $row['color']); + $colors[(int)$row['id_product']][] = array('id_product_attribute' => (int)$row['id_product_attribute'], 'color' => $row['color'], 'id_product' => $row['id_product']); } return $colors; @@ -5107,8 +5107,8 @@ class ProductCore extends ObjectModel foreach ($attributes as &$a) { foreach ($a as &$b) - $b = str_replace('-', '_', Tools::link_rewrite($b)); - $anchor .= '/'.$a['group'].'-'.$a['name']; + $b = str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($b)); + $anchor .= '/'.$a['group'].Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').$a['name']; } return $anchor; } diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index ed16d2b03..57e4b5f06 100644 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -1171,7 +1171,8 @@ class FrontControllerCore extends Controller if (isset($colors[$product['id_product']])) $tpl->assign(array( 'id_product' => $product['id_product'], - 'colors_list' => $colors[$product['id_product']] + 'colors_list' => $colors[$product['id_product']], + 'link' => Context::getContext()->link )); if (!in_array($product['id_product'], $products_need_cache) || isset($colors[$product['id_product']])) $product['color_list'] = $tpl->fetch(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product'])); diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php index 519013a9d..c23c0280e 100644 --- a/controllers/admin/AdminPPreferencesController.php +++ b/controllers/admin/AdminPPreferencesController.php @@ -181,6 +181,15 @@ class AdminPPreferencesControllerCore extends AdminController 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool' + ), + 'PS_ATTRIBUTE_ANCHOR_SEPARATOR' => array( + 'title' => $this->l('Separator of attribute anchor on the product links'), + 'type' => 'select', + 'list' => array( + array('id' => '-', 'name' => '-'), + array('id' => ',', 'name' => ','), + ), + 'identifier' => 'id' ) ) ), diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index ed2454ab6..c082654f9 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -515,10 +515,14 @@ class ProductControllerCore extends FrontController if (is_array($attributes_combinations) && count($attributes_combinations)) foreach ($attributes_combinations as &$ac) foreach ($ac as &$val) - $val = str_replace('-', '_', Tools::link_rewrite(str_replace(array(',', '.'), '-', $val))); + $val = str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite(str_replace(array(',', '.'), '-', $val))); else $attributes_combinations = array(); - $this->context->smarty->assign('attributesCombinations', $attributes_combinations); + $this->context->smarty->assign(array( + 'attributesCombinations' => $attributes_combinations, + 'attribute_anchor_separator' => Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR') + ) + ); } /** diff --git a/install-dev/data/xml/configuration.xml b/install-dev/data/xml/configuration.xml index 816b5647a..d7dc6f3b1 100644 --- a/install-dev/data/xml/configuration.xml +++ b/install-dev/data/xml/configuration.xml @@ -778,5 +778,8 @@ Country 0 + + - + diff --git a/install-dev/upgrade/sql/1.6.0.1.sql b/install-dev/upgrade/sql/1.6.0.1.sql index fec326595..f870067b3 100644 --- a/install-dev/upgrade/sql/1.6.0.1.sql +++ b/install-dev/upgrade/sql/1.6.0.1.sql @@ -29,3 +29,5 @@ CREATE TABLE `PREFIX_configuration_kpi_lang` ( ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; /* PHP:ps1600_add_missing_index(); */; + +UPDATE `PREFIX_configuration` SET `value`='-' WHERE `name`='PS_ATTRIBUTE_ANCHOR_SEPARATOR'; \ No newline at end of file diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index 03efc8d51..71fe8c0d8 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -419,7 +419,7 @@ class BlockLayered extends Module foreach ($attribute as $param) { $selected_filters = array(); - $link = '/'.str_replace('-', '_', Tools::link_rewrite($param['name'])).'-'.str_replace('-', '_', Tools::link_rewrite($param['value'])); + $link = '/'.str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($param['name'])).Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($param['value'])); $selected_filters[$param['type']] = array(); if (!isset($param['id_id_value'])) $param['id_id_value'] = $param['id_value']; @@ -2103,7 +2103,7 @@ class BlockLayered extends Module { foreach ($url_attributes as $url_attribute) { - $url_parameters = explode('-', $url_attribute); + $url_parameters = explode(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), $url_attribute); $attribute_name = array_shift($url_parameters); if ($attribute_name == 'page') $this->page = (int)$url_parameters[0]; @@ -2113,7 +2113,7 @@ class BlockLayered extends Module { foreach ($url_parameters as $url_parameter) { - $data = Db::getInstance()->getValue('SELECT data FROM `'._DB_PREFIX_.'layered_friendly_url` WHERE `url_key` = \''.md5('/'.$attribute_name.'-'.$url_parameter).'\''); + $data = Db::getInstance()->getValue('SELECT data FROM `'._DB_PREFIX_.'layered_friendly_url` WHERE `url_key` = \''.md5('/'.$attribute_name.Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').$url_parameter).'\''); if ($data) foreach (Tools::unSerialize($data) as $key_params => $params) { @@ -3029,7 +3029,7 @@ class BlockLayered extends Module { $value_name = !empty($value['url_name']) ? $value['url_name'] : $value['name']; $value_meta = !empty($value['meta_title']) ? $value['meta_title'] : $value['name']; - $param_group_selected .= '-'.str_replace('-', '_', Tools::link_rewrite($value_name)); + $param_group_selected .= Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($value_name)); $param_group_selected_array[Tools::link_rewrite($filter_name)][] = Tools::link_rewrite($value_name); if (!isset($title_values[$filter_name])) @@ -3044,12 +3044,12 @@ class BlockLayered extends Module } if (!empty($param_group_selected)) { - $param_selected .= '/'.str_replace('-', '_', Tools::link_rewrite($filter_name)).$param_group_selected; + $param_selected .= '/'.str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($filter_name)).$param_group_selected; $option_checked_array[Tools::link_rewrite($filter_name)] = $param_group_selected; } // select only attribute and group attribute to display an unique product combination link if (!empty($param_group_selected) && $type_filter['type'] == 'id_attribute_group') - $param_product_url .= '/'.str_replace('-', '_', Tools::link_rewrite($filter_name)).$param_group_selected; + $param_product_url .= '/'.str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($filter_name)).$param_group_selected; } @@ -3089,23 +3089,23 @@ class BlockLayered extends Module // Update parameter filter checked before if (array_key_exists(Tools::link_rewrite($filter_name), $option_checked_array)) { - $option_checked_clone_array[Tools::link_rewrite($filter_name)] = $option_checked_clone_array[Tools::link_rewrite($filter_name)].'-'.str_replace('-', '_', Tools::link_rewrite($value_name)); + $option_checked_clone_array[Tools::link_rewrite($filter_name)] = $option_checked_clone_array[Tools::link_rewrite($filter_name)].Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($value_name)); $nofollow = true; } else - $option_checked_clone_array[Tools::link_rewrite($filter_name)] = '-'.str_replace('-', '_', Tools::link_rewrite($value_name)); + $option_checked_clone_array[Tools::link_rewrite($filter_name)] = Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($value_name)); } else { // Remove selected parameters - $option_checked_clone_array[Tools::link_rewrite($filter_name)] = str_replace('-'.str_replace('-', '_', Tools::link_rewrite($value_name)), '', $option_checked_clone_array[Tools::link_rewrite($filter_name)]); + $option_checked_clone_array[Tools::link_rewrite($filter_name)] = str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($value_name)), '', $option_checked_clone_array[Tools::link_rewrite($filter_name)]); if (empty($option_checked_clone_array[Tools::link_rewrite($filter_name)])) unset($option_checked_clone_array[Tools::link_rewrite($filter_name)]); } $parameters = ''; ksort($option_checked_clone_array); // Order parameters foreach ($option_checked_clone_array as $key_group => $value_group) - $parameters .= '/'.str_replace('-', '_', $key_group).$value_group; + $parameters .= '/'.str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', $key_group).$value_group; // Check if there is an non indexable attribute or feature in the url foreach ($non_indexable as $value) diff --git a/themes/default/js/product.js b/themes/default/js/product.js index 8e959b9ae..2cff98d95 100644 --- a/themes/default/js/product.js +++ b/themes/default/js/product.js @@ -659,7 +659,7 @@ function getProductAttribute() for (var i in attributesCombinations) for (var a in tab_attributes) if (attributesCombinations[i]['id_attribute'] === tab_attributes[a]) - request += '/'+attributesCombinations[i]['group'] + '-' + attributesCombinations[i]['attribute']; + request += '/'+attributesCombinations[i]['group'] + attribute_anchor_separator + attributesCombinations[i]['attribute']; request = request.replace(request.substring(0, 1), '#/'); url = window.location + ''; @@ -694,7 +694,7 @@ function checkUrl() if (tabParams[0] == '') tabParams.shift(); for (var i in tabParams) - tabValues.push(tabParams[i].split('-')); + tabValues.push(tabParams[i].split(attribute_anchor_separator)); product_id = $('#product_page_product_id').val(); // fill html with values $('.color_pick').removeClass('selected'); diff --git a/themes/default/product-list-colors.tpl b/themes/default/product-list-colors.tpl index 5bfa034e2..a4d4f2205 100644 --- a/themes/default/product-list-colors.tpl +++ b/themes/default/product-list-colors.tpl @@ -23,9 +23,8 @@ * International Registered Trademark & Property of PrestaShop SA *} - diff --git a/themes/default/product.tpl b/themes/default/product.tpl index dfd32a4ae..b208166d0 100644 --- a/themes/default/product.tpl +++ b/themes/default/product.tpl @@ -49,6 +49,7 @@ var availableNowValue = '{$product->available_now|escape:'quotes':'UTF-8'}'; var availableLaterValue = '{$product->available_later|escape:'quotes':'UTF-8'}'; var productPriceTaxExcluded = {$product->getPriceWithoutReduct(true)|default:'null'} - {$product->ecotax}; var productBasePriceTaxExcluded = {$product->base_price} - {$product->ecotax}; +var attribute_anchor_separator = '{$attribute_anchor_separator|addslashes}'; var reduction_percent = {if $product->specificPrice AND $product->specificPrice.reduction AND $product->specificPrice.reduction_type == 'percentage'}{$product->specificPrice.reduction*100}{else}0{/if}; var reduction_price = {if $product->specificPrice AND $product->specificPrice.reduction AND $product->specificPrice.reduction_type == 'amount'}{$product->specificPrice.reduction|floatval}{else}0{/if};