[*] FO : combination link from product page are now the same as the combination link from blocklayered
// Cart is now accepting the combination link
This commit is contained in:
@@ -381,8 +381,9 @@ class DispatcherCore
|
||||
* @param string $route_id Name the route
|
||||
* @param array $params
|
||||
* @param bool $use_routes If false, don't use to create this url
|
||||
* @param string $anchor Optional anchor to add at the end of this url
|
||||
*/
|
||||
public function createUrl($route_id, $params = array(), $use_routes = true)
|
||||
public function createUrl($route_id, $params = array(), $use_routes = true, $anchor = '')
|
||||
{
|
||||
if (!is_array($params))
|
||||
die('Dispatcher::createUrl() $params must be an array');
|
||||
@@ -390,7 +391,7 @@ class DispatcherCore
|
||||
if (!isset($this->routes[$route_id]))
|
||||
{
|
||||
$query = http_build_query($params);
|
||||
return ($route_id == 'index') ? 'index.php'.(($query) ? '?'.$query : '') : 'index.php?controller='.$route_id.(($query) ? '&'.$query : '');
|
||||
return ($route_id == 'index') ? 'index.php'.(($query) ? '?'.$query : '') : 'index.php?controller='.$route_id.(($query) ? '&'.$query : '').$anchor;
|
||||
}
|
||||
$route = $this->routes[$route_id];
|
||||
|
||||
@@ -427,7 +428,7 @@ class DispatcherCore
|
||||
else
|
||||
$url = 'index.php?controller='.$route['controller'].(($query_params) ? '&'.http_build_query($query_params) : '');
|
||||
|
||||
return $url;
|
||||
return $url.$anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,9 +68,10 @@ class LinkCore
|
||||
* @param string $ean13
|
||||
* @param int $id_lang
|
||||
* @param int $id_shop (since 1.5.0) ID shop need to be used when we generate a product link for a product in a cart
|
||||
* @param int $ipa ID product attribute
|
||||
* @return string
|
||||
*/
|
||||
public function getProductLink($product, $alias = null, $category = null, $ean13 = null, $id_lang = null, $id_shop = null)
|
||||
public function getProductLink($product, $alias = null, $category = null, $ean13 = null, $id_lang = null, $id_shop = null, $ipa = 0)
|
||||
{
|
||||
$dispatcher = Dispatcher::getInstance();
|
||||
$url = _PS_BASE_URL_.__PS_BASE_URI__;
|
||||
@@ -107,7 +108,12 @@ class LinkCore
|
||||
if ($dispatcher->hasKeyword('product_rule', 'tags'))
|
||||
$params['tags'] = Tools::str2url($product->getTags($id_lang));
|
||||
|
||||
return $url.$dispatcher->createUrl('product_rule', $params, $this->allow);
|
||||
if ($ipa)
|
||||
$anchor = $product->getAnchor($ipa);
|
||||
else
|
||||
$anchor = '';
|
||||
|
||||
return $url.$dispatcher->createUrl('product_rule', $params, $this->allow, $anchor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3641,44 +3641,224 @@ class ProductCore extends ObjectModel
|
||||
|
||||
/**
|
||||
* Get label by lang and value by lang too
|
||||
* @todo Remove existing module condition
|
||||
* @param int $id_product
|
||||
* @param int $product_attribute_id
|
||||
* @return array
|
||||
*/
|
||||
public static function getAttributesParams($id_product, $id_product_attribute)
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT al.`name`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (pac.`id_attribute` = a.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE pa.`id_product` = '.(int)$id_product.'
|
||||
AND pac.`id_product_attribute` = '.(int)$id_product_attribute.'
|
||||
AND agl.`id_lang` = '.(int)Context::getContext()->language->id);
|
||||
// if blocklayered module is installed we check if user has set custom attribute name
|
||||
if (Module::isInstalled('blocklayered'))
|
||||
{
|
||||
$nb_custom_values = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT la.`id_attribute`, la.`url_name` as `name`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (a.`id_attribute` = pac.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'layered_indexable_attribute_lang_value` la
|
||||
ON (la.`id_attribute` = a.`id_attribute` AND la.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE la.`url_name` IS NOT NULL
|
||||
AND pa.`id_product` = '.(int)$id_product);
|
||||
|
||||
if (!empty($nb_custom_values))
|
||||
{
|
||||
$tab_id_attribute = array();
|
||||
foreach ($nb_custom_values as $attribute)
|
||||
{
|
||||
$tab_id_attribute[] = $attribute['id_attribute'];
|
||||
|
||||
$group = Db::getInstance()->executeS('
|
||||
SELECT g.`id_attribute_group`, g.`url_name` as `group`
|
||||
FROM `'._DB_PREFIX_.'layered_indexable_attribute_group_lang_value` g
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute` a
|
||||
ON (a.`id_attribute_group` = g.`id_attribute_group`)
|
||||
WHERE a.`id_attribute` = '.(int)$attribute['id_attribute'].'
|
||||
AND g.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND g.`url_name` IS NOT NULL');
|
||||
if (empty($group))
|
||||
{
|
||||
$group = Db::getInstance()->executeS('
|
||||
SELECT g.`id_attribute_group`, g.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute_group_lang` g
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute` a
|
||||
ON (a.`id_attribute_group` = g.`id_attribute_group`)
|
||||
WHERE a.`id_attribute` = '.(int)$attribute['id_attribute'].'
|
||||
AND g.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND g.`name` IS NOT NULL');
|
||||
}
|
||||
$result[] = array_merge($attribute, $group[0]);
|
||||
}
|
||||
$values_not_custom = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT a.`id_attribute_group`, al.`name`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (a.`id_attribute` = pac.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
WHERE pa.`id_product` = '.(int)$id_product.'
|
||||
AND a.`id_attribute` NOT IN('.implode(', ', $tab_id_attribute).')');
|
||||
$result = array_merge($values_not_custom, $result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT al.`name`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (pac.`id_attribute` = a.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE pa.`id_product` = '.(int)$id_product.'
|
||||
AND pac.`id_product_attribute` = '.(int)$id_product_attribute.'
|
||||
AND agl.`id_lang` = '.(int)Context::getContext()->language->id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT al.`name`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (pac.`id_attribute` = a.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE pa.`id_product` = '.(int)$id_product.'
|
||||
AND pac.`id_product_attribute` = '.(int)$id_product_attribute.'
|
||||
AND agl.`id_lang` = '.(int)Context::getContext()->language->id);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Remove existing module condition
|
||||
* @param int $id_product
|
||||
*/
|
||||
public static function getAttributesInformationsByProduct($id_product)
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT DISTINCT a.`id_attribute`, a.`id_attribute_group`, al.`name` as `attribute`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (a.`id_attribute` = pac.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
WHERE pa.`id_product` = '.(int)$id_product);
|
||||
// if blocklayered module is installed we check if user has set custom attribute name
|
||||
if (Module::isInstalled('blocklayered'))
|
||||
{
|
||||
$nb_custom_values = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT la.`id_attribute`, la.`url_name` as `attribute`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (a.`id_attribute` = pac.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'layered_indexable_attribute_lang_value` la
|
||||
ON (la.`id_attribute` = a.`id_attribute` AND la.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE la.`url_name` IS NOT NULL
|
||||
AND pa.`id_product` = '.(int)$id_product);
|
||||
|
||||
if (!empty($nb_custom_values))
|
||||
{
|
||||
$tab_id_attribute = array();
|
||||
foreach ($nb_custom_values as $attribute)
|
||||
{
|
||||
$tab_id_attribute[] = $attribute['id_attribute'];
|
||||
|
||||
$group = Db::getInstance()->executeS('
|
||||
SELECT g.`id_attribute_group`, g.`url_name` as `group`
|
||||
FROM `'._DB_PREFIX_.'layered_indexable_attribute_group_lang_value` g
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute` a
|
||||
ON (a.`id_attribute_group` = g.`id_attribute_group`)
|
||||
WHERE a.`id_attribute` = '.(int)$attribute['id_attribute'].'
|
||||
AND g.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND g.`url_name` IS NOT NULL');
|
||||
if (empty($group))
|
||||
{
|
||||
$group = Db::getInstance()->executeS('
|
||||
SELECT g.`id_attribute_group`, g.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute_group_lang` g
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute` a
|
||||
ON (a.`id_attribute_group` = g.`id_attribute_group`)
|
||||
WHERE a.`id_attribute` = '.(int)$attribute['id_attribute'].'
|
||||
AND g.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND g.`name` IS NOT NULL');
|
||||
}
|
||||
$result[] = array_merge($attribute, $group[0]);
|
||||
}
|
||||
$values_not_custom = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT a.`id_attribute`, a.`id_attribute_group`, a.`id_attribute_group`, al.`name` as `attribute`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (a.`id_attribute` = pac.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
WHERE pa.`id_product` = '.(int)$id_product.'
|
||||
AND a.`id_attribute` NOT IN('.implode(', ', $tab_id_attribute).')');
|
||||
$result = array_merge($values_not_custom, $result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT a.`id_attribute`, a.`id_attribute_group`, al.`name` as `attribute`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (a.`id_attribute` = pac.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
WHERE pa.`id_product` = '.(int)$id_product);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT a.`id_attribute`, a.`id_attribute_group`, al.`name` as `attribute`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (a.`id_attribute` = pac.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
WHERE pa.`id_product` = '.(int)$id_product);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the combination url anchor of the product
|
||||
*
|
||||
* @param integer $id_product_attribute
|
||||
* @return string
|
||||
*/
|
||||
public function getAnchor($id_product_attribute)
|
||||
{
|
||||
$attributes = Product::getAttributesParams($this->id, $id_product_attribute);
|
||||
$anchor = '#';
|
||||
foreach ($attributes as &$a)
|
||||
{
|
||||
foreach ($a as &$b)
|
||||
$b = str_replace('-', '_', Tools::link_rewrite($b));
|
||||
$anchor .= '/'.$a['group'].'-'.$a['name'];
|
||||
}
|
||||
return $anchor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -375,7 +375,8 @@ class ProductControllerCore extends FrontController
|
||||
{
|
||||
$attributes_combinations = Product::getAttributesInformationsByProduct($this->product->id);
|
||||
foreach ($attributes_combinations as &$ac)
|
||||
$ac = array_map('Tools::str2url', $ac);
|
||||
foreach ($ac as &$val)
|
||||
$val = str_replace('-', '_', Tools::link_rewrite($val));
|
||||
$this->context->smarty->assign('attributesCombinations', $attributes_combinations);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
{assign var='productAttributeId' value=$product.id_product_attribute}
|
||||
{ldelim}
|
||||
"id": {$product.id_product},
|
||||
"link": "{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, null, null, $product.id_shop)|addslashes|replace:'\\\'':'\''}",
|
||||
"link": "{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|addslashes|replace:'\\\'':'\''}",
|
||||
"quantity": {$product.cart_quantity},
|
||||
"priceByLine": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}",
|
||||
"name": "{$product.name|html_entity_decode:2:'UTF-8'|escape|truncate:15:'...':true}",
|
||||
|
||||
@@ -62,14 +62,14 @@ var removingLinkText = '{l s='remove this product from my cart' mod='blockcart'
|
||||
{assign var='productAttributeId' value=$product.id_product_attribute}
|
||||
<dt id="cart_block_product_{$product.id_product}{if $product.id_product_attribute}_{$product.id_product_attribute}{/if}" class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}">
|
||||
<span class="quantity-formated"><span class="quantity">{$product.cart_quantity}</span>x</span>
|
||||
<a class="cart_block_product_name" href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, null, null, $product.id_shop)}" title="{$product.name|escape:html:'UTF-8'}">
|
||||
<a class="cart_block_product_name" href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)}" title="{$product.name|escape:html:'UTF-8'}">
|
||||
{$product.name|truncate:13:'...'|escape:html:'UTF-8'}</a>
|
||||
<span class="remove_link">{if !isset($blockcart_customizedDatas.$productId.$productAttributeId)}<a rel="nofollow" class="ajax_cart_block_remove_link" href="{$link->getPageLink('cart', true, NULL, "delete&id_product={$product.id_product}&ipa={$product.id_product_attribute}&token={$static_token}")}" title="{l s='remove this product from my cart' mod='blockcart'}"> </a>{/if}</span>
|
||||
<span class="price">{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total`"}{else}{displayWtPrice p="`$product.total_wt`"}{/if}</span>
|
||||
</dt>
|
||||
{if isset($product.attributes_small)}
|
||||
<dd id="cart_block_combination_of_{$product.id_product}{if $product.id_product_attribute}_{$product.id_product_attribute}{/if}" class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}">
|
||||
<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, null, null, $product.id_shop)}" title="{l s='Product detail'}">{$product.attributes_small}</a>
|
||||
<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)}" title="{l s='Product detail'}">{$product.attributes_small}</a>
|
||||
{/if}
|
||||
|
||||
<!-- Customizable datas -->
|
||||
|
||||
@@ -88,6 +88,7 @@ function initLayered()
|
||||
{
|
||||
initSliders();
|
||||
initLocationChange();
|
||||
updateProductUrl();
|
||||
if (window.location.href.split('#').length == 2 && window.location.href.split('#')[1] != '')
|
||||
{
|
||||
var params = window.location.href.split('#')[1];
|
||||
@@ -318,6 +319,7 @@ function reloadContent(params_plus)
|
||||
|
||||
if(slideUp)
|
||||
$.scrollTo('#product_list', 400);
|
||||
updateProductUrl();
|
||||
}
|
||||
});
|
||||
ajaxQueries.push(ajaxQuery);
|
||||
@@ -352,3 +354,11 @@ function getUrlParams()
|
||||
params = '#'+window.location.href.split('#')[1];
|
||||
return params;
|
||||
}
|
||||
|
||||
function updateProductUrl()
|
||||
{
|
||||
// Adding the filters to URL product
|
||||
$('ul#product_list li.ajax_block_product .product_img_link').attr('href', $('ul#product_list li.ajax_block_product .product_img_link').attr('href') + param_product_url);
|
||||
$('ul#product_list li.ajax_block_product h3 a').attr('href', $('ul#product_list li.ajax_block_product h3 a').attr('href') + param_product_url);
|
||||
$('ul#product_list li.ajax_block_product .product_desc a').attr('href', $('ul#product_list li.ajax_block_product .product_desc a').attr('href') + param_product_url);
|
||||
}
|
||||
|
||||
@@ -2385,6 +2385,7 @@ class BlockLayered extends Module
|
||||
|
||||
//generate SEO link
|
||||
$paramSelected = '';
|
||||
$param_product_url = '';
|
||||
$optionCheckedArray = array();
|
||||
$paramGroupSelectedArray = array();
|
||||
$titleValues = array();
|
||||
@@ -2419,6 +2420,9 @@ class BlockLayered extends Module
|
||||
$paramSelected .= '/'.str_replace('-', '_', Tools::link_rewrite($filterName)).$paramGroupSelected;
|
||||
$optionCheckedArray[Tools::link_rewrite($filterName)] = $paramGroupSelected;
|
||||
}
|
||||
// select only attribute and group attribute to display an unique product combination link
|
||||
if (!empty($paramGroupSelected) && $typeFilter['type'] == 'id_attribute_group')
|
||||
$param_product_url .= '/'.str_replace('-', '_', Tools::link_rewrite($filterName)).$paramGroupSelected;
|
||||
}
|
||||
|
||||
$blackList = array('weight','price');
|
||||
@@ -2460,7 +2464,6 @@ class BlockLayered extends Module
|
||||
$parameters = '';
|
||||
foreach ($optionCheckedCloneArray as $keyGroup => $valueGroup)
|
||||
$parameters .= '/'.str_replace('-', '_', $keyGroup).$valueGroup;
|
||||
|
||||
// Check if there is an non indexable attribute or feature in the url
|
||||
foreach ($nonIndexable as $value)
|
||||
if (strpos($parameters, '/'.$value) !== false)
|
||||
@@ -2489,7 +2492,7 @@ class BlockLayered extends Module
|
||||
|
||||
$cache = array('layered_show_qties' => (int)Configuration::get('PS_LAYERED_SHOW_QTIES'), 'id_category_layered' => (int)$id_parent,
|
||||
'selected_filters' => $selectedFilters, 'n_filters' => (int)$nFilters, 'nbr_filterBlocks' => count($filterBlocks), 'filters' => $filterBlocks,
|
||||
'title_values' => $titleValues, 'current_friendly_url' => htmlentities($paramSelected), 'nofollow' => !empty($paramSelected) || $nofollow);
|
||||
'title_values' => $titleValues, 'current_friendly_url' => htmlentities($paramSelected), 'param_product_url' => htmlentities($param_product_url), 'nofollow' => !empty($paramSelected) || $nofollow);
|
||||
|
||||
return $cache;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
{if $nbr_filterBlocks != 0}
|
||||
<script type="text/javascript">
|
||||
current_friendly_url = '#{$current_friendly_url}';
|
||||
param_product_url = '#{$param_product_url}';
|
||||
</script>
|
||||
<div id="layered_block_left" class="block">
|
||||
<h4>{l s='Catalog' mod='blocklayered'}</h4>
|
||||
|
||||
@@ -610,8 +610,8 @@ function getProductAttribute()
|
||||
for (i in attributesCombinations)
|
||||
for (a in tab_attributes)
|
||||
if (attributesCombinations[i]['id_attribute'] == tab_attributes[a])
|
||||
request += '&'+attributesCombinations[i]['group']+'='+attributesCombinations[i]['attribute'];
|
||||
request = request.replace(request.substring(0, 1), '#');
|
||||
request += '/'+attributesCombinations[i]['group']+'-'+attributesCombinations[i]['attribute'];
|
||||
request = request.replace(request.substring(0, 1), '#/');
|
||||
url = window.location+'';
|
||||
|
||||
// redirection
|
||||
@@ -621,16 +621,30 @@ function getProductAttribute()
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
checkUrl();
|
||||
initLocationChange(2000);
|
||||
});
|
||||
|
||||
function initLocationChange(time)
|
||||
{
|
||||
if(!time) time = 1000;
|
||||
setInterval(checkUrl, time);
|
||||
}
|
||||
|
||||
function checkUrl()
|
||||
{
|
||||
url = window.location+'';
|
||||
// if we need to load a specific combination
|
||||
if (url.indexOf('#') != -1)
|
||||
if (url.indexOf('#/') != -1)
|
||||
{
|
||||
// get the params to fill
|
||||
// get the params to fill from a "normal" url
|
||||
params = url.substring(url.indexOf('#') + 1, url.length);
|
||||
tabParams = params.split('&');
|
||||
tabParams = params.split('/');
|
||||
tabValues = new Array();
|
||||
if (tabParams[0] == '')
|
||||
tabParams.shift();
|
||||
for (i in tabParams)
|
||||
tabValues.push(tabParams[i].split('='));
|
||||
tabValues.push(tabParams[i].split('-'));
|
||||
product_id = $('#product_page_product_id').val();
|
||||
// fill html with values
|
||||
$('.color_pick').removeClass('selected');
|
||||
@@ -648,10 +662,10 @@ $(document).ready(function(){
|
||||
$('select[name=group_'+attributesCombinations[a]['id_attribute_group']+']').val(attributesCombinations[a]['id_attribute']);
|
||||
}
|
||||
// find combination
|
||||
if (count == tabValues.length)
|
||||
if (count > 0)
|
||||
findCombination();
|
||||
// no combination found = removing attributes from url
|
||||
else
|
||||
window.location = url.substring(0, url.indexOf('#'));
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user