[-] MO : blockviewed Fix bug adding last product to list, thanks @kluevandrew
This commit is contained in:
1 parent
e6ecf0c177
commit
9848468f3e
1 file changed
+9
-7
@@ -93,7 +93,15 @@ class BlockViewed extends Module
|
|||||||
public function hookRightColumn($params)
|
public function hookRightColumn($params)
|
||||||
{
|
{
|
||||||
$id_product = (int)Tools::getValue('id_product');
|
$id_product = (int)Tools::getValue('id_product');
|
||||||
$productsViewed = (isset($params['cookie']->viewed) && !empty($params['cookie']->viewed)) ? array_slice(explode(',', $params['cookie']->viewed), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();
|
$productsViewed = (isset($params['cookie']->viewed) && !empty($params['cookie']->viewed)) ? array_slice(array_reverse(explode(',', $params['cookie']->viewed)), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();
|
||||||
|
|
||||||
|
if ($id_product && !in_array($id_product, $productsViewed))
|
||||||
|
{
|
||||||
|
if(isset($params['cookie']->viewed) && !empty($params['cookie']->viewed))
|
||||||
|
$params['cookie']->viewed .= ',' . (int)$id_product;
|
||||||
|
else
|
||||||
|
$params['cookie']->viewed = (int)$id_product;
|
||||||
|
}
|
||||||
|
|
||||||
if (count($productsViewed))
|
if (count($productsViewed))
|
||||||
{
|
{
|
||||||
@@ -154,10 +162,6 @@ class BlockViewed extends Module
|
|||||||
if ($product->checkAccess((int)$this->context->customer->id))
|
if ($product->checkAccess((int)$this->context->customer->id))
|
||||||
array_unshift($productsViewed, $id_product);
|
array_unshift($productsViewed, $id_product);
|
||||||
}
|
}
|
||||||
$viewed = '';
|
|
||||||
foreach ($productsViewed as $id_product_viewed)
|
|
||||||
$viewed .= (int)($id_product_viewed).',';
|
|
||||||
$params['cookie']->viewed = rtrim($viewed, ',');
|
|
||||||
|
|
||||||
if (!count($productsViewedObj))
|
if (!count($productsViewedObj))
|
||||||
return;
|
return;
|
||||||
@@ -168,8 +172,6 @@ class BlockViewed extends Module
|
|||||||
|
|
||||||
return $this->display(__FILE__, 'blockviewed.tpl');
|
return $this->display(__FILE__, 'blockviewed.tpl');
|
||||||
}
|
}
|
||||||
elseif ($id_product)
|
|
||||||
$params['cookie']->viewed = (int)($id_product);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user